List of usage examples for weka.core Instances deleteWithMissing
public void deleteWithMissing(Attribute att)
From source file:ID3Chi.java
License:Open Source License
private void MakeALeaf(Instances data) { data.deleteWithMissing(m_Attribute); if (data.numInstances() == 0) { SetNullDistribution(data);//from w w w .jav a 2s. co m return; } m_Distribution = new double[data.numClasses()]; Enumeration instEnum = data.enumerateInstances(); while (instEnum.hasMoreElements()) { Instance inst = (Instance) instEnum.nextElement(); m_Distribution[(int) inst.classValue()]++; } Utils.normalize(m_Distribution); m_ClassValue = Utils.maxIndex(m_Distribution); m_ClassAttribute = data.classAttribute(); // set m_Attribute to null to mark this node as a leaf m_Attribute = null; }
From source file:org.vimarsha.utils.impl.ArffAttributeInfoExtractor.java
License:Open Source License
/** * Returns a table model with the attribute related info when the selected attribute index is passed. * * @param index index of the attribute/*w w w .j av a2s.c om*/ * @return DefaultTableModel */ public DefaultTableModel getArffAttributeInfo(int index) { DefaultTableModel defaultTableModel = new DefaultTableModel(); Instances temp = this.arffData; //since kthSmallestValue cannot handle missing values, they need to be removed. temp.deleteWithMissing(index); ArrayList<String> tmp = new ArrayList<String>(); defaultTableModel.addColumn("Statistics", new String[] { "Name", "Variance", "Min", "Max", "Mean" }); tmp.add(temp.attribute(index).name()); tmp.add(String.valueOf(temp.variance(index))); tmp.add(String.valueOf(temp.kthSmallestValue(index, 1))); //min value is the 1st smallest value tmp.add(String.valueOf(temp.kthSmallestValue(index, temp.numInstances()))); //max value is the last smallest value tmp.add(String.valueOf(temp.meanOrMode(index))); defaultTableModel.addColumn("Value", tmp.toArray()); return defaultTableModel; }