@Override public void deleteWithMissingClass() { super.deleteWithMissingClass(); }
/** * Method for building a classifier tree. * * @param data the data to build the tree from * @throws Exception if something goes wrong */ public void buildClassifier(Instances data) throws Exception { // remove instances with missing class data = new Instances(data); data.deleteWithMissingClass(); buildTree(data, false); }
/** * Method for building a classifier tree. * * @param data the data to build the tree from * @throws Exception if something goes wrong */ public void buildClassifier(Instances data) throws Exception { // remove instances with missing class data = new Instances(data); data.deleteWithMissingClass(); buildTree(data, false); }
/** * Loads test data, if required. * * @param data * the current training data * @throws Exception * if test sets are not compatible with training data */ protected void loadTestData(Instances data) throws Exception { String msg; m_SearchSpaceTestInst = null; if (m_SearchSpaceTestSet.exists() && !m_SearchSpaceTestSet.isDirectory()) { m_SearchSpaceTestInst = DataSource.read(m_SearchSpaceTestSet .getAbsolutePath()); m_SearchSpaceTestInst.setClassIndex(data.classIndex()); msg = data.equalHeadersMsg(m_SearchSpaceTestInst); if (msg != null) { throw new IllegalArgumentException( "Test set for search space not compatible with training dta:\n" + msg); } m_SearchSpaceTestInst.deleteWithMissingClass(); log("Using test set for search space: " + m_SearchSpaceTestSet); } }
/** * Builds Id3 decision tree classifier. * * @param data the training data * @exception Exception if classifier can't be built successfully */ public void buildClassifier(Instances data) throws Exception { // can classifier handle the data? getCapabilities().testWithFail(data); // remove instances with missing class data = new Instances(data); data.deleteWithMissingClass(); makeTree(data); }
/** * Generates the classifier. * * @param instances set of instances serving as training data * @throws Exception if the classifier has not been generated successfully */ public void buildClassifier(Instances instances) throws Exception { // can classifier handle the data? getCapabilities().testWithFail(instances); // remove instances with missing class instances = new Instances(instances); instances.deleteWithMissingClass(); m_Train = new Instances(instances, 0, instances.numInstances()); // initializes class attributes ** java-speaking! :-) ** init_m_Attributes(); }
/** * Generates the classifier. * * @param instances set of instances serving as training data * @throws Exception if the classifier has not been generated successfully */ public void buildClassifier(Instances instances) throws Exception { // can classifier handle the data? getCapabilities().testWithFail(instances); // remove instances with missing class instances = new Instances(instances); instances.deleteWithMissingClass(); m_Train = new Instances(instances, 0, instances.numInstances()); // initializes class attributes ** java-speaking! :-) ** init_m_Attributes(); }
/** * Generates the classifier. * * @param instances set of instances serving as training data * @throws Exception if the classifier has not been generated successfully */ public void buildClassifier(Instances instances) throws Exception { // can classifier handle the data? getCapabilities().testWithFail(instances); // remove instances with missing class instances = new Instances(instances); instances.deleteWithMissingClass(); m_Train = new Instances(instances, 0, instances.numInstances()); m_MinArray = new double [m_Train.numAttributes()]; m_MaxArray = new double [m_Train.numAttributes()]; for (int i = 0; i < m_Train.numAttributes(); i++) { m_MinArray[i] = m_MaxArray[i] = Double.NaN; } Enumeration enu = m_Train.enumerateInstances(); while (enu.hasMoreElements()) { updateMinMax((Instance) enu.nextElement()); } }
/** * Method for building a pruneable classifier tree. * * @param data the data to build the tree from * @throws Exception if tree can't be built successfully */ public void buildClassifier(Instances data) throws Exception { // remove instances with missing class data = new Instances(data); data.deleteWithMissingClass(); Random random = new Random(m_seed); data.stratify(numSets); buildTree(data.trainCV(numSets, numSets - 1, random), data.testCV(numSets, numSets - 1), !m_cleanup); if (pruneTheTree) { prune(); } if (m_cleanup) { cleanup(new Instances(data, 0)); } }
/** * Method for building a pruneable classifier tree. * * @param data the data to build the tree from * @throws Exception if tree can't be built successfully */ public void buildClassifier(Instances data) throws Exception { // remove instances with missing class data = new Instances(data); data.deleteWithMissingClass(); Random random = new Random(m_seed); data.stratify(numSets); buildTree(data.trainCV(numSets, numSets - 1, random), data.testCV(numSets, numSets - 1), !m_cleanup); if (pruneTheTree) { prune(); } if (m_cleanup) { cleanup(new Instances(data, 0)); } }
/** * Method for building a pruneable classifier tree. * * @param data the data for building the tree * @throws Exception if something goes wrong */ public void buildClassifier(Instances data) throws Exception { // remove instances with missing class data = new Instances(data); data.deleteWithMissingClass(); buildTree(data, m_subtreeRaising || !m_cleanup); if (m_collapseTheTree) { collapse(); } if (m_pruneTheTree) { prune(); } if (m_cleanup) { cleanup(new Instances(data, 0)); } }
/** * Method for building a pruneable classifier tree. * * @param data the data for building the tree * @throws Exception if something goes wrong */ public void buildClassifier(Instances data) throws Exception { // remove instances with missing class data = new Instances(data); data.deleteWithMissingClass(); buildTree(data, m_subtreeRaising || !m_cleanup); if (m_collapseTheTree) { collapse(); } if (m_pruneTheTree) { prune(); } if (m_cleanup) { cleanup(new Instances(data, 0)); } }
/** * Build the clusterer on the filtered data. * * @param data the training data * @throws Exception if the clusterer could not be built successfully */ @Override public void buildClusterer(Instances data) throws Exception { if (m_Clusterer == null) { throw new Exception("No base clusterer has been set!"); } // remove instances with missing class if (data.classIndex() > -1) { data = new Instances(data); data.deleteWithMissingClass(); } m_Filter.setInputFormat(data); // filter capabilities are checked here data = Filter.useFilter(data, m_Filter); // can clusterer handle the data? getClusterer().getCapabilities().testWithFail(data); m_FilteredInstances = data.stringFreeStructure(); m_Clusterer.buildClusterer(data); }
/** * Build the clusterer on the filtered data. * * @param data the training data * @throws Exception if the clusterer could not be built successfully */ @Override public void buildClusterer(Instances data) throws Exception { if (m_Clusterer == null) { throw new Exception("No base clusterer has been set!"); } // remove instances with missing class if (data.classIndex() > -1) { data = new Instances(data); data.deleteWithMissingClass(); } m_Filter.setInputFormat(data); // filter capabilities are checked here data = Filter.useFilter(data, m_Filter); // can clusterer handle the data? getClusterer().getCapabilities().testWithFail(data); m_FilteredInstances = data.stringFreeStructure(); m_Clusterer.buildClusterer(data); }
/** * Builds the classifier * * @param data the training data to be used for generating the boosted * classifier. * @throws Exception if the classifier could not be built successfully */ @Override public void buildClassifier(Instances data) throws Exception { // can classifier handle the data? getCapabilities().testWithFail(data); // remove instances with missing class Instances train = new Instances(data); train.deleteWithMissingClass(); if (m_Classifier == null) { throw new Exception("A base classifier has not been specified!"); } if (getDebug()) { System.out.println("Start training ..."); } m_NumClasses = train.numClasses(); // convert the training dataset into single-instance dataset m_ConvertToProp.setWeightMethod(getWeightMethod()); m_ConvertToProp.setInputFormat(train); train = Filter.useFilter(train, m_ConvertToProp); train.deleteAttributeAt(0); // remove the bag index attribute m_Classifier.buildClassifier(train); }
/** * Generates a classifier. * * @param data set of instances serving as training data * @throws Exception if the classifier has not been * generated successfully */ public void buildClassifier(Instances data) throws Exception { this.instanceConverter = new WekaToSamoaInstanceConverter(); getCapabilities().testWithFail(data); data = new Instances(data); data.deleteWithMissingClass(); m_ActualClassifier.resetLearning(); for (int i = 0; i < data.numInstances(); i++) updateClassifier(data.instance(i)); }
/** * Builds the classifier. * * @param data the data to train with * @throws Exception if classifier can't be built successfully */ @Override public void buildClassifier(Instances data) throws Exception { reset(); m_header = new Instances(data, 0); if (m_selectedSplitMetric == GINI_SPLIT) { m_splitMetric = new GiniSplitMetric(); } else { m_splitMetric = new InfoGainSplitMetric(m_minFracWeightForTwoBranchesGain); } data = new Instances(data); data.deleteWithMissingClass(); for (int i = 0; i < data.numInstances(); i++) { updateClassifier(data.instance(i)); } // can classifier handle the data? getCapabilities().testWithFail(data); }
/** * Builds the classifier. * * @param data the data to train with * @throws Exception if classifier can't be built successfully */ @Override public void buildClassifier(Instances data) throws Exception { reset(); m_header = new Instances(data, 0); if (m_selectedSplitMetric == GINI_SPLIT) { m_splitMetric = new GiniSplitMetric(); } else { m_splitMetric = new InfoGainSplitMetric(m_minFracWeightForTwoBranchesGain); } data = new Instances(data); data.deleteWithMissingClass(); for (int i = 0; i < data.numInstances(); i++) { updateClassifier(data.instance(i)); } // can classifier handle the data? getCapabilities().testWithFail(data); }
/** * Builds the classifiers. * * @param insts the training data. * @throws Exception if a classifier can't be built */ public void buildClassifier(Instances insts) throws Exception { Instances newInsts; // can classifier handle the data? getCapabilities().testWithFail(insts); // remove instances with missing class insts = new Instances(insts); insts.deleteWithMissingClass(); m_Classifiers = AbstractClassifier.makeCopies(m_Classifier, insts.numClasses()); m_ClassFilters = new MakeIndicator[insts.numClasses()]; for (int i = 0; i < insts.numClasses(); i++) { m_ClassFilters[i] = new MakeIndicator(); m_ClassFilters[i].setAttributeIndex("" + (insts.classIndex() + 1)); m_ClassFilters[i].setValueIndex(i); m_ClassFilters[i].setNumeric(true); m_ClassFilters[i].setInputFormat(insts); newInsts = Filter.useFilter(insts, m_ClassFilters[i]); m_Classifiers[i].buildClassifier(newInsts); } }
/** * Builds the classifier from the given training data. */ @Override public void buildClassifier(Instances data) throws Exception { data = new Instances(data); data.deleteWithMissingClass(); getCapabilities().testWithFail(data); m_Filter = new MultiFilter(); Filter[] twoFilters = new Filter[2]; PartitionMembership pm = new PartitionMembership(); pm.setPartitionGenerator(getPartitionGenerator()); MultiInstanceWrapper miw = new MultiInstanceWrapper(); miw.setFilter(pm); twoFilters[0] = miw; twoFilters[1] = new Remove(); ((Remove) twoFilters[1]).setAttributeIndices("1"); m_Filter.setFilters(twoFilters); m_Filter.setInputFormat(data); Instances propositionalData = Filter.useFilter(data, m_Filter); // can classifier handle the data? getClassifier().getCapabilities().testWithFail(propositionalData); m_Classifier.buildClassifier(propositionalData); }