@Override public void removeAllRows() { instances.delete(); }
Instances data; ... // it's important to iterate from last to first, because when we remove // an instance, the rest shifts by one position. for (int i = data.numInstances - 1; i >= 0; i--) { Instance inst = data.getInstance(i); if (condition(inst)) { data.delete(i); } }
@Override public void delete() { table.removeAllRows(); super.delete(); }
@Override public void delete(int index) { table.removeRow(index); super.delete(index); }
@Override public boolean removeRow(int row) { if (instances.instance(row) == null) { return false; } instances.delete(row); return true; }
/** * Deletes all training instances from our dataset. */ public void removeAllInstances() { if (m_trainingData != null) { m_trainingData.delete(); try { initialize(); } catch (Exception e) { } ; } }
/** * Deletes all training instances from our dataset. */ public void removeAllInstances() { if (m_trainingData != null) { m_trainingData.delete(); try { initialize(); } catch (Exception e) { } ; } }
/** * Deletes the unnecessary instances, the instances that have value 0 on * given attribute. * * @param trainSet the trainSet on which the deletion will be applied * @param attrIndex the index of the attribute that the deletion is based */ protected void deleteInstances(Instances trainSet, int attrIndex) { for (int i = 0; i < trainSet.numInstances(); i++) { if (trainSet.instance(i).stringValue(attrIndex).equals("0")) { trainSet.delete(i); // While deleting an instance from the trainSet, i must reduced too i--; } } } //spark temporary edit
/** * deletes the instance at the given index * * @param rowIndex the index of the row * @param notify whether to notify the listeners */ public void deleteInstanceAt(int rowIndex, boolean notify) { if ((rowIndex >= 0) && (rowIndex < getRowCount())) { if (!m_IgnoreChanges) { addUndoPoint(); } m_Data.delete(rowIndex); if (notify) { notifyListener(new TableModelEvent(this, rowIndex, rowIndex, TableModelEvent.ALL_COLUMNS, TableModelEvent.DELETE)); } } }
/** * deletes the instance at the given index * * @param rowIndex the index of the row * @param notify whether to notify the listeners */ public void deleteInstanceAt(int rowIndex, boolean notify) { if ((rowIndex >= 0) && (rowIndex < getRowCount())) { if (!m_IgnoreChanges) { addUndoPoint(); } m_Data.delete(rowIndex); if (notify) { notifyListener(new TableModelEvent(this, rowIndex, rowIndex, TableModelEvent.ALL_COLUMNS, TableModelEvent.DELETE)); } } }
/** * deletes the instance at the given index * * @param rowIndex the index of the row * @param notify whether to notify the listeners */ public void deleteInstanceAt(int rowIndex, boolean notify) { if ((rowIndex >= 0) && (rowIndex < getRowCount())) { if (!m_IgnoreChanges) { addUndoPoint(); } m_Data.delete(rowIndex); if (notify) { notifyListener(new TableModelEvent(this, rowIndex, rowIndex, TableModelEvent.ALL_COLUMNS, TableModelEvent.DELETE)); } } }
/** * Resets the class values of all instances using voting. For each instance * the class value that satisfies the most rules is choosen as new class * value. * * @param dataset the dataset to work on * @return the changed instances * @throws Exception if something goes wrong */ private Instances voteDataset(Instances dataset) throws Exception { for (int i = 0; i < dataset.numInstances(); i++) { Instance inst = dataset.firstInstance(); inst = votedReclassifyExample(inst); dataset.add(inst); dataset.delete(0); } return dataset; }
@Override public void buildInternal(MultiLabelInstances mlData) throws Exception { //Do the transformation //and generate the classifier pt6Trans = new IncludeLabelsTransformation(); debug("Transforming the dataset"); transformed = pt6Trans.transformInstances(mlData); debug("Building the base-level classifier"); baseClassifier.buildClassifier(transformed); transformed.delete(); }
/** * deletes the instance at the given index * * @param rowIndex the index of the row * @param notify whether to notify the listeners */ public void deleteInstanceAt(int rowIndex, boolean notify) { if ((rowIndex >= 0) && (rowIndex < getRowCount())) { if (!m_IgnoreChanges) { addUndoPoint(); } m_Data.delete(rowIndex); if (notify) { notifyListener(new TableModelEvent(this, rowIndex, rowIndex, TableModelEvent.ALL_COLUMNS, TableModelEvent.DELETE)); } } }
@Override public Instance transformInstance(Instance x) throws Exception{ Instances tmpInst = new Instances(x.dataset()); tmpInst.delete(); tmpInst.add(x); Instances features = this.extractPart(tmpInst, false); Instances pseudoLabels = new Instances(this.compressedMatrix); Instance tmpin = pseudoLabels.instance(0); pseudoLabels.delete(); pseudoLabels.add(tmpin); for ( int i = 0; i< pseudoLabels.classIndex(); i++) { pseudoLabels.instance(0).setMissing(i); } Instances newDataSet = Instances.mergeInstances(pseudoLabels, features); newDataSet.setClassIndex(this.size); return newDataSet.instance(0); }
@Override public Instance transformInstance(Instance x) throws Exception{ Instances tmpInst = new Instances(x.dataset()); tmpInst.delete(); tmpInst.add(x); Instances features = this.extractPart(tmpInst, false); Instances pseudoLabels = new Instances(this.compressedMatrix); Instance tmpin = pseudoLabels.instance(0); pseudoLabels.delete(); pseudoLabels.add(tmpin); for ( int i = 0; i< pseudoLabels.classIndex(); i++) { pseudoLabels.instance(0).setMissing(i); } Instances newDataSet = Instances.mergeInstances(pseudoLabels, features); newDataSet.setClassIndex(this.size); return newDataSet.instance(0); }
/** * This will remove all buffered instances from the inputformat dataset. Use * this method rather than getInputFormat().delete(); */ protected void flushInput() { if ((m_InputStringAtts.getAttributeIndices().length > 0) || (m_InputRelAtts.getAttributeIndices().length > 0)) { m_InputFormat = m_InputFormat.stringFreeStructure(); m_InputStringAtts = new StringLocator(m_InputFormat, m_InputStringAtts.getAllowedIndices()); m_InputRelAtts = new RelationalLocator(m_InputFormat, m_InputRelAtts.getAllowedIndices()); } else { // This more efficient than new Instances(m_InputFormat, 0); m_InputFormat.delete(); } }
@Override public Instance transformInstance(Instance x) throws Exception{ Instances tmpInst = new Instances(x.dataset()); tmpInst.delete(); tmpInst.add(x); Instances features = this.extractPart(tmpInst, false); Instances pseudoLabels = new Instances(this.compressedTemplateInst); Instance tmpin = pseudoLabels.instance(0); pseudoLabels.delete(); pseudoLabels.add(tmpin); for ( int i = 0; i< pseudoLabels.classIndex(); i++) { pseudoLabels.instance(0).setMissing(i); } Instances newDataSet = Instances.mergeInstances(pseudoLabels, features); newDataSet.setClassIndex(pseudoLabels.numAttributes()); return newDataSet.instance(0); }
@Override public Instance transformInstance(Instance x) throws Exception{ Instances tmpInst = new Instances(x.dataset()); tmpInst.delete(); tmpInst.add(x); Instances features = this.extractPart(tmpInst, false); Instances pseudoLabels = new Instances(this.compressedTemplateInst); Instance tmpin = pseudoLabels.instance(0); pseudoLabels.delete(); pseudoLabels.add(tmpin); for ( int i = 0; i< pseudoLabels.classIndex(); i++) { pseudoLabels.instance(0).setMissing(i); } Instances newDataSet = Instances.mergeInstances(pseudoLabels, features); newDataSet.setClassIndex(pseudoLabels.numAttributes()); return newDataSet.instance(0); }
/** * This will remove all buffered instances from the inputformat dataset. Use * this method rather than getInputFormat().delete(); */ protected void flushInput() { if ((m_InputStringAtts.getAttributeIndices().length > 0) || (m_InputRelAtts.getAttributeIndices().length > 0)) { m_InputFormat = m_InputFormat.stringFreeStructure(); m_InputStringAtts = new StringLocator(m_InputFormat, m_InputStringAtts.getAllowedIndices()); m_InputRelAtts = new RelationalLocator(m_InputFormat, m_InputRelAtts.getAllowedIndices()); } else { // This more efficient than new Instances(m_InputFormat, 0); m_InputFormat.delete(); } }