Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
The Waikato Environment for Knowledge Analysis (WEKA), a machine
learning workbench. This version represents the developer version, the
"bleeding edge" of development, you could say. New functionality gets added
to this version.
/*
* 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 3 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, see .
*/
/*
* CostSensitiveClassifier.java
* Copyright (C) 2002-2012 University of Waikato, Hamilton, New Zealand
*
*/
package weka.classifiers.meta;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.StringReader;
import java.io.StringWriter;
import java.util.Collections;
import java.util.Enumeration;
import java.util.Random;
import java.util.Vector;
import weka.classifiers.Classifier;
import weka.classifiers.CostMatrix;
import weka.classifiers.RandomizableSingleClassifierEnhancer;
import weka.core.*;
import weka.core.Capabilities.Capability;
/**
* A metaclassifier that makes its base classifier cost-sensitive. Two methods can be used to introduce cost-sensitivity: reweighting training instances according to the total cost assigned to each class; or predicting the class with minimum expected misclassification cost (rather than the most likely class). Performance can often be improved by using a Bagged classifier to improve the probability estimates of the base classifier.
*
*
* Valid options are:
*
*
-M
* Minimize expected misclassification cost. Default is to
* reweight training instances according to costs per class
*
*
-C <cost file name>
* File name of a cost matrix to use. If this is not supplied,
* a cost matrix will be loaded on demand. The name of the
* on-demand file is the relation name of the training data
* plus ".cost", and the path to the on-demand file is
* specified with the -N option.
*
*
-N <directory>
* Name of a directory to search for cost files when loading
* costs on demand (default current directory).
*
*
-cost-matrix <matrix>
* The cost matrix in Matlab single line format.
*
*
-S <num>
* Random number seed.
* (default 1)
*
*
-D
* If set, classifier is run in debug mode and
* may output additional info to the console
*
*
-W
* Full name of base classifier.
* (default: weka.classifiers.rules.ZeroR)
*
*
* Options specific to classifier weka.classifiers.rules.ZeroR:
*
*
*
-D
* If set, classifier is run in debug mode and
* may output additional info to the console
*
*
* Options after -- are passed to the designated classifier.
*
* @author Len Trigg ([email protected])
* @version $Revision: 14258 $
*/
public class CostSensitiveClassifier
extends RandomizableSingleClassifierEnhancer
implements OptionHandler, Drawable, BatchPredictor {
/** for serialization */
static final long serialVersionUID = -110658209263002404L;
/** load cost matrix on demand */
public static final int MATRIX_ON_DEMAND = 1;
/** use explicit cost matrix */
public static final int MATRIX_SUPPLIED = 2;
/** Specify possible sources of the cost matrix */
public static final Tag [] TAGS_MATRIX_SOURCE = {
new Tag(MATRIX_ON_DEMAND, "Load cost matrix on demand"),
new Tag(MATRIX_SUPPLIED, "Use explicit cost matrix")
};
/** Indicates the current cost matrix source */
protected int m_MatrixSource = MATRIX_ON_DEMAND;
/**
* The directory used when loading cost files on demand, null indicates
* current directory
*/
protected File m_OnDemandDirectory = new File(System.getProperty("user.dir"));
/** The name of the cost file, for command line options */
protected String m_CostFile;
/** The cost matrix */
protected CostMatrix m_CostMatrix = new CostMatrix(1);
/**
* True if the costs should be used by selecting the minimum expected
* cost (false means weight training data by the costs)
*/
protected boolean m_MinimizeExpectedCost;
/**
* String describing default classifier.
*
* @return the default classifier classname
*/
protected String defaultClassifierString() {
return "weka.classifiers.rules.ZeroR";
}
/**
* Default constructor.
*/
public CostSensitiveClassifier() {
m_Classifier = new weka.classifiers.rules.ZeroR();
}
/**
* Returns an enumeration describing the available options.
*
* @return an enumeration of all the available options.
*/
public Enumeration