List of usage examples for weka.classifiers Evaluation pctCorrect
public final double pctCorrect()
From source file:FlexDMThread.java
License:Open Source License
public void run() { try {//from w ww. j av a 2s . c om //Get the data from the source FlexDM.getMainData.acquire(); Instances data = dataset.getSource().getDataSet(); FlexDM.getMainData.release(); //Set class attribute if undefined if (data.classIndex() == -1) { data.setClassIndex(data.numAttributes() - 1); } //Process hyperparameters for classifier String temp = ""; for (int i = 0; i < classifier.getNumParams(); i++) { temp += classifier.getParameter(i).getName(); temp += " "; if (classifier.getParameter(i).getValue() != null) { temp += classifier.getParameter(i).getValue(); temp += " "; } } String[] options = weka.core.Utils.splitOptions(temp); //Print to console- experiment is starting if (temp.equals("")) { //no parameters temp = "results_no_parameters"; try { System.out.println("STARTING CLASSIFIER " + cNum + " - " + classifier.getName() + " on dataset " + dataset.getName().substring(dataset.getName().lastIndexOf("\\") + 1) + " with no parameters"); } catch (Exception e) { System.out.println("STARTING CLASSIFIER " + cNum + " - " + classifier.getName() + " on dataset " + dataset.getName() + " with no parameters"); } } else { //parameters try { System.out.println("STARTING CLASSIFIER " + cNum + " - " + classifier.getName() + " on dataset " + dataset.getName().substring(dataset.getName().lastIndexOf("\\") + 1) + " with parameters " + temp); } catch (Exception e) { System.out.println("STARTING CLASSIFIER " + cNum + " - " + classifier.getName() + " on dataset " + dataset.getName() + " with parameters " + temp); } } //Create classifier, setting parameters weka.classifiers.Classifier x = createObject(classifier.getName()); x.setOptions(options); x.buildClassifier(data); //Process the test selection String[] tempTest = dataset.getTest().split("\\s"); //Create evaluation object for training and testing classifiers Evaluation eval = new Evaluation(data); StringBuffer predictions = new StringBuffer(); //Train and evaluate classifier if (tempTest[0].equals("testset")) { //specified test file //Build classifier x.buildClassifier(data); //Open test file, load data //DataSource testFile = new DataSource(dataset.getTest().substring(7).trim()); // Instances testSet = testFile.getDataSet(); FlexDM.getTestData.acquire(); Instances testSet = dataset.getTestFile().getDataSet(); FlexDM.getTestData.release(); //Set class attribute if undefined if (testSet.classIndex() == -1) { testSet.setClassIndex(testSet.numAttributes() - 1); } //Evaluate model Object[] array = { predictions, new Range(), new Boolean(true) }; eval.evaluateModel(x, testSet, array); } else if (tempTest[0].equals("xval")) { //Cross validation //Build classifier x.buildClassifier(data); //Cross validate eval.crossValidateModel(x, data, Integer.parseInt(tempTest[1]), new Random(1), predictions, new Range(), true); } else if (tempTest[0].equals("leavexval")) { //Leave one out cross validation //Build classifier x.buildClassifier(data); //Cross validate eval.crossValidateModel(x, data, data.numInstances() - 1, new Random(1), predictions, new Range(), true); } else if (tempTest[0].equals("percent")) { //Percentage split of single data set //Set training and test sizes from percentage int trainSize = (int) Math.round(data.numInstances() * Double.parseDouble(tempTest[1])); int testSize = data.numInstances() - trainSize; //Load specified data Instances train = new Instances(data, 0, trainSize); Instances testSet = new Instances(data, trainSize, testSize); //Build classifier x.buildClassifier(train); //Train and evaluate model Object[] array = { predictions, new Range(), new Boolean(true) }; eval.evaluateModel(x, testSet, array); } else { //Evaluate on training data //Test and evaluate model Object[] array = { predictions, new Range(), new Boolean(true) }; eval.evaluateModel(x, data, array); } //create datafile for results String filename = dataset.getDir() + "/" + classifier.getDirName() + "/" + temp + ".txt"; PrintWriter writer = new PrintWriter(filename, "UTF-8"); //Print classifier, dataset, parameters info to file try { writer.println("CLASSIFIER: " + classifier.getName() + "\n DATASET: " + dataset.getName() + "\n PARAMETERS: " + temp); } catch (Exception e) { writer.println("CLASSIFIER: " + classifier.getName() + "\n DATASET: " + dataset.getName() + "\n PARAMETERS: " + temp); } //Add evaluation string to file writer.println(eval.toSummaryString()); //Process result options if (checkResults("stats")) { //Classifier statistics writer.println(eval.toClassDetailsString()); } if (checkResults("model")) { //The model writer.println(x.toString()); } if (checkResults("matrix")) { //Confusion matrix writer.println(eval.toMatrixString()); } if (checkResults("entropy")) { //Entropy statistics //Set options req'd to get the entropy stats String[] opt = new String[4]; opt[0] = "-t"; opt[1] = dataset.getName(); opt[2] = "-k"; opt[3] = "-v"; //Evaluate model String entropy = Evaluation.evaluateModel(x, opt); //Grab the relevant info from the results, print to file entropy = entropy.substring(entropy.indexOf("=== Stratified cross-validation ===") + 35, entropy.indexOf("=== Confusion Matrix ===")); writer.println("=== Entropy Statistics ==="); writer.println(entropy); } if (checkResults("predictions")) { //The models predictions writer.println("=== Predictions ===\n"); if (!dataset.getTest().contains("xval")) { //print header of predictions table if req'd writer.println(" inst# actual predicted error distribution ()"); } writer.println(predictions.toString()); //print predictions to file } writer.close(); //Summary file is semaphore controlled to ensure quality try { //get a permit //grab the summary file, write the classifiers details to it FlexDM.writeFile.acquire(); PrintWriter p = new PrintWriter(new FileWriter(summary, true)); if (temp.equals("results_no_parameters")) { //change output based on parameters temp = temp.substring(8); } //write percent correct, classifier name, dataset name to summary file p.write(dataset.getName() + ", " + classifier.getName() + ", " + temp + ", " + eval.correct() + ", " + eval.incorrect() + ", " + eval.unclassified() + ", " + eval.pctCorrect() + ", " + eval.pctIncorrect() + ", " + eval.pctUnclassified() + ", " + eval.kappa() + ", " + eval.meanAbsoluteError() + ", " + eval.rootMeanSquaredError() + ", " + eval.relativeAbsoluteError() + ", " + eval.rootRelativeSquaredError() + ", " + eval.SFPriorEntropy() + ", " + eval.SFSchemeEntropy() + ", " + eval.SFEntropyGain() + ", " + eval.SFMeanPriorEntropy() + ", " + eval.SFMeanSchemeEntropy() + ", " + eval.SFMeanEntropyGain() + ", " + eval.KBInformation() + ", " + eval.KBMeanInformation() + ", " + eval.KBRelativeInformation() + ", " + eval.weightedTruePositiveRate() + ", " + eval.weightedFalsePositiveRate() + ", " + eval.weightedTrueNegativeRate() + ", " + eval.weightedFalseNegativeRate() + ", " + eval.weightedPrecision() + ", " + eval.weightedRecall() + ", " + eval.weightedFMeasure() + ", " + eval.weightedAreaUnderROC() + "\n"); p.close(); //release semaphore FlexDM.writeFile.release(); } catch (InterruptedException e) { //bad things happened System.err.println("FATAL ERROR OCCURRED: Classifier: " + cNum + " - " + classifier.getName() + " on dataset " + dataset.getName()); } //output we have successfully finished processing classifier if (temp.equals("no_parameters")) { //no parameters try { System.out.println("FINISHED CLASSIFIER " + cNum + " - " + classifier.getName() + " on dataset " + dataset.getName().substring(dataset.getName().lastIndexOf("\\") + 1) + " with no parameters"); } catch (Exception e) { System.out.println("FINISHED CLASSIFIER " + cNum + " - " + classifier.getName() + " on dataset " + dataset.getName() + " with no parameters"); } } else { //with parameters try { System.out.println("FINISHED CLASSIFIER " + cNum + " - " + classifier.getName() + " on dataset " + dataset.getName().substring(dataset.getName().lastIndexOf("\\") + 1) + " with parameters " + temp); } catch (Exception e) { System.out.println("FINISHED CLASSIFIER " + cNum + " - " + classifier.getName() + " on dataset " + dataset.getName() + " with parameters " + temp); } } try { //get a permit //grab the log file, write the classifiers details to it FlexDM.writeLog.acquire(); PrintWriter p = new PrintWriter(new FileWriter(log, true)); Date date = new Date(); Format formatter = new SimpleDateFormat("dd/MM/YYYY HH:mm:ss"); //formatter.format(date) if (temp.equals("results_no_parameters")) { //change output based on parameters temp = temp.substring(8); } //write details to log file p.write(dataset.getName() + ", " + dataset.getTest() + ", \"" + dataset.getResult_string() + "\", " + classifier.getName() + ", " + temp + ", " + formatter.format(date) + "\n"); p.close(); //release semaphore FlexDM.writeLog.release(); } catch (InterruptedException e) { //bad things happened System.err.println("FATAL ERROR OCCURRED: Classifier: " + cNum + " - " + classifier.getName() + " on dataset " + dataset.getName()); } s.release(); } catch (Exception e) { //an error occurred System.err.println("FATAL ERROR OCCURRED: " + e.toString() + "\nClassifier: " + cNum + " - " + classifier.getName() + " on dataset " + dataset.getName()); s.release(); } }
From source file:adams.flow.core.EvaluationHelper.java
License:Open Source License
/** * Returns a statistical value from the evaluation object. * * @param eval the evaluation object to get the value from * @param statistic the type of value to return * @param classIndex the class label index, for statistics like AUC * @return the determined value, Double.NaN if not found * @throws Exception if evaluation fails *///w w w .ja v a2 s . co m public static double getValue(Evaluation eval, EvaluationStatistic statistic, int classIndex) throws Exception { switch (statistic) { case NUMBER_CORRECT: return eval.correct(); case NUMBER_INCORRECT: return eval.incorrect(); case NUMBER_UNCLASSIFIED: return eval.unclassified(); case PERCENT_CORRECT: return eval.pctCorrect(); case PERCENT_INCORRECT: return eval.pctIncorrect(); case PERCENT_UNCLASSIFIED: return eval.pctUnclassified(); case KAPPA_STATISTIC: return eval.kappa(); case MEAN_ABSOLUTE_ERROR: return eval.meanAbsoluteError(); case ROOT_MEAN_SQUARED_ERROR: return eval.rootMeanSquaredError(); case RELATIVE_ABSOLUTE_ERROR: return eval.relativeAbsoluteError(); case ROOT_RELATIVE_SQUARED_ERROR: return eval.rootRelativeSquaredError(); case CORRELATION_COEFFICIENT: return eval.correlationCoefficient(); case SF_PRIOR_ENTROPY: return eval.SFPriorEntropy(); case SF_SCHEME_ENTROPY: return eval.SFSchemeEntropy(); case SF_ENTROPY_GAIN: return eval.SFEntropyGain(); case SF_MEAN_PRIOR_ENTROPY: return eval.SFMeanPriorEntropy(); case SF_MEAN_SCHEME_ENTROPY: return eval.SFMeanSchemeEntropy(); case SF_MEAN_ENTROPY_GAIN: return eval.SFMeanEntropyGain(); case KB_INFORMATION: return eval.KBInformation(); case KB_MEAN_INFORMATION: return eval.KBMeanInformation(); case KB_RELATIVE_INFORMATION: return eval.KBRelativeInformation(); case TRUE_POSITIVE_RATE: return eval.truePositiveRate(classIndex); case NUM_TRUE_POSITIVES: return eval.numTruePositives(classIndex); case FALSE_POSITIVE_RATE: return eval.falsePositiveRate(classIndex); case NUM_FALSE_POSITIVES: return eval.numFalsePositives(classIndex); case TRUE_NEGATIVE_RATE: return eval.trueNegativeRate(classIndex); case NUM_TRUE_NEGATIVES: return eval.numTrueNegatives(classIndex); case FALSE_NEGATIVE_RATE: return eval.falseNegativeRate(classIndex); case NUM_FALSE_NEGATIVES: return eval.numFalseNegatives(classIndex); case IR_PRECISION: return eval.precision(classIndex); case IR_RECALL: return eval.recall(classIndex); case F_MEASURE: return eval.fMeasure(classIndex); case MATTHEWS_CORRELATION_COEFFICIENT: return eval.matthewsCorrelationCoefficient(classIndex); case AREA_UNDER_ROC: return eval.areaUnderROC(classIndex); case AREA_UNDER_PRC: return eval.areaUnderPRC(classIndex); case WEIGHTED_TRUE_POSITIVE_RATE: return eval.weightedTruePositiveRate(); case WEIGHTED_FALSE_POSITIVE_RATE: return eval.weightedFalsePositiveRate(); case WEIGHTED_TRUE_NEGATIVE_RATE: return eval.weightedTrueNegativeRate(); case WEIGHTED_FALSE_NEGATIVE_RATE: return eval.weightedFalseNegativeRate(); case WEIGHTED_IR_PRECISION: return eval.weightedPrecision(); case WEIGHTED_IR_RECALL: return eval.weightedRecall(); case WEIGHTED_F_MEASURE: return eval.weightedFMeasure(); case WEIGHTED_MATTHEWS_CORRELATION_COEFFICIENT: return eval.weightedMatthewsCorrelation(); case WEIGHTED_AREA_UNDER_ROC: return eval.weightedAreaUnderROC(); case WEIGHTED_AREA_UNDER_PRC: return eval.weightedAreaUnderPRC(); case UNWEIGHTED_MACRO_F_MEASURE: return eval.unweightedMacroFmeasure(); case UNWEIGHTED_MICRO_F_MEASURE: return eval.unweightedMicroFmeasure(); case BIAS: return eval.getPluginMetric(Bias.class.getName()).getStatistic(Bias.NAME); case RSQUARED: return eval.getPluginMetric(RSquared.class.getName()).getStatistic(RSquared.NAME); case SDR: return eval.getPluginMetric(SDR.class.getName()).getStatistic(SDR.NAME); case RPD: return eval.getPluginMetric(RPD.class.getName()).getStatistic(RPD.NAME); default: throw new IllegalArgumentException("Unhandled statistic field: " + statistic); } }
From source file:adams.opt.cso.Measure.java
License:Open Source License
/** * Extracts the measure from the Evaluation object. * * @param evaluation the evaluation to use * @param adjust whether to adjust the measure * @return the measure/*from w ww .j a v a2 s.c o m*/ * @throws Exception in case the retrieval of the measure fails */ public double extract(Evaluation evaluation, boolean adjust) throws Exception { switch (this) { case ACC: if (adjust) return 100.0 - evaluation.pctCorrect(); else return evaluation.pctCorrect(); case CC: if (adjust) return 1.0 - evaluation.correlationCoefficient(); else return evaluation.correlationCoefficient(); case MAE: return evaluation.meanAbsoluteError(); case RAE: return evaluation.relativeAbsoluteError(); case RMSE: return evaluation.rootMeanSquaredError(); case RRSE: return evaluation.rootRelativeSquaredError(); default: throw new IllegalStateException("Unhandled measure '" + this + "'!"); } }
From source file:adams.opt.genetic.Measure.java
License:Open Source License
/** * Extracts the measure from the Evaluation object. * * @param evaluation the evaluation to use * @param adjust whether to just the measure * @return the measure//from w ww. j a v a 2s. co m * @see #adjust(double) * @throws Exception in case the retrieval of the measure fails */ public double extract(Evaluation evaluation, boolean adjust) throws Exception { double result; if (this == Measure.ACC) result = evaluation.pctCorrect(); else if (this == Measure.CC) result = evaluation.correlationCoefficient(); else if (this == Measure.MAE) result = evaluation.meanAbsoluteError(); else if (this == Measure.RAE) result = evaluation.relativeAbsoluteError(); else if (this == Measure.RMSE) result = evaluation.rootMeanSquaredError(); else if (this == Measure.RRSE) result = evaluation.rootRelativeSquaredError(); else throw new IllegalStateException("Unhandled measure '" + this + "'!"); if (adjust) result = adjust(result); return result; }
From source file:adams.opt.optimise.genetic.fitnessfunctions.AttributeSelection.java
License:Open Source License
public double evaluate(OptData opd) { init();//from ww w. j a va2s . co m int cnt = 0; int[] weights = getWeights(opd); Instances newInstances = new Instances(getInstances()); for (int i = 0; i < getInstances().numInstances(); i++) { Instance in = newInstances.instance(i); cnt = 0; for (int a = 0; a < getInstances().numAttributes(); a++) { if (a == getInstances().classIndex()) continue; if (weights[cnt++] == 0) { in.setValue(a, 0); } else { in.setValue(a, in.value(a)); } } } Classifier newClassifier = null; try { newClassifier = (Classifier) OptionUtils.shallowCopy(getClassifier()); // evaluate classifier on data Evaluation evaluation = new Evaluation(newInstances); evaluation.crossValidateModel(newClassifier, newInstances, getFolds(), new Random(getCrossValidationSeed())); // obtain measure double measure = 0; if (getMeasure() == Measure.ACC) measure = evaluation.pctCorrect(); else if (getMeasure() == Measure.CC) measure = evaluation.correlationCoefficient(); else if (getMeasure() == Measure.MAE) measure = evaluation.meanAbsoluteError(); else if (getMeasure() == Measure.RAE) measure = evaluation.relativeAbsoluteError(); else if (getMeasure() == Measure.RMSE) measure = evaluation.rootMeanSquaredError(); else if (getMeasure() == Measure.RRSE) measure = evaluation.rootRelativeSquaredError(); else throw new IllegalStateException("Unhandled measure '" + getMeasure() + "'!"); measure = getMeasure().adjust(measure); return (measure); // process fitness } catch (Exception e) { getLogger().log(Level.SEVERE, "Error evaluating", e); } return 0; }
From source file:algoritmogeneticocluster.Cromossomo.java
private void classifica() { //SMO classifier = new SMO(); //HyperPipes classifier = new HyperPipes(); IBk classifier = new IBk(5); BufferedReader datafile = readDataFile(inId + ".arff"); Instances data;// w w w.j av a 2 s.c o m Evaluation eval; try { data = new Instances(datafile); data.setClassIndex(data.numAttributes() - 1); eval = new Evaluation(data); Random rand = new Random(1); // usando semente = 1 int folds = 10; eval.crossValidateModel(classifier, data, folds, rand); //this.fitness = eval.pctCorrect(); //fitness = new BigDecimal(fitness).setScale(2, RoundingMode.HALF_UP).doubleValue();//arredondamento para duas casas pctAcerto = eval.pctCorrect(); pctAcerto = new BigDecimal(pctAcerto).setScale(2, RoundingMode.HALF_UP).doubleValue(); microAverage = getMicroAverage(eval, data); microAverage = new BigDecimal(microAverage).setScale(2, RoundingMode.HALF_UP).doubleValue(); macroAverage = getMacroAverage(eval, data); macroAverage = new BigDecimal(macroAverage).setScale(2, RoundingMode.HALF_UP).doubleValue(); } catch (Exception ex) { System.out.println("Erro ao tentar fazer a classificacao"); Logger.getLogger(WekaSimulation.class.getName()).log(Level.SEVERE, null, ex); } switch (metodoFitness) { case 1: fitness = pctAcerto; break; case 2: fitness = microAverage; break; case 3: fitness = macroAverage; break; default: break; } }
From source file:algoritmogeneticocluster.WekaSimulation.java
/** * @param args the command line arguments *///from w w w.jav a 2 s . c om public static void main(String[] args) { SMO classifier = new SMO(); HyperPipes hy = new HyperPipes(); // classifier.buildClassifier(trainset); BufferedReader datafile = readDataFile("tabela10.arff"); Instances data; Evaluation eval; try { data = new Instances(datafile); data.setClassIndex(data.numAttributes() - 1); eval = new Evaluation(data); Random rand = new Random(1); // using seed = 1 int folds = 10; eval.crossValidateModel(classifier, data, folds, rand); System.out.println(eval.toString()); System.out.println(eval.numInstances()); System.out.println(eval.correct()); System.out.println(eval.incorrect()); System.out.println(eval.pctCorrect()); System.out.println(eval.pctIncorrect()); } catch (Exception ex) { Logger.getLogger(WekaSimulation.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:br.unicamp.ic.recod.gpsi.gp.gpsiJGAPRoiFitnessFunction.java
@Override protected double evaluate(IGPProgram igpp) { double mean_accuracy = 0.0; Object[] noargs = new Object[0]; gpsiRoiBandCombiner roiBandCombinator = new gpsiRoiBandCombiner(new gpsiJGAPVoxelCombiner(super.b, igpp)); // TODO: The ROI descriptors must combine the images first //roiBandCombinator.combineEntity(this.dataset.getTrainingEntities()); gpsiMLDataset mlDataset = new gpsiMLDataset(this.descriptor); try {//from www. j av a 2 s .c o m mlDataset.loadWholeDataset(this.dataset, true); } catch (Exception ex) { Logger.getLogger(gpsiJGAPRoiFitnessFunction.class.getName()).log(Level.SEVERE, null, ex); } int dimensionality = mlDataset.getDimensionality(); int n_classes = mlDataset.getTrainingEntities().keySet().size(); int n_entities = mlDataset.getNumberOfTrainingEntities(); ArrayList<Byte> listOfClasses = new ArrayList<>(mlDataset.getTrainingEntities().keySet()); Attribute[] attributes = new Attribute[dimensionality]; FastVector fvClassVal = new FastVector(n_classes); int i, j; for (i = 0; i < dimensionality; i++) attributes[i] = new Attribute("f" + Integer.toString(i)); for (i = 0; i < n_classes; i++) fvClassVal.addElement(Integer.toString(listOfClasses.get(i))); Attribute classes = new Attribute("class", fvClassVal); FastVector fvWekaAttributes = new FastVector(dimensionality + 1); for (i = 0; i < dimensionality; i++) fvWekaAttributes.addElement(attributes[i]); fvWekaAttributes.addElement(classes); Instances instances = new Instances("Rel", fvWekaAttributes, n_entities); instances.setClassIndex(dimensionality); Instance iExample; for (byte label : mlDataset.getTrainingEntities().keySet()) { for (double[] featureVector : mlDataset.getTrainingEntities().get(label)) { iExample = new Instance(dimensionality + 1); for (j = 0; j < dimensionality; j++) iExample.setValue(i, featureVector[i]); iExample.setValue(dimensionality, label); instances.add(iExample); } } int folds = 5; Random rand = new Random(); Instances randData = new Instances(instances); randData.randomize(rand); Instances trainingSet, testingSet; Classifier cModel; Evaluation eTest; try { for (i = 0; i < folds; i++) { cModel = (Classifier) new SimpleLogistic(); trainingSet = randData.trainCV(folds, i); testingSet = randData.testCV(folds, i); cModel.buildClassifier(trainingSet); eTest = new Evaluation(trainingSet); eTest.evaluateModel(cModel, testingSet); mean_accuracy += eTest.pctCorrect(); } } catch (Exception ex) { Logger.getLogger(gpsiJGAPRoiFitnessFunction.class.getName()).log(Level.SEVERE, null, ex); } mean_accuracy /= (folds * 100); return mean_accuracy; }
From source file:cezeri.feature.selection.FeatureSelectionRanker.java
private static TFeatureRank[] computeCombinationPairs(String[] lstComb, Instances data, Classifier model, int nFolds, boolean show_text, boolean show_plot) { TFeatureRank[] ret = new TFeatureRank[lstComb.length]; int m = lstComb.length; double q = m * 1.0 / 100; int n = 0;//from w w w . j a v a2 s . com for (int i = 0; i < m; i++) { if (n != (int) Math.round(i / q)) { n = (int) Math.round(i / q); System.out.println("progress:" + n + "%"); } TFeatureRank obj = new TFeatureRank(); obj.featureName = lstComb[i]; obj.index = i + ""; Instances subsetData = FactoryInstance.getSubsetData(data, lstComb[i].split(",")); Evaluation eval = FactoryEvaluation.performCrossValidate(model, subsetData, nFolds, show_text, show_plot); try { if (data.classAttribute().isNominal()) { obj.value = eval.pctCorrect(); } else { obj.value = eval.correlationCoefficient(); } } catch (Exception ex) { Logger.getLogger(FeatureSelectionRanker.class.getName()).log(Level.SEVERE, null, ex); } ret[i] = obj; } ArrayList<TFeatureRank> lst = toArrayList(ret); Collections.sort(lst, new CustomComparatorForFeatureRank()); ret = toArray(lst); return ret; }
From source file:cezeri.feature.selection.FeatureSelectionRanker.java
private static double computeCombinationFeature(String lstComb, Instances data, int folds, Classifier model, boolean show_text, boolean show_plot) { TFeatureRank obj = new TFeatureRank(); obj.featureName = lstComb;// www . jav a 2 s . c o m obj.index = ""; Instances subsetData = FactoryInstance.getSubsetData(data, lstComb.split(",")); Evaluation eval = FactoryEvaluation.performCrossValidate(model, subsetData, folds, show_text, show_plot); try { if (data.classAttribute().isNominal()) { obj.value = eval.pctCorrect(); } else { obj.value = eval.correlationCoefficient(); } } catch (Exception ex) { Logger.getLogger(FeatureSelectionRanker.class.getName()).log(Level.SEVERE, null, ex); } return obj.value; }