Codota Logo
Evaluation.evaluateModel
Code IndexAdd Codota to your IDE (free)

How to use
evaluateModel
method
in
weka.classifiers.Evaluation

Best Java code snippets using weka.classifiers.Evaluation.evaluateModel (Showing top 20 results out of 315)

  • Common ways to obtain Evaluation
private void myMethod () {
Evaluation e =
  • Codota IconInstances data;new Evaluation(data)
  • Smart code suggestions by Codota
}
origin: nz.ac.waikato.cms.weka/weka-stable

/**
 * A test method for this class. Just extracts the first command line argument
 * as a classifier class name and calls evaluateModel.
 * 
 * @param args an array of command line arguments, the first of which must be
 *          the class name of a classifier.
 */
public static void main(String[] args) {
 try {
  if (args.length == 0) {
   throw new Exception("The first argument must be the class name"
    + " of a classifier");
  }
  String classifier = args[0];
  args[0] = "";
  System.out.println(evaluateModel(classifier, args));
 } catch (Exception ex) {
  ex.printStackTrace();
  System.err.println(ex.getMessage());
 }
}
origin: Waikato/weka-trunk

/**
 * A test method for this class. Just extracts the first command line argument
 * as a classifier class name and calls evaluateModel.
 * 
 * @param args an array of command line arguments, the first of which must be
 *          the class name of a classifier.
 */
public static void main(String[] args) {
 try {
  if (args.length == 0) {
   throw new Exception("The first argument must be the class name"
    + " of a classifier");
  }
  String classifier = args[0];
  args[0] = "";
  System.out.println(evaluateModel(classifier, args));
 } catch (Exception ex) {
  ex.printStackTrace();
  System.err.println(ex.getMessage());
 }
}
origin: de.tudarmstadt.ukp.dkpro.tc/de.tudarmstadt.ukp.dkpro.tc.weka-gpl

/**
 * Evaluates a given single-label classifier on given train and test sets.
 * 
 * @param cl
 *            single-label classifier, needs to be trained beforehand
 * @param trainData
 * @param testData
 * @return
 * @throws Exception
 */
public static Evaluation getEvaluationSinglelabel(Classifier cl, Instances trainData,
    Instances testData)
  throws Exception
{
  Evaluation eval = new Evaluation(trainData);
  eval.evaluateModel(cl, testData);
  return eval;
}
origin: org.dkpro.tc/dkpro-tc-ml-weka

private void createWekaEvaluationObject(Classifier classifier, File evalOutput,
    Instances trainData, Instances testData)
  throws Exception
{
  Evaluation eval = new Evaluation(trainData);
  eval.evaluateModel(classifier, testData);
  weka.core.SerializationHelper.write(evalOutput.getAbsolutePath(), eval);
}
origin: dkpro/dkpro-tc

protected void createWekaEvaluationObject(Classifier classifier, File evalOutput,
    Instances trainData, Instances testData)
  throws Exception
{
  Evaluation eval = new Evaluation(trainData);
  eval.evaluateModel(classifier, testData);
  weka.core.SerializationHelper.write(evalOutput.getAbsolutePath(), eval);
}
origin: droidefense/engine

public Evaluation classify(Classifier model, Instances trainingSet, Instances testingSet) throws Exception {
  Evaluation evaluation = new Evaluation(trainingSet);
  model.buildClassifier(trainingSet);
  evaluation.evaluateModel(model, testingSet);
  return evaluation;
}
origin: Waikato/weka-trunk

/**
 * runs the classifier instance with the given options.
 *
 * @param classifier the classifier to run
 * @param options the commandline options
 */
public static void runClassifier(Classifier classifier, String[] options) {
 try {
  if (classifier instanceof CommandlineRunnable) {
   ((CommandlineRunnable)classifier).preExecution();
  }
  System.out.println(Evaluation.evaluateModel(classifier, options));
 } catch (Exception e) {
  if (((e.getMessage() != null)
   && (e.getMessage().indexOf("General options") == -1))
   || (e.getMessage() == null)) {
   e.printStackTrace();
  } else {
   System.err.println(e.getMessage());
  }
 }
 if (classifier instanceof CommandlineRunnable) {
  try {
   ((CommandlineRunnable) classifier).postExecution();
  } catch (Exception ex) {
   ex.printStackTrace();
  }
 }
}
origin: nz.ac.waikato.cms.weka/weka-stable

/**
 * Returns the error of the probability estimates for the current model on a
 * set of instances.
 * 
 * @param data the set of instances
 * @return the error
 * @throws Exception if something goes wrong
 */
