Class StoppableEvaluation

  • All Implemented Interfaces:
    Stoppable, StoppableWithFeedback, Serializable, weka.core.RevisionHandler, weka.core.Summarizable

    public class StoppableEvaluation
    extends weka.classifiers.evaluation.Evaluation
    implements StoppableWithFeedback
    Extended Evaluation class that can stop its evaluation processes better.
    Author:
    fracpete (fracpete at waikato dot ac dot nz)
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected weka.classifiers.Classifier m_CurrentClassifier
      the current classifier that is being evaluated.
      protected boolean m_Stopped
      whether the execution was stopped.
      • Fields inherited from class weka.classifiers.evaluation.Evaluation

        BUILT_IN_EVAL_METRICS, k_MarginResolution, m_ClassIsNominal, m_ClassNames, m_ClassPriors, m_ClassPriorsSum, m_ComplexityStatisticsAvailable, m_ConfLevel, m_ConfusionMatrix, m_Correct, m_CostMatrix, m_CoverageStatisticsAvailable, m_DiscardPredictions, m_Header, m_Incorrect, m_MarginCounts, m_MaxTarget, m_metricsToDisplay, m_MinTarget, m_MissingClass, m_NoPriors, m_NumClasses, m_NumFolds, m_NumTrainClassVals, m_pluginMetrics, m_Predictions, m_PriorEstimator, m_SumAbsErr, m_SumClass, m_SumClassPredicted, m_SumErr, m_SumKBInfo, m_SumPredicted, m_SumPriorAbsErr, m_SumPriorEntropy, m_SumPriorSqrErr, m_SumSchemeEntropy, m_SumSqrClass, m_SumSqrErr, m_SumSqrPredicted, m_TotalCost, m_TotalCoverage, m_TotalSizeOfRegions, m_TrainClassVals, m_TrainClassWeights, m_Unclassified, m_WithClass, MIN_SF_PROB
    • Constructor Summary

      Constructors 
      Constructor Description
      StoppableEvaluation​(weka.core.Instances data)
      Initializes all the counters for the evaluation.
      StoppableEvaluation​(weka.core.Instances data, weka.classifiers.CostMatrix costMatrix)
      Initializes all the counters for the evaluation and also takes a cost matrix as parameter.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void crossValidateModel​(weka.classifiers.Classifier classifier, weka.core.Instances data, int numFolds, Random random, Object... forPredictionsPrinting)
      Performs a (stratified if class is nominal) cross-validation for a classifier on a set of instances.
      double[] evaluateModel​(weka.classifiers.Classifier classifier, weka.core.Instances data, Object... forPredictionsPrinting)
      Evaluates the classifier on a given set of instances.
      boolean isStopped()
      Whether the execution has been stopped.
      void stopExecution()
      Stops the execution.
      • Methods inherited from class weka.classifiers.evaluation.Evaluation

        addNumericTrainClass, areaUnderPRC, areaUnderROC, avgCost, confusionMatrix, correct, correlationCoefficient, coverageOfTestCasesByPredictedRegions, crossValidateModel, crossValidateModel, equals, errorRate, evaluateModel, evaluateModel, evaluateModelOnce, evaluateModelOnce, evaluateModelOnce, evaluateModelOnceAndRecordPrediction, evaluateModelOnceAndRecordPrediction, evaluationForSingleInstance, evaluationForSingleInstance, falseNegativeRate, falseNegativeRate, falsePositiveRate, falsePositiveRate, fMeasure, fMeasure, getAllEvaluationMetricNames, getClassPriors, getDiscardPredictions, getGlobalInfo, getHeader, getMetricsToDisplay, getModelFromFile, getPluginMetric, getPluginMetrics, getRevision, handleCostOption, incorrect, kappa, KBInformation, KBMeanInformation, KBRelativeInformation, main, makeDistribution, makeOptionString, matthewsCorrelationCoefficient, matthewsCorrelationCoefficient, meanAbsoluteError, meanPriorAbsoluteError, missingClass, num2ShortID, numClassified, numFalseNegatives, numFalsePositives, numInstances, numNegatives, numPositives, numPredictedNegatives, numPredictedPositives, numTrueNegatives, numTruePositives, pctCorrect, pctIncorrect, pctUnclassified, precision, predictedClassCounts, predictions, priorEntropy, recall, relativeAbsoluteError, rootMeanPriorSquaredError, rootMeanSquaredError, rootRelativeSquaredError, saveClassifier, setDiscardPredictions, setMetricsToDisplay, setNumericPriorsFromBuffer, setPriors, SFEntropyGain, SFMeanEntropyGain, SFMeanPriorEntropy, SFMeanSchemeEntropy, SFPriorEntropy, SFSchemeEntropy, sizeOfPredictedRegions, toClassDetailsString, toClassDetailsString, toCumulativeMarginDistributionString, toggleEvalMetrics, toMatrixString, toMatrixString, toSummaryString, toSummaryString, toSummaryString, totalCost, trueClassCounts, trueNegativeRate, trueNegativeRate, truePositiveRate, truePositiveRate, unclassified, unweightedMacroFmeasure, unweightedMicroFmeasure, updateMargins, updateNumericScores, updatePriors, updateStatsForClassifier, updateStatsForConditionalDensityEstimator, updateStatsForIntervalEstimator, updateStatsForPredictor, useNoPriors, weightedAreaUnderPRC, weightedAreaUnderROC, weightedFalseNegativeRate, weightedFalsePositiveRate, weightedFMeasure, weightedMatthewsCorrelation, weightedPrecision, weightedRecall, weightedTrueNegativeRate, weightedTruePositiveRate, wekaStaticWrapper, withClass
    • Field Detail

      • m_Stopped

        protected boolean m_Stopped
        whether the execution was stopped.
      • m_CurrentClassifier

        protected transient weka.classifiers.Classifier m_CurrentClassifier
        the current classifier that is being evaluated.
    • Constructor Detail

      • StoppableEvaluation

        public StoppableEvaluation​(weka.core.Instances data)
                            throws Exception
        Initializes all the counters for the evaluation. Use useNoPriors() if the dataset is the test set and you can't initialize with the priors from the training set via setPriors(Instances).
        Parameters:
        data - set of training instances, to get some header information and prior class distribution information
        Throws:
        Exception - if the class is not defined
        See Also:
        Evaluation.useNoPriors(), Evaluation.setPriors(Instances)
      • StoppableEvaluation

        public StoppableEvaluation​(weka.core.Instances data,
                                   weka.classifiers.CostMatrix costMatrix)
                            throws Exception
        Initializes all the counters for the evaluation and also takes a cost matrix as parameter. Use useNoPriors() if the dataset is the test set and you can't initialize with the priors from the training set via setPriors(Instances).
        Parameters:
        data - set of training instances, to get some header information and prior class distribution information
        costMatrix - the cost matrix---if null, default costs will be used
        Throws:
        Exception - if cost matrix is not compatible with data, the class is not defined or the class is numeric
        See Also:
        Evaluation.useNoPriors(), Evaluation.setPriors(Instances)
    • Method Detail

      • evaluateModel

        public double[] evaluateModel​(weka.classifiers.Classifier classifier,
                                      weka.core.Instances data,
                                      Object... forPredictionsPrinting)
                               throws Exception
        Evaluates the classifier on a given set of instances. Note that the data must have exactly the same format (e.g. order of attributes) as the data used to train the classifier! Otherwise the results will generally be meaningless.
        Overrides:
        evaluateModel in class weka.classifiers.evaluation.Evaluation
        Parameters:
        classifier - machine learning classifier
        data - set of test instances for evaluation
        forPredictionsPrinting - varargs parameter that, if supplied, is expected to hold a weka.classifiers.evaluation.output.prediction.AbstractOutput object
        Returns:
        the predictions
        Throws:
        Exception - if model could not be evaluated successfully
      • crossValidateModel

        public void crossValidateModel​(weka.classifiers.Classifier classifier,
                                       weka.core.Instances data,
                                       int numFolds,
                                       Random random,
                                       Object... forPredictionsPrinting)
                                throws Exception
        Performs a (stratified if class is nominal) cross-validation for a classifier on a set of instances. Now performs a deep copy of the classifier before each call to buildClassifier() (just in case the classifier is not initialized properly).
        Overrides:
        crossValidateModel in class weka.classifiers.evaluation.Evaluation
        Parameters:
        classifier - the classifier with any options set.
        data - the data on which the cross-validation is to be performed
        numFolds - the number of folds for the cross-validation
        random - random number generator for randomization
        forPredictionsPrinting - varargs parameter that, if supplied, is expected to hold a weka.classifiers.evaluation.output.prediction.AbstractOutput object
        Throws:
        Exception - if a classifier could not be generated successfully or the class is not defined
      • stopExecution

        public void stopExecution()
        Stops the execution. No message set.
        Specified by:
        stopExecution in interface Stoppable
      • isStopped

        public boolean isStopped()
        Whether the execution has been stopped.
        Specified by:
        isStopped in interface StoppableWithFeedback
        Returns:
        true if stopped