Package weka.classifiers.evaluation
Class StoppableEvaluation
- java.lang.Object
-
- weka.classifiers.evaluation.Evaluation
-
- weka.classifiers.evaluation.StoppableEvaluation
-
- All Implemented Interfaces:
adams.core.Stoppable
,adams.core.StoppableWithFeedback
,Serializable
,weka.core.RevisionHandler
,weka.core.Summarizable
public class StoppableEvaluation extends weka.classifiers.evaluation.Evaluation implements adams.core.StoppableWithFeedback
Specializes 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 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, equals, errorRate, evaluateModel, evaluateModel, evaluateModelOnce, evaluateModelOnce, evaluateModelOnce, evaluateModelOnceAndRecordPrediction, evaluateModelOnceAndRecordPrediction, evaluationForSingleInstance, evaluationForSingleInstance, falseNegativeRate, falsePositiveRate, fMeasure, getAllEvaluationMetricNames, getClassPriors, getDiscardPredictions, getGlobalInfo, getHeader, getMetricsToDisplay, getPluginMetric, getPluginMetrics, getRevision, handleCostOption, incorrect, kappa, KBInformation, KBMeanInformation, KBRelativeInformation, main, makeDistribution, makeOptionString, matthewsCorrelationCoefficient, meanAbsoluteError, meanPriorAbsoluteError, num2ShortID, numFalseNegatives, numFalsePositives, numInstances, numTrueNegatives, numTruePositives, pctCorrect, pctIncorrect, pctUnclassified, precision, predictions, priorEntropy, recall, relativeAbsoluteError, rootMeanPriorSquaredError, rootMeanSquaredError, rootRelativeSquaredError, setDiscardPredictions, setMetricsToDisplay, setNumericPriorsFromBuffer, setPriors, SFEntropyGain, SFMeanEntropyGain, SFMeanPriorEntropy, SFMeanSchemeEntropy, SFPriorEntropy, SFSchemeEntropy, sizeOfPredictedRegions, toClassDetailsString, toClassDetailsString, toCumulativeMarginDistributionString, toggleEvalMetrics, toMatrixString, toMatrixString, toSummaryString, toSummaryString, toSummaryString, totalCost, trueNegativeRate, truePositiveRate, unclassified, unweightedMacroFmeasure, unweightedMicroFmeasure, updateMargins, updateNumericScores, updatePriors, updateStatsForClassifier, updateStatsForConditionalDensityEstimator, updateStatsForIntervalEstimator, updateStatsForPredictor, useNoPriors, weightedAreaUnderPRC, weightedAreaUnderROC, weightedFalseNegativeRate, weightedFalsePositiveRate, weightedFMeasure, weightedMatthewsCorrelation, weightedPrecision, weightedRecall, weightedTrueNegativeRate, weightedTruePositiveRate, wekaStaticWrapper
-
-
-
-
Constructor Detail
-
StoppableEvaluation
public StoppableEvaluation(weka.core.Instances data) throws Exception
Initializes all the counters for the evaluation. UseuseNoPriors()
if the dataset is the test set and you can't initialize with the priors from the training set viasetPriors(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. UseuseNoPriors()
if the dataset is the test set and you can't initialize with the priors from the training set viasetPriors(Instances)
.- Parameters:
data
- set of training instances, to get some header information and prior class distribution informationcostMatrix
- 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 classweka.classifiers.evaluation.Evaluation
- Parameters:
classifier
- machine learning classifierdata
- set of test instances for evaluationforPredictionsPrinting
- 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 classweka.classifiers.evaluation.Evaluation
- Parameters:
classifier
- the classifier with any options set.data
- the data on which the cross-validation is to be performednumFolds
- the number of folds for the cross-validationrandom
- random number generator for randomizationforPredictionsPrinting
- 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 interfaceadams.core.Stoppable
-
isStopped
public boolean isStopped()
Whether the execution has been stopped.- Specified by:
isStopped
in interfaceadams.core.StoppableWithFeedback
- Returns:
- true if stopped
-
-