protected double getMeanAbsoluteError(Instances data) throws Exception {
 Evaluation eval = new Evaluation(data);
 eval.evaluateModel(this, data);
 return eval.meanAbsoluteError();
}
origin: Waikato/weka-trunk

/**
 * Returns the misclassification error of the current model on a set of
 * instances.
 * 
 * @param data the set of instances
 * @return the error rate
 * @throws Exception if something goes wrong
 */
protected double getErrorRate(Instances data) throws Exception {
 Evaluation eval = new Evaluation(data);
 eval.evaluateModel(this, data);
 return eval.errorRate();
}
origin: nz.ac.waikato.cms.weka/weka-stable

/**
 * Returns the misclassification error of the current model on a set of
 * instances.
 * 
 * @param data the set of instances
 * @return the error rate
 * @throws Exception if something goes wrong
 */
protected double getErrorRate(Instances data) throws Exception {
 Evaluation eval = new Evaluation(data);
 eval.evaluateModel(this, data);
 return eval.errorRate();
}
origin: Waikato/weka-trunk

/**
 * Returns the error of the probability estimates for the current model on a
 * set of instances.
 * 
 * @param data the set of instances
 * @return the error
 * @throws Exception if something goes wrong
 */
protected double getMeanAbsoluteError(Instances data) throws Exception {
 Evaluation eval = new Evaluation(data);
 eval.evaluateModel(this, data);
 return eval.meanAbsoluteError();
}
origin: Waikato/weka-trunk

/**
 * Determine whether the scheme performs worse than ZeroR during testing
 * 
 * @param classifier the pre-trained classifier
 * @param evaluation the classifier evaluation object
 * @param train the training data
 * @param test the test data
 * @return index 0 is true if the scheme performs better than ZeroR
 * @throws Exception if there was a problem during the scheme's testing
 */
protected boolean[] testWRTZeroR(Classifier classifier,
 Evaluation evaluation, Instances train, Instances test) throws Exception {
 boolean[] result = new boolean[2];
 evaluation.evaluateModel(classifier, test);
 try {
  // Tested OK, compare with ZeroR
  Classifier zeroR = new weka.classifiers.rules.ZeroR();
  zeroR.buildClassifier(train);
  Evaluation zeroREval = new Evaluation(train);
  zeroREval.evaluateModel(zeroR, test);
  result[0] = Utils.grOrEq(zeroREval.errorRate(), evaluation.errorRate());
 } catch (Exception ex) {
  throw new Error("Problem determining ZeroR performance: "
   + ex.getMessage());
 }
 return result;
}
origin: nz.ac.waikato.cms.weka/weka-stable

/**
 * Determine whether the scheme performs worse than ZeroR during testing
 * 
 * @param classifier the pre-trained classifier
 * @param evaluation the classifier evaluation object
 * @param train the training data
 * @param test the test data
 * @return index 0 is true if the scheme performs better than ZeroR
 * @throws Exception if there was a problem during the scheme's testing
 */
protected boolean[] testWRTZeroR(Classifier classifier,
 Evaluation evaluation, Instances train, Instances test) throws Exception {
 boolean[] result = new boolean[2];
 evaluation.evaluateModel(classifier, test);
 try {
  // Tested OK, compare with ZeroR
  Classifier zeroR = new weka.classifiers.rules.ZeroR();
  zeroR.buildClassifier(train);
  Evaluation zeroREval = new Evaluation(train);
  zeroREval.evaluateModel(zeroR, test);
  result[0] = Utils.grOrEq(zeroREval.errorRate(), evaluation.errorRate());
 } catch (Exception ex) {
  throw new Error("Problem determining ZeroR performance: "
   + ex.getMessage());
 }
 return result;
}
origin: sc.fiji/Trainable_Segmentation

/**
 * Get training error (from loaded data).
 *
 * @param verbose option to display evaluation information in the log window
 * @return classifier error on the training data set.
 */
public double getTrainingError(boolean verbose)
{
  if(null == this.trainHeader)
    return -1;
  double error = -1;
  try {
    final Evaluation evaluation = new Evaluation(this.loadedTrainingData);
    evaluation.evaluateModel(classifier, this.loadedTrainingData);
    if(verbose)
      IJ.log(evaluation.toSummaryString("\n=== Training set evaluation ===\n", false));
    error = evaluation.errorRate();
  } catch (Exception e) {
    e.printStackTrace();
  }
  return error;
}
origin: fiji/Trainable_Segmentation

