Classifier cModel = (Classifier)new NaiveBayes(); cModel.buildClassifier(isTrainingSet); weka.core.SerializationHelper.write("/some/where/nBayes.model", cModel); Classifier cls = (Classifier) weka.core.SerializationHelper.read("/some/where/nBayes.model"); // Test the model Evaluation eTest = new Evaluation(isTrainingSet); eTest.evaluateModel(cls, isTrainingSet);
/** * Calls toSummaryString() with no title and no complexity stats. * * @return a summary description of the classifier evaluation */ @Override public String toSummaryString() { return toSummaryString("", false); }
/** * Evaluates the supplied distribution on a single instance. * * @param dist the supplied distribution * @param instance the test instance to be classified * @return the prediction * @throws Exception if model could not be evaluated successfully */ public double evaluateModelOnceAndRecordPrediction(double[] dist, Instance instance) throws Exception { return m_delegate.evaluateModelOnceAndRecordPrediction(dist, instance); }
/** * Returns the relative absolute error. * * @return the relative absolute error * @throws Exception if it can't be computed */ public final double relativeAbsoluteError() throws Exception { if (m_NoPriors) { return Double.NaN; } return 100 * meanAbsoluteError() / meanPriorAbsoluteError(); }
/** * Outputs the performance statistics as a classification confusion matrix. * For each class value, shows the distribution of predicted class values. * * @param title the title for the confusion matrix * @return the confusion matrix as a String * @throws Exception if the class is numeric */ public String toMatrixString(String title) throws Exception { return m_delegate.toMatrixString(title); }
/** * Gets the number of instances incorrectly classified (that is, for which an * incorrect prediction was made). (Actually the sum of the weights of these * instances) * * @return the number of incorrectly classified instances */ public final double incorrect() { return m_delegate.incorrect(); }
/** * Returns the mean absolute error. Refers to the error of the predicted * values for numeric classes, and the error of the predicted probability * distribution for nominal classes. * * @return the mean absolute error */ public final double meanAbsoluteError() { return m_delegate.meanAbsoluteError(); }
/** * Adds the statistics encapsulated in the supplied Evaluation object into * this one. Does not perform any checks for compatibility between the * supplied Evaluation object and this one. * * @param evaluation the evaluation object to aggregate */ public void aggregate(Evaluation evaluation) { ((weka.classifiers.evaluation.AggregateableEvaluation) m_delegate) .aggregate(evaluation.m_delegate); } }
/** * Calculates the weighted (by class size) recall. * * @return the weighted recall. */ public double weightedRecall() { return weightedTruePositiveRate(); }
/** * Toggle the output of the metrics specified in the supplied list. * * @param metricsToToggle a list of metrics to toggle */ public void toggleEvalMetrics(List<String> metricsToToggle) { m_delegate.toggleEvalMetrics(metricsToToggle); }
/** * Calculates the weighted (by class size) AUC. * * @return the weighted AUC. */ public double weightedAreaUnderROC() { return m_delegate.weightedAreaUnderROC(); }
/** * Gets the average cost, that is, total cost of misclassifications (incorrect * plus unclassified) over the total number of instances. * * @return the average cost. */ public final double avgCost() { return m_delegate.avgCost(); }
/** * Gets the number of instances not classified (that is, for which no * prediction was made by the classifier). (Actually the sum of the weights of * these instances) * * @return the number of unclassified instances */ public final double unclassified() { return m_delegate.unclassified(); }
/** * Calculate the entropy of the prior distribution. * * @return the entropy of the prior distribution * @throws Exception if the class is not nominal */ public final double priorEntropy() throws Exception { return m_delegate.priorEntropy(); }
/** * Return the Kononenko & Bratko Relative Information score. * * @return the K&B relative information score * @throws Exception if the class is not nominal */ public final double KBRelativeInformation() throws Exception { return m_delegate.KBRelativeInformation(); }
/** * Calculates the weighted (by class size) true negative rate. * * @return the weighted true negative rate. */ public double weightedTrueNegativeRate() { return m_delegate.weightedTrueNegativeRate(); }
/** * Calculates the weighted (by class size) precision. * * @return the weighted precision. */ public double weightedPrecision() { return m_delegate.weightedPrecision(); }
/** * disables the use of priors, e.g., in case of de-serialized schemes that * have no access to the original training set, but are evaluated on a set * set. */ public void useNoPriors() { m_delegate.useNoPriors(); }
/** * Calls toSummaryString() with a default title. * * @param printComplexityStatistics if true, complexity statistics are * returned as well * @return the summary string */ public String toSummaryString(boolean printComplexityStatistics) { return m_delegate.toSummaryString(printComplexityStatistics); }
/** * Calls toMatrixString() with a default title. * * @return the confusion matrix as a string * @throws Exception if the class is numeric */ public String toMatrixString() throws Exception { return m_delegate.toMatrixString(); }