coser.classifiers.trees
类 CostSensitiveDecisionTree

java.lang.Object
  继承者 Id3
      继承者 coser.classifiers.trees.CostSensitiveDecisionTree

public class CostSensitiveDecisionTree
extends Id3

构造一个代价敏感决策树。从Id3.java中复制并修改而来。
Summary: Build a decision tree for a cost sensitive decision system. Modified from Id3.java

Author: Fan Min minfanphd@163.com
For more information of the data model please refer to our papers:
\@ARTICLE{MinZhu2012Induction,
author = {Fan Min and William Zhu},
title = {Induction of cost-time-sensitive decision trees},
journal = {submitted to RSKT 2012},
year = {2012}
}

Copyright: The source code and all documents are open and free. PLEASE keep this header while revising the program.

Organization: Lab of Granular Computing, Zhangzhou Normal University, Fujian 363000, China.
Project: The cost-sensitive rough sets project.

Progress: Half done.
Written time: November 5, 2011.
Last modify time: January 28, 2011.


字段摘要
修饰符 和 类型 字段 和 描述
protected  double accuracy
          The accuracy after classification.
static int ALL_ALGORITHMS
          The weighted test cost algorithm.
protected  double averageCost
          The average cost after classfication.
protected  boolean balance
          Whether or not balance according to the misclassification matrix.
static int COST_GAIN
          The cost gain algorithm.
static int EXPONENTIAL_GAIN
          The power information gain algorithm.
protected  double maximalCostGain
          The maximal cost gain.
static int NO_PRUNE
          No prune.
static int POST_PRUNE
          Postprune.
static int PRE_PRUNE
          Preprune.
static long serialVersionUID
          For serialization
static int WEIGHTED_GAIN
          The weighted test cost algorithm.
 
构造方法摘要
构造函数 和 描述
CostSensitiveDecisionTree(BothCostsNominalDecisionSystem paraDs, boolean paraBalance)
          Construct the object.
 
方法摘要
修饰符 和 类型 方法 和 描述
 void buildClassifier(int paraAlgorithm, double paraLabmda, int paraPrune)
          Build the cost-sensitive decision tree using the specified algorithm and prune strategy.
 double classifyInstance(Instance instance)
          Classifies a given test instance using the decision tree.
 double classifyInstances()
          Classifies using the training set.
 double classifyInstances(BothCostsNominalDecisionSystem paraTestingSet)
          Classifies a given test set using the decision tree.
 double getAccuracy()
          Get the classification accuracy.
 double getAverageCost()
          Get the average cost.
 TechnicalInformation getTechnicalInformation()
          Gets an instance of a TechnicalInformation object, containing detailed information about the technical background of this class, e.g., paper reference or book this class is based on.
 java.lang.String globalInfo()
          Get a string describing the classifier.
 double instanceTestCost(Instance instance, double paraTestCost)
          Compute the instance's test cost while classification.
static void main(java.lang.String[] args)
          Main method.
 void setBalance(boolean paraBalance)
          Set the balance variable.
 void setDecisionSystem(BothCostsNominalDecisionSystem paraDs)
          Set the decision system.
 java.lang.String toString()
          Prints the decision tree using the toString(int) method.
 java.lang.String toString(int level)
          Outputs a tree at a certain level.
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

字段详细信息

serialVersionUID

public static final long serialVersionUID
For serialization

另请参见:
常量字段值

COST_GAIN

public static final int COST_GAIN
The cost gain algorithm.
代价增益算法

另请参见:
常量字段值

WEIGHTED_GAIN

public static final int WEIGHTED_GAIN
The weighted test cost algorithm. When lambda = 0, it coincides with the ID3 algorithm; When lambda = -0.5, it coincides with the CS-ID3 algorithm;. When lambda = -1, it coincides with the IDX algorithm;.
加权测试代价算法。
当兰布达=0时,等同于ID3算法;
当兰布达=-0.5时,等同于CS-ID3算法;
当兰布达=-1时,等同于IDX算法。

另请参见:
常量字段值

EXPONENTIAL_GAIN

public static final int EXPONENTIAL_GAIN
The power information gain algorithm. Also known as the EG2 algorithm.
信息增益算法。或者被称为EG2算法。

另请参见:
常量字段值

ALL_ALGORITHMS

public static final int ALL_ALGORITHMS
The weighted test cost algorithm.
加权测试代价算法