/**
 * Get training error (from loaded data).
 *
 * @param verbose option to display evaluation information in the log window
 * @return classifier error on the training data set.
 */
public double getTrainingError(boolean verbose)
{
  if(null == this.trainHeader)
    return -1;
  double error = -1;
  try {
    final Evaluation evaluation = new Evaluation(this.loadedTrainingData);
    evaluation.evaluateModel(classifier, this.loadedTrainingData);
    if(verbose)
      IJ.log(evaluation.toSummaryString("\n=== Training set evaluation ===\n", false));
    error = evaluation.errorRate();
  } catch (Exception e) {
    e.printStackTrace();
  }
  return error;
}
origin: org.dkpro.similarity/dkpro-similarity-algorithms-ml-gpl

eval.evaluateModel(filteredClassifier, test);
origin: Waikato/wekaDeeplearning4j

public static void evaluate(Dl4jMlpClassifier clf, Instances data, double minPerfomance)
  throws Exception {
 Instances[] split = TestUtil.splitTrainTest(data);
 Instances train = split[0];
 Instances test = split[1];
 clf.buildClassifier(train);
 Evaluation trainEval = new Evaluation(train);
 trainEval.evaluateModel(clf, train);
 Evaluation testEval = new Evaluation(train);
 testEval.evaluateModel(clf, test);
 final double testPctCorrect = testEval.pctCorrect();
 final double trainPctCorrect = trainEval.pctCorrect();
 log.info("Train: {}, Test: {}", trainPctCorrect, testPctCorrect);
 boolean success = testPctCorrect > minPerfomance && trainPctCorrect > minPerfomance;
 log.info("Success: " + success);
 log.info(clf.getModel().conf().toYaml());
 Assert.assertTrue("Performance was < " + minPerfomance + ". TestPctCorrect: " + testPctCorrect +", TrainPctCorrect: " + trainPctCorrect, success);
}
origin: nz.ac.waikato.cms.weka/weka-stable

/**
 * Traverses the tree and installs linear models at each node. This method
 * must be called if pruning is not to be performed.
 * 
 * @throws Exception if an error occurs
 */
public void installLinearModels() throws Exception {
 Evaluation nodeModelEval;
 if (m_isLeaf) {
  buildLinearModel(m_indices);
 } else {
  if (m_left != null) {
   m_left.installLinearModels();
  }
  if (m_right != null) {
   m_right.installLinearModels();
  }
  buildLinearModel(m_indices);
 }
 nodeModelEval = new Evaluation(m_instances);
 nodeModelEval.evaluateModel(m_nodeModel, m_instances);
 m_rootMeanSquaredError = nodeModelEval.rootMeanSquaredError();
 // save space
 if (!m_saveInstances) {
  m_instances = new Instances(m_instances, 0);
 }
}
origin: Waikato/weka-trunk

/**
 * Traverses the tree and installs linear models at each node. This method
 * must be called if pruning is not to be performed.
 * 
 * @throws Exception if an error occurs
 */
public void installLinearModels() throws Exception {
 Evaluation nodeModelEval;
 if (m_isLeaf) {
  buildLinearModel(m_indices);
 } else {
  if (m_left != null) {
   m_left.installLinearModels();
  }
  if (m_right != null) {
   m_right.installLinearModels();
  }
  buildLinearModel(m_indices);
 }
 nodeModelEval = new Evaluation(m_instances);
 nodeModelEval.evaluateModel(m_nodeModel, m_instances);
 m_rootMeanSquaredError = nodeModelEval.rootMeanSquaredError();
 // save space
 if (!m_saveInstances) {
  m_instances = new Instances(m_instances, 0);
 }
}
origin: Waikato/wekaDeeplearning4j

 private static Evaluation eval(Instances metaData)
   throws Exception {

  String imagesPath = "src/test/resources/nominal/mnist-minimal";
  Dl4jMlpClassifier clf = new Dl4jMlpClassifier();
  ImageInstanceIterator iii = new ImageInstanceIterator();
  iii.setImagesLocation(new File(imagesPath));
  iii.setTrainBatchSize(2);

  clf.setInstanceIterator(iii);
  clf.setNumEpochs(5);

  // Build clf
  clf.buildClassifier(metaData);

  // Evaluate clf
  Evaluation trainEval = new Evaluation(metaData);
  trainEval.evaluateModel(clf, metaData);
  return trainEval;
 }
}
weka.classifiersEvaluationevaluateModel

Javadoc

Evaluates a classifier with the options given in an array of strings.

