/** * Output an instance after filtering and remove from the output queue. * * @return the instance that has most recently been filtered (or null if the * queue is empty). */ @Override public Instance output() { return m_attributeFilter.output(); }
/** * Output an instance after filtering and remove from the output queue. * * @return the instance that has most recently been filtered (or null if the * queue is empty). */ @Override public Instance output() { return m_attributeFilter.output(); }
/** * processes the given instance (may change the provided instance) and returns * the modified version. * * @param instance the instance to process * @return the modified data * @throws Exception in case the processing goes wrong */ @Override protected Instance process(Instance instance) throws Exception { m_Remove.input(instance); return m_Remove.output(); }
/** * processes the given instance (may change the provided instance) and returns * the modified version. * * @param instance the instance to process * @return the modified data * @throws Exception in case the processing goes wrong */ @Override protected Instance process(Instance instance) throws Exception { m_Remove.input(instance); return m_Remove.output(); }
/** * reduce the dimensionality of a single instance to include only those * attributes chosen by the last run of attribute selection. * * @param in the instance to be reduced * @return a dimensionality reduced instance * @exception Exception if the instance can't be reduced */ public Instance reduceDimensionality(Instance in) throws Exception { if (m_attributeFilter == null) { throw new Exception("No feature selection has been performed yet!"); } if (m_transformer != null) { in = m_transformer.convertInstance(in); } m_attributeFilter.input(in); m_attributeFilter.batchFinished(); Instance result = m_attributeFilter.output(); return result; }
/** * reduce the dimensionality of a single instance to include only those * attributes chosen by the last run of attribute selection. * * @param in the instance to be reduced * @return a dimensionality reduced instance * @exception Exception if the instance can't be reduced */ public Instance reduceDimensionality(Instance in) throws Exception { if (m_attributeFilter == null) { throw new Exception("No feature selection has been performed yet!"); } if (m_transformer != null) { in = m_transformer.convertInstance(in); } m_attributeFilter.input(in); m_attributeFilter.batchFinished(); Instance result = m_attributeFilter.output(); return result; }
/** * Update the distance function (if necessary) for the newly added instance. * * @param ins the instance to add */ public void update(Instance ins) { try { m_Remove.input(ins); m_Filter.input(m_Remove.output()); m_Distance.update(m_Filter.output()); } catch (Exception e) { e.printStackTrace(); } }
/** * Update the distance function (if necessary) for the newly added instance. * * @param ins the instance to add */ public void update(Instance ins) { try { m_Remove.input(ins); m_Filter.input(m_Remove.output()); m_Distance.update(m_Filter.output()); } catch (Exception e) { e.printStackTrace(); } }
/** * Process an instance * * @param inst the instance to process * @throws Exception if a problem occurs */ public void processInstance(Instance inst) throws Exception { if (m_remove != null) { m_remove.input(inst); inst = m_remove.output(); } for (int i = 0; i < inst.numAttributes(); i++) { for (int j = 0; j < (i + 1); j++) { m_corrMatrix[i][j] += cov(inst, i, j); } } }
protected MultiLabelOutput makePredictionInternal(Instance instance) throws Exception { double[] confidences = new double[numLabels]; boolean[] labels = new boolean[numLabels]; // gather votes for (int i = 0; i < numOfModels; i++) { remove[i].input(instance); remove[i].batchFinished(); Instance newInstance = remove[i].output(); MultiLabelOutput subsetMLO = subsetClassifiers[i].makePrediction(newInstance); boolean[] localPredictions = subsetMLO.getBipartition(); double[] localConfidences = subsetMLO.getConfidences(); for (int j = 0; j < classIndicesPerSubset_d[i].size(); j++) { labels[classIndicesPerSubset_d[i].get(j)] = localPredictions[j]; confidences[classIndicesPerSubset_d[i].get(j)] = localConfidences[j]; } } MultiLabelOutput mlo = new MultiLabelOutput(labels, confidences); return mlo; }
remove[i].input(instance); remove[i].batchFinished(); Instance newInstance = remove[i].output(); MLO[multiSplitNo] = multiLabelLearners.get(multiSplitNo).makePrediction(newInstance);
/** * Input an instance for filtering. * * @param instance the input instance * @return true if the filtered instance may now be collected with output(). */ @Override public boolean input(Instance instance) { if (getInputFormat() == null) { throw new IllegalStateException("No input instance format defined"); } if (m_NewBatch) { resetQueue(); m_NewBatch = false; } if (m_removeFilter != null) { m_removeFilter.input(instance); Instance processed = m_removeFilter.output(); copyValues(processed, false, instance.dataset(), outputFormatPeek()); push(processed, false); // No need to copy return true; } bufferInput(instance); return false; }
/** * Input an instance for filtering. * * @param instance the input instance * @return true if the filtered instance may now be collected with output(). */ @Override public boolean input(Instance instance) { if (getInputFormat() == null) { throw new IllegalStateException("No input instance format defined"); } if (m_NewBatch) { resetQueue(); m_NewBatch = false; } if (m_removeFilter != null) { m_removeFilter.input(instance); Instance processed = m_removeFilter.output(); copyValues(processed, false, instance.dataset(), outputFormatPeek()); push(processed, false); // No need to copy return true; } bufferInput(instance); return false; }
Instance dtInstance = m_delTransform.output();
remove[i].input(instance); remove[i].batchFinished(); Instance newInstance = remove[i].output(); MultiLabelOutput subsetMLO = subsetClassifiers[i].makePrediction(newInstance); for (int j = 0; j < sizeOfSubset; j++) {
instance = m_delTransform.output();
/** * Remove all label attributes except labelToKeep * * @param instance * @param labelToKeep * @return transformed Instance */ public Instance transformInstance(Instance instance, int labelToKeep) { Instance transformedInstance; remove.input(instance); transformedInstance = remove.output(); add.input(transformedInstance); transformedInstance = add.output(); transformedInstance.setDataset(shell); int[] labelIndices = data.getLabelIndices(); if (data.getDataSet().attribute(labelIndices[labelToKeep]).value(0).equals("1")) { transformedInstance.setValue(shell.numAttributes() - 1, 1 - instance.value(labelIndices[labelToKeep])); } else { transformedInstance.setValue(shell.numAttributes() - 1, instance.value(labelIndices[labelToKeep])); } return transformedInstance; }
while ((processed = m_removeFilter.output()) != null) { processed.setDataset(outputDataset); push(processed, false); // No need to copy