另请参见:
常量字段值

NO_PRUNE

public static final int NO_PRUNE
No prune.
无剪枝

另请参见:
常量字段值

PRE_PRUNE

public static final int PRE_PRUNE
Preprune.
预剪枝

另请参见:
常量字段值

POST_PRUNE

public static final int POST_PRUNE
Postprune.
后剪枝

另请参见:
常量字段值

accuracy

protected double accuracy
The accuracy after classification.
分类后的精确度


maximalCostGain

protected double maximalCostGain
The maximal cost gain. Used for postprune
最大代价增益。用于后剪枝。


averageCost

protected double averageCost
The average cost after classfication.
分类后的平均代价


balance

protected boolean balance
Whether or not balance according to the misclassification matrix.
根据误分类代价矩阵,是否平衡

构造方法详细信息

CostSensitiveDecisionTree

public CostSensitiveDecisionTree(BothCostsNominalDecisionSystem paraDs,
                                 boolean paraBalance)
                          throws java.lang.Exception
Construct the object.
构造对象

参数:
paraBalance - wether or not balance 是否平衡
抛出:
java.lang.Exception
方法详细信息

globalInfo

public java.lang.String globalInfo()
Get a string describing the classifier. Use the same style of ID3
获得一个描述分类器的字符串。使用与ID3相同的类型。

返回:
a description suitable for the GUI.

setBalance

public void setBalance(boolean paraBalance)
Set the balance variable.


getTechnicalInformation

public TechnicalInformation getTechnicalInformation()
Gets an instance of a TechnicalInformation object, containing detailed information about the technical background of this class, e.g., paper reference or book this class is based on. Use the same style of ID3

返回:
the technical information about this class.

setDecisionSystem

public void setDecisionSystem(BothCostsNominalDecisionSystem paraDs)
Set the decision system.
设置决策系统


getAccuracy

public double getAccuracy()
Get the classification accuracy.
获得分类精确度


getAverageCost

public double getAverageCost()
Get the average cost.
获得平均代价


buildClassifier

public void buildClassifier(int paraAlgorithm,
                            double paraLabmda,
                            int paraPrune)
                     throws java.lang.Exception
Build the cost-sensitive decision tree using the specified algorithm and prune strategy.
使用指定算法和剪枝策略构造代价敏感决策树

参数:
paraAlgorithm - 0 for cost gain, 1 for weighted cost gain
paraLabmda - only valid while the algorithm is weighted cost gain
paraPrune - the prune strategy, 0 for no prune, 1 for pre-prune, 2 for post-prune
抛出:
java.lang.Exception - if classifier can't be built successfully
另请参见:
makeTree(int, double, boolean)

classifyInstance

public double classifyInstance(Instance instance)
                        throws NoSupportForMissingValuesException
Classifies a given test instance using the decision tree.
使用决策树给一个给定测试实例分类

参数:
instance - the instance to be classified
返回:
the classification
抛出:
NoSupportForMissingValuesException - if instance has missing values

instanceTestCost

public double instanceTestCost(Instance instance,
                               double paraTestCost)
                        throws NoSupportForMissingValuesException,
                               java.lang.Exception
Compute the instance's test cost while classification.
当分类时,计算实例的测试代价

参数:
instance - the instance to be classified
返回:
the instance' test cost
抛出:
NoSupportForMissingValuesException - if instance has missing values
java.lang.Exception

classifyInstances

public double classifyInstances()
                         throws java.lang.Exception
Classifies using the training set.
使用训练集分类

返回:
average cost
抛出:
java.lang.Exception - if something wrong happens

classifyInstances

public double classifyInstances(BothCostsNominalDecisionSystem paraTestingSet)
                         throws java.lang.Exception
Classifies a given test set using the decision tree. Results are stored in object variables.
使用决策树给一个给定的测试集分类。结果储存在对象变量中。

参数:
paraTestingSet - the testing set
返回:
average cost
抛出:
java.lang.Exception - if something wrong happens

toString

public java.lang.String toString()
Prints the decision tree using the toString(int) method.

返回:
a textual description of the classifier
另请参见:
toString(int)

toString

public java.lang.String toString(int level)
Outputs a tree at a certain level.

参数:
level - the level at which the tree is to be printed
返回:
the tree as string at the given level

main

public static void main(java.lang.String[] args)
Main method.

参数:
args - the options for the classifier