Valid options are:

-t filename
Name of the file with the training data. (required)

-T filename
Name of the file with the test data. If missing a cross-validation is performed.

-c index
Index of the class attribute (1, 2, ...; default: last).

-x number
The number of folds for the cross-validation (default: 10).

-no-cv
No cross validation. If no test file is provided, no evaluation is done.

-split-percentage percentage
Sets the percentage for the train/test set split, e.g., 66.

-preserve-order
Preserves the order in the percentage split instead of randomizing the data first with the seed value ('-s').

-s seed
Random number seed for the cross-validation and percentage split (default: 1).

-m filename
The name of a file containing a cost matrix.

-l filename
Loads classifier from the given file. In case the filename ends with ".xml",a PMML file is loaded or, if that fails, options are loaded from XML.

-d filename
Saves classifier built from the training data into the given file. In case the filename ends with ".xml" the options are saved XML, not the model.

-v
Outputs no statistics for the training data.

-o
Outputs statistics only, not the classifier.

-i
Outputs detailed information-retrieval statistics per class.

-k
Outputs information-theoretic statistics.

-classifications "weka.classifiers.evaluation.output.prediction.AbstractOutput + options"
Uses the specified class for generating the classification output. E.g.: weka.classifiers.evaluation.output.prediction.PlainText or : weka.classifiers.evaluation.output.prediction.CSV -p range
Outputs predictions for test instances (or the train instances if no test instances provided and -no-cv is used), along with the attributes in the specified range (and nothing else). Use '-p 0' if no attributes are desired.

Deprecated: use "-classifications ..." instead.

-distribution
Outputs the distribution instead of only the prediction in conjunction with the '-p' option (only nominal classes).

Deprecated: use "-classifications ..." instead.

-no-predictions
Turns off the collection of predictions in order to conserve memory.

-r
Outputs cumulative margin distribution (and nothing else).

-g
Only for classifiers that implement "Graphable." Outputs the graph representation of the classifier (and nothing else).

-xml filename | xml-string
Retrieves the options from the XML-data instead of the command line.

-threshold-file file
The file to save the threshold data to. The format is determined by the extensions, e.g., '.arff' for ARFF format or '.csv' for CSV.

-threshold-label label
The class label to determine the threshold data for (default is the first label)

Popular methods of Evaluation

  • <init>
  • toSummaryString
    Calls toSummaryString() with a default title.
  • crossValidateModel
    Performs a (stratified if class is nominal) cross-validation for a classifier on a set of instances.
  • pctCorrect
    Gets the percentage of instances correctly classified (that is, for which a correct prediction was m
  • toMatrixString
    Outputs the performance statistics as a classification confusion matrix. For each class value, shows
  • toClassDetailsString
    Generates a breakdown of the accuracy for each class, incorporating various information-retrieval st
  • weightedFMeasure
    Calculates the macro weighted (by class size) average F-Measure.
  • weightedPrecision
    Calculates the weighted (by class size) precision.
  • weightedRecall
    Calculates the weighted (by class size) recall.
  • areaUnderROC
    Returns the area under ROC for those predictions that have been collected in the evaluateClassifier(
  • correct
    Gets the number of instances correctly classified (that is, for which a correct prediction was made)
  • correlationCoefficient
    Returns the correlation coefficient if the class is numeric.
  • correct,
  • correlationCoefficient,
  • fMeasure,
  • incorrect,
  • meanAbsoluteError,
  • pctIncorrect,
  • precision,
  • recall,
  • relativeAbsoluteError

Popular in Java

  • Reading from database using SQL prepared statement
  • setScale (BigDecimal)
  • scheduleAtFixedRate (ScheduledExecutorService)
    Creates and executes a periodic action that becomes enabled first after the given initial delay, and
  • onCreateOptionsMenu (Activity)
  • InetAddress (java.net)
    This class represents an Internet Protocol (IP) address. An IP address is either a 32-bit or 128-bit
  • Connection (java.sql)
    A connection represents a link from a Java application to a database. All SQL statements and results
  • Date (java.sql)
    A class which can consume and produce dates in SQL Date format. Dates are represented in SQL as yyyy
  • ResultSet (java.sql)
    An interface for an object which represents a database table entry, returned as the result of the qu
  • Annotation (javassist.bytecode.annotation)
    The annotation structure.An instance of this class is returned bygetAnnotations() in AnnotationsAttr
  • DataSource (javax.sql)
    A factory for connections to the physical data source that this DataSource object represents. An alt
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now