/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* Evaluation.java
* Copyright (C) 1999 Eibe Frank,Len Trigg
*
*/
package weka.classifiers;
import java.util.*;
import java.io.*;
import weka.core.*;
import weka.estimators.*;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
/**
* Class for evaluating machine learning models. <p/>
*
* ------------------------------------------------------------------- <p/>
*
* General options when evaluating a learning scheme from the command-line: <p/>
*
* -t filename <br/>
* Name of the file with the training data. (required) <p/>
*
* -T filename <br/>
* Name of the file with the test data. If missing a cross-validation
* is performed. <p/>
*
* -c index <br/>
* Index of the class attribute (1, 2, ...; default: last). <p/>
*
* -x number <br/>
* The number of folds for the cross-validation (default: 10). <p/>
*
* -s seed <br/>
* Random number seed for the cross-validation (default: 1). <p/>
*
* -m filename <br/>
* The name of a file containing a cost matrix. <p/>
*
* -l filename <br/>
* Loads classifier from the given file. <p/>
*
* -d filename <br/>
* Saves classifier built from the training data into the given file. <p/>
*
* -v <br/>
* Outputs no statistics for the training data. <p/>
*
* -o <br/>
* Outputs statistics only, not the classifier. <p/>
*
* -i <br/>
* Outputs information-retrieval statistics per class. <p/>
*
* -k <br/>
* Outputs information-theoretic statistics. <p/>
*
* -p range <br/>
* Outputs predictions for test instances, along with the attributes in
* the specified range (and nothing else). Use '-p 0' if no attributes are
* desired. <p/>
*
* -r <br/>
* Outputs cumulative margin distribution (and nothing else). <p/>
*
* -g <br/>
* Only for classifiers that implement "Graphable." Outputs
* the graph representation of the classifier (and nothing
* else). <p/>
*
* ------------------------------------------------------------------- <p/>
*
* Example usage as the main of a classifier (called FunkyClassifier):
* <code> <pre>
* public static void main(String [] args) {
* try {
* Classifier scheme = new FunkyClassifier();
* System.out.println(Evaluation.evaluateModel(scheme, args));
* } catch (Exception e) {
* System.err.println(e.getMessage());
* }
* }
* </pre> </code>
* <p/>
*
* ------------------------------------------------------------------ <p/>
*
* Example usage from within an application:
* <code> <pre>
* Instances trainInstances = ... instances got from somewhere
* Instances testInstances = ... instances got from somewhere
* Classifier scheme = ... scheme got from somewhere
*
* Evaluation evaluation = new Evaluation(trainInstances);
* evaluation.evaluateModel(scheme, testInstances);
* System.out.println(evaluation.toSummaryString());
* </pre> </code>
*
*
* @author Eibe Frank (eibe@cs.waikato.ac.nz)
* @author Len Trigg (trigg@cs.waikato.ac.nz)
* @version $Revision: 1.53.2.6 $
*/
public class Evaluation implements Summarizable {
/** The number of classes. */
protected int m_NumClasses;
/** The number of folds for a cross-validation. */
protected int m_NumFolds;
/** The weight of all incorrectly classified instances. */
protected double m_Incorrect;
/** The weight of all correctly classified instances. */
protected double m_Correct;
/** The weight of all unclassified instances. */
protected double m_Unclassified;
/*** The weight of all instances that had no class assigned to them. */
protected double m_MissingClass;
/** The weight of all instances that had a class assigned to them. */
protected double m_WithClass;
/** Array for storing the confusion matrix. */
protected double [][] m_ConfusionMatrix;
/** The names of the classes. */
protected String [] m_ClassNames;
/** Is the class nominal or numeric? */
protected boolean m_ClassIsNominal;
/** The prior probabilities of the classes */
protected double [] m_ClassPriors;
/** The sum of counts for priors */
protected double m_ClassPriorsSum;
/** The cost matrix (if given). */
protected CostMatrix m_CostMatrix;
/** The total cost of predictions (includes instance weights) */
protected double m_TotalCost;
/** Sum of errors. */
protected double m_SumErr;
/** Sum of absolute errors. */
protected double m_SumAbsErr;
/** Sum of squared errors. */
protected double m_SumSqrErr;
/** Sum of class values. */
protected double m_SumClass;
/** Sum of squared class values. */
protected double m_SumSqrClass;
/*** Sum of predicted values. */
protected double m_SumPredicted;
/** Sum of squared predicted values. */
protected double m_SumSqrPredicted;
/** Sum of predicted * class values. */
protected double m_SumClassPredicted;
/** Sum of absolute errors of the prior */
protected double m_SumPriorAbsErr;
/** Sum of absolute errors of the prior */
protected double m_SumPriorSqrErr;
/** Total Kononenko & Bratko Information */
protected double m_SumKBInfo;
/*** Resolution of the margin histogram */
protected static int k_MarginResolution = 500;
/** Cumulative margin distribution */
protected double m_MarginCounts [];
/** Number of non-missing class training instances seen */
protected int m_NumTrainClassVals;
/** Array containing all numeric training class values seen */
protected double [] m_TrainClassVals;
/** Array containing all numeric training class weights */
protected double [] m_TrainClassWeights;
/** Numeric class error estimator for prior */
protected Estimator m_PriorErrorEstimator;
/** Numeric class error estimator for scheme */
protected Estimator m_ErrorEstimator;
/**
* The minimum probablility accepted from an estimator to avoid
* taking log(0) in Sf calculations.
*/
protected static final double MIN_SF_PROB = Double.MIN_VALUE;
/** Total entropy of prior predictions */
protected double m_SumPriorEntropy;
/** Total entropy of scheme predictions */
protected double m_SumSchemeEntropy;
/** enables/disables the use of priors, e.g., if no training set is
* present in case of de-serialized schemes */
protected boolean m_NoPriors = false;
/**
* Initializes all the counters for the evaluation.
* Use <code>useNoPriors()</code> if the dataset is the test set and you
* can't initialize with the priors from the training set via
* <code>setPriors(Instances)</code>.
*
* @param data set of training instances, to get some header
* information and prior class distribution information
* @throws Exception if the class is not defined
* @see #useNoPriors()
* @see #setPriors(Instances)
*/
public Evaluation(Instances data) throws Exception {
this(data, null);
}
/**
* Initializes all the counters for the evaluation and also takes a
* cost matrix as parameter.
* Use <code>useNoPriors()</code> if the dataset is the test set and you
* can't initialize with the priors from the training set via
* <code>setPriors(Instances)</code>.
*
* @param data set of training instances, to get some header
* information and prior class distribution information
* @param costMa
没有合适的资源?快使用搜索试试~ 我知道了~
weka-src.rar_weka
共1189个文件
java:816个
gif:347个
props:7个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 171 浏览量
2022-09-21
07:51:35
上传
评论
收藏 3.34MB RAR 举报
温馨提示
weka包含有大量数据挖掘的算法,是学习数据挖掘的最佳助手
资源详情
资源评论
资源推荐
收起资源包目录
weka-src.rar_weka (1189个子文件)
FilterTest.arff 1KB
ClassifierTest.arff 864B
ClassifierTest.cost 55B
weka3.gif 30KB
DefaultClassifier_animated.gif 3KB
DefaultClassifier.gif 3KB
PaceRegression.gif 3KB
PaceRegression_animated.gif 3KB
SMO_animated.gif 3KB
SMO.gif 3KB
SimpleLinearRegression_animated.gif 3KB
SimpleLinearRegression.gif 3KB
SimpleLogistic_animated.gif 3KB
SimpleLogistic.gif 3KB
LinearRegression.gif 3KB
LinearRegression_animated.gif 3KB
ClassificationViaRegression.gif 3KB
ClassificationViaRegression_animated.gif 3KB
filters.unsupervised.attribute.NumericToBinary_animated.gif 3KB
LeastMedSq.gif 3KB
LeastMedSq_animated.gif 3KB
filters.unsupervised.attribute.NumericToBinary.gif 3KB
SMOreg.gif 3KB
filters.unsupervised.attribute.StringToNominal.gif 3KB
filters.unsupervised.attribute.StringToNominal_animated.gif 3KB
RegressionByDiscretization.gif 3KB
RegressionByDiscretization_animated.gif 3KB
SMOreg_animated.gif 3KB
Default_miscClassifier_animated.gif 3KB
Default_miscClassifier.gif 3KB
filters.unsupervised.instance.Normalize.gif 3KB
filters.unsupervised.instance.Normalize_animated.gif 3KB
IncrementalClassifierEvaluator.gif 3KB
IncrementalClassifierEvaluator_animated.gif 3KB
NaiveBayes.gif 3KB
NaiveBayes_animated.gif 3KB
ComplementNaiveBayes.gif 3KB
ComplementNaiveBayes_animated.gif 3KB
filters.supervised.instance.Resample_animated.gif 3KB
RandomCommittee_animated.gif 3KB
RandomCommittee.gif 3KB
filters.supervised.instance.Resample.gif 3KB
RandomForest_animated.gif 3KB
filters.unsupervised.attribute.AddNoise_animated.gif 3KB
RandomForest.gif 3KB
filters.unsupervised.attribute.AddNoise.gif 3KB
Logistic_animated.gif 3KB
Logistic.gif 3KB
CVParameterSelection.gif 3KB
CVParameterSelection_animated.gif 3KB
filters.unsupervised.attribute.Normalize_animated.gif 3KB
filters.unsupervised.attribute.RemoveType.gif 3KB
filters.unsupervised.attribute.RemoveType_animated.gif 3KB
filters.unsupervised.attribute.Normalize.gif 3KB
ThresholdSelector.gif 3KB
ThresholdSelector_animated.gif 3KB
filters.unsupervised.attribute.FirstOrder_animated.gif 3KB
filters.unsupervised.attribute.AddExpression_animated.gif 3KB
Default_lazyClassifier.gif 3KB
filters.unsupervised.attribute.AddExpression.gif 3KB
Default_lazyClassifier_animated.gif 3KB
filters.unsupervised.attribute.FirstOrder.gif 3KB
MultilayerPerceptron.gif 3KB
MultilayerPerceptron_animated.gif 3KB
LogitBoost_animated.gif 3KB
AdditiveRegression.gif 3KB
LogitBoost.gif 3KB
DecisionStump_animated.gif 3KB
filters.unsupervised.attribute.Standardize_animated.gif 3KB
AdditiveRegression_animated.gif 3KB
filters.unsupervised.attribute.Standardize.gif 3KB
DecisionStump.gif 3KB
NaiveBayesMultinomial.gif 3KB
NaiveBayesMultinomial_animated.gif 3KB
NaiveBayesSimple_animated.gif 3KB
NaiveBayesSimple.gif 3KB
filters.unsupervised.attribute.ReplaceMissingValues.gif 3KB
filters.unsupervised.attribute.ReplaceMissingValues_animated.gif 3KB
filters.unsupervised.attribute.MakeIndicator.gif 3KB
filters.unsupervised.attribute.TimeSeriesTranslate.gif 3KB
filters.unsupervised.attribute.TimeSeriesDelta_animated.gif 3KB
filters.unsupervised.attribute.TimeSeriesDelta.gif 3KB
LBR_animated.gif 3KB
LBR.gif 3KB
filters.unsupervised.attribute.TimeSeriesTranslate_animated.gif 3KB
filters.unsupervised.attribute.MakeIndicator_animated.gif 3KB
filters.unsupervised.attribute.StringToWordVector_animated.gif 3KB
DefaultText_animated.gif 3KB
filters.unsupervised.attribute.StringToWordVector.gif 3KB
DefaultText.gif 3KB
DefaultAssociator_animated.gif 3KB
DefaultAssociator.gif 3KB
Default_bayesClassifier_animated.gif 3KB
filters.unsupervised.attribute.Discretize.gif 3KB
filters.unsupervised.attribute.Discretize_animated.gif 3KB
Default_bayesClassifier.gif 3KB
AdaBoostM1.gif 3KB
AdaBoostM1_animated.gif 3KB
filters.unsupervised.attribute.NumericTransform.gif 3KB
filters.unsupervised.attribute.NumericTransform_animated.gif 3KB
共 1189 条
- 1
- 2
- 3
- 4
- 5
- 6
- 12
钱亚锋
- 粉丝: 86
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0