coser.datamodel.decisionsystem
类 NominalDecisionSystem

java.lang.Object
  继承者 Instances
      继承者 coser.datamodel.decisionsystem.RoughDecisionSystem
          继承者 coser.datamodel.decisionsystem.CostSensitiveDecisionSystem
              继承者 coser.datamodel.decisionsystem.NominalDecisionSystem
直接已知子类:
BothCostsNominalDecisionSystem, TestCostNominalDecisionSystem, TimeNominalDecisionSystem

public class NominalDecisionSystem
extends CostSensitiveDecisionSystem

Summary: Decision system with only nominal values for Pawlak rough sets. Implement the following algorithms:
1) compute positive region, information entropy, majority;
2) compute core;
3) compute reducts with exhaustively (backtrack and exponential) or heuristically (information-gain based).

Author: Fan Min minfanphd@163.com

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: Finished. New methods can be added, though.
Written time: March 09, 2011.
Last modify time: February 21, 2012.


字段摘要
修饰符 和 类型 字段 和 描述
static int ATTRIBUTES_COMBINATIONS
          Attribute value maximal combination.
static int BACKTRACK
          The backtrack algorithm.
static int EXPONENTIAL
          The exponential algorithm.
protected  int reductMinimalSize
          The minimal size of reducts.
 
从类 coser.datamodel.decisionsystem.CostSensitiveDecisionSystem 继承的字段
alpha, COMPLEX_COMMON_TEST_COST, COST_TYPE_MONEY, COST_TYPE_TESTING_TIME, COST_TYPE_WAITING_TIME, currentReductCost, currentReductTime, currentReductTotalTestCost, DEFAULT_AVERAGE_NUMBER_OF_TESTS_PER_GROUP, groupCommonTestCostArray, groupInclusionArray, groupInclusionMatrix, IMPOSSIBLE_COST, individualCostDistributions, individualCostLowerBounds, individualCostMatrix, individualCostRandom, individualCostUpperBounds, minimalTestCostReduct, minimalTimeReduct, misclassificationCostMatrix, misclassificationCostSumArray, NORMAL, optimalReductTestCost, optimalReductTime, PARETO, randomMode, SIMPLE_COMMON_TEST_COST, TEST_COST_INDEPENDENT, TEST_COST_TYPES, testCostConstraint, testCostRelationship, testingOrderMatrix, timeParts, totalTimeConstraint, unifiedMisclassificationCost, UNIFORM
 
从类 coser.datamodel.decisionsystem.RoughDecisionSystem 继承的字段
allConditions, allReducts, allReductsFilename, allSubreducts, allSubreductsFilename, arffFilename, backtrackSteps, candidateReductArray, candidateSubreductArray, candidateSubreductConsistencyArray, classSize, CONDITIONAL_ENTROPY, consistency, core, currentReduct, currentSelectedAttributes, endTime, MAJORITY, minimalReductSize, numberOfCandidateReducts, numberOfCandidateSubreducts, numberOfConditions, numberOfInstances, optimalReduct, POSITIVE_REGION, runTimeInformation, startTime, totalEntropy, totalMajority, totalPositiveRegion
 
构造方法摘要
构造函数 和 描述
NominalDecisionSystem(Instances paraDataset)
          Construct the decision system.
NominalDecisionSystem(Instances paraDataset, int paraCapacity)
          Construct the decision system.
NominalDecisionSystem(Instances paraSource, int paraFirst, int paraToCopy)
          Construct the decision system.
NominalDecisionSystem(NominalDecisionSystem paraDataset, boolean[] paraSelectedAttributes)
          Construct the decision system.
NominalDecisionSystem(java.io.Reader paraReader)
          Construct the decision system.
NominalDecisionSystem(java.lang.String paraName, FastVector paraAttInfo, int paraCapacity)
          Construct the decision system.
 
方法摘要
修饰符 和 类型 方法 和 描述
 void buildCandidateReducts(Instances[] paraInstancesArray, long paraSelectedAttributes, int attributeIndexLowerBound)
          Backtrack approach to produce candidate reducts.
 boolean[][] computeAllReductsBacktrack()
          Compute the set of all reducts using the backtrack algorithm.
 boolean[][] computeAllReductsBacktrack(boolean[] paraAvailableAttributes)
          Compute the set of all reducts using the backtrack algorithm.
 boolean[][] computeAllReductsExhaustive(boolean[] paraAvailableAttributes, int paraAlgorithm)
          Exhaustive reduction.
 boolean[][] computeAllReductsExhaustive(int paraAlgorithm)
          Exhaustive reduction.
 long[] computeAllReductsExhaustive(long[] paraAttributeSetsInLong, int paraAlgorithm)
          Exhaustive reduction.
 boolean[][] computeAllReductsExhaustiveExponential(boolean[] paraAvailableAttributes)
          Exhaustive reduction using the exponential approach.
 boolean[][] computeAllSubreducts()
          Compute the set of all sub-reducts.
 int computeConsistency(Instances[] paraInstancesArray)
          Compute the attribute set consistency.
 boolean[] computeCore(boolean[] paraAvailableAttributes)
          Find a core subject to the given measure.
 double computeOptimalReductBacktrack()
          Compute one optimal reducts using the backtrack algorithm.
 double conditionalEntropy(boolean[] paraSelectedAttributes)
          Computes the conditional entropy of a dataset.
 boolean[] entropyBasedReduction()
          Find a (possibly) minimal reduct using the information entropy based approach.
 double informationGain(boolean[] paraSelectedAttributes, int paraAttributeIndex)
          Computes the information gain of an attribute given an attribute subset.
 double informationGain(int paraAttributeIndex)
          Computes the information gain of an attribute given an attribute subset.
 boolean isCurrentReductOptimal()
          Is the current reduct optimal?
static void main(java.lang.String[] args)
          Test information entopy.
 int majority(boolean[] paraSelectedAttributes)
          Compute the majority number of instances.
 int majority(Instances[] paraInstancesArray)
          Compute the majority number of instances.
 void optimalReductBacktrack(Instances[] paraInstancesArray, long paraSelectedAttributes, int paraNumberOfSelectedAttributes, int paraAttributeLowerBound)
          Backtrack approach to produce an optimal.
 int positiveRegion(boolean[] paraSelectedAttributes)
          Compute the positive region given the attribute subset.
 int positiveRegion(Instances[] paraInstancesArray)
          Compute the positive region given the attribute subset.
 long[] removeRedundantSubreducts()
          Remove redundant sub-reducts.
 Instances[] splitData(boolean[] paraSelectedAttributes)
          Splits this dataset according to the given attribute subset.
 Instances[] splitData(Instances[] paraInstancesArray, Attribute paraAttribute)
          Splits a number of datasets according to the values of a nominal attribute.
 Instances[] splitData(Instances paraData, Attribute paraAttribute)
          Splits a dataset according to the values of a nominal attribute.
 java.lang.String toString()
          For toString().
 
从类 coser.datamodel.decisionsystem.CostSensitiveDecisionSystem 继承的方法
averageMisclassificationCost, averageMisclassificationCost, averageMisclassificationCost, averageMisclassificationCost, bestClassValue, computeAdditiveCost, computeExceedingFactor, computeOptimalTestCost, computeReductTestCost, computeReductWaitingTime, computeTestCost, computeTestCost, copyForClone, generateIndividualCosts, generateOneCost, getClassificationCost, getDistributionString, getIndividualCost, getIndividualTestCost, getIndividualTestCostArray, getMisclassificationCostMatrix, getOptimalReductTestCost, getReductTotalTestCost, initializeForReduction, refreshTestCost, setAlpha, setComplexCommonTestCostArrays, setCostRandomMode, setIndividualCostArray, setIndividualCostBounds, setIndividualCostDistribution, setMisclassificationCostMatrix, setMisclassificationCostMatrix, setSimpleCommonTestCostArrays, setTestCostsRelationShip, setUnifiedMisclassificationCost, sortByTestCost
 
从类 coser.datamodel.decisionsystem.RoughDecisionSystem 继承的方法
classEntropy, classEntropy, computeConsistency, computeConsistency, computeCore, conditionalEntropy, conditionalEntropy, copyForClone, delete, divideInTwo, entropyReciprocal, entropyReciprocal, entropyReciprocal, entropyReciprocal, entropyReciprocal, getAllReductsFilename, getAllReductsString, getAllSubreductsFilename, getArffFilename, getArffSource, getBacktrackSteps, getCandidateSubreductConsistencyArray, getCurrentReduct, getCurrentReductIndex, getMeasure, getNumberOfConditions, getOptimalReduct, getReductionTime, getReductString, getRunTimeInformation, hasMissingValue, isNominal, isNormalized, isNumeric, majority, majority, normalize, positiveRegion, positiveRegion, printAllReducts, readAllReducts, readAllReducts, readAllSubreducts, readAllSubreducts, setAllReductsFilename, setAllReductsFilename, setAllSubreductsFilename, setAllSubreductsFilename, setArffFilename, setCurrentReduct, setCurrentReduct, setMeasure, writeAllReducts
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

字段详细信息

ATTRIBUTES_COMBINATIONS

public static final int ATTRIBUTES_COMBINATIONS
Attribute value maximal combination.

另请参见:
常量字段值

EXPONENTIAL

public static final int EXPONENTIAL
The exponential algorithm. To compute the set of all reducts. This algorithm is employed only

另请参见:
常量字段值

BACKTRACK

public static final int BACKTRACK
The backtrack algorithm. To compute the set of all reducts.

另请参见:
常量字段值

reductMinimalSize

protected int reductMinimalSize
The minimal size of reducts.

构造方法详细信息

NominalDecisionSystem

public NominalDecisionSystem(java.io.Reader paraReader)
                      throws java.io.IOException,
                             java.lang.Exception
Construct the decision system. Simply adopt everything of the super class. This is the most often used constructor since it reads from a file.

参数:
paraReader - the given reader, often with the form of a file reader. We can generate a FileReader given an .arff filename.
抛出:
java.io.IOException
java.lang.Exception

NominalDecisionSystem

public NominalDecisionSystem(Instances paraDataset)
                      throws java.lang.Exception
Construct the decision system. Simply adopt everything of the super class.

抛出:
java.lang.Exception

NominalDecisionSystem

public NominalDecisionSystem(Instances paraDataset,
                             int paraCapacity)
                      throws java.lang.Exception
Construct the decision system. Simply adopt everything of the super class. Rarely used.

抛出:
java.lang.Exception

NominalDecisionSystem

public NominalDecisionSystem(Instances paraSource,
                             int paraFirst,
                             int paraToCopy)
                      throws java.lang.Exception
Construct the decision system. Simply adopt everything of the super class.

抛出:
java.lang.Exception

NominalDecisionSystem

public NominalDecisionSystem(java.lang.String paraName,
                             FastVector paraAttInfo,
                             int paraCapacity)
                      throws java.lang.Exception
Construct the decision system. Simply adopt everything of the super class.

抛出:
java.lang.Exception

NominalDecisionSystem

public NominalDecisionSystem(NominalDecisionSystem paraDataset,
                             boolean[] paraSelectedAttributes)
                      throws java.lang.Exception
Construct the decision system. Simply adopt everything of the super class.

抛出:
java.lang.Exception
方法详细信息

positiveRegion

public int positiveRegion(boolean[] paraSelectedAttributes)
                   throws java.lang.Exception
Compute the positive region given the attribute subset.

覆盖:
类 RoughDecisionSystem 中的 positiveRegion
参数:
paraSelectedAttributes - selected attributes represented as a boolean array.
返回:
the number of objects in the positive region.
抛出:
java.lang.Exception - for overridden by subclasses.
另请参见:
positiveRegion(Instances[])

positiveRegion

public int positiveRegion(Instances[] paraInstancesArray)
                   throws java.lang.Exception
Compute the positive region given the attribute subset.

覆盖:
类 RoughDecisionSystem 中的 positiveRegion
参数:
paraInstancesArray - instances array, already a number of object subsets.
返回:
the number of objects in the positive region.
抛出:
java.lang.Exception - for overridden by subclasses.

majority

public int majority(boolean[] paraSelectedAttributes)
             throws java.lang.Exception
Compute the majority number of instances.

覆盖:
类 RoughDecisionSystem 中的 majority
参数:
paraSelectedAttributes - selected attributes represented as a boolean array.
返回:
the majority number of instances.
抛出:
java.lang.Exception
另请参见:
majority(Instances[])

majority

public int majority(Instances[] paraInstancesArray)
             throws java.lang.Exception
Compute the majority number of instances.

覆盖:
类 RoughDecisionSystem 中的 majority
参数:
paraInstancesArray - the subsets.
返回:
the majority number of instances.
抛出:
java.lang.Exception

splitData

public Instances[] splitData(Instances paraData,
                             Attribute paraAttribute)
Splits a dataset according to the values of a nominal attribute. Copied from Id3.java. Only for nominal attributes.

参数:
paraData - the data which is to be split.
paraAttribute - the attribute to be used for splitting.
返回:
the sets of instances produced by the split.

splitData

public Instances[] splitData(Instances[] paraInstancesArray,
                             Attribute paraAttribute)
                      throws java.lang.Exception
Splits a number of datasets according to the values of a nominal attribute. Modified from Id3.java. Only for nominal attributes.

参数:
paraInstancesArray - the data array which is to be split.
paraAttribute - the attribute to be used for splitting.
返回:
the sets of instances produced by the split.
抛出:
java.lang.Exception

splitData

public Instances[] splitData(boolean[] paraSelectedAttributes)
                      throws java.lang.Exception
Splits this dataset according to the given attribute subset. There is not a paraData parameter since it is unnecessary.

参数:
paraSelectedAttributes - selected attributes.
返回:
the sets of instances produced by the split. Pure Instances are not returned, hence when the returned value is null, the given attibute subset is enough for classification.
抛出:
java.lang.Exception

conditionalEntropy

public double conditionalEntropy(boolean[] paraSelectedAttributes)
                          throws java.lang.Exception
Computes the conditional entropy of a dataset.

覆盖:
类 RoughDecisionSystem 中的 conditionalEntropy
参数:
paraSelectedAttributes - the selected attributes.
返回:
the conditional entropy of selected attributes.
抛出:
java.lang.Exception
另请参见:
RoughDecisionSystem.conditionalEntropy(Instances[])

computeConsistency

public int computeConsistency(Instances[] paraInstancesArray)
                       throws java.lang.Exception
Compute the attribute set consistency.

覆盖:
类 RoughDecisionSystem 中的 computeConsistency
参数:
paraInstancesArray - object subsets.
返回:
the attribute set consistency.
抛出:
java.lang.Exception

informationGain

public double informationGain(int paraAttributeIndex)
                       throws java.lang.Exception
Computes the information gain of an attribute given an attribute subset. Performance enhancement not considered.

参数:
paraAttributeIndex - the index of the new attribute.
返回:
the information gain of specified attributes.
抛出:
java.lang.Exception

informationGain

public double informationGain(boolean[] paraSelectedAttributes,
                              int paraAttributeIndex)
                       throws java.lang.Exception
Computes the information gain of an attribute given an attribute subset. Performance enhancement not considered.

参数:
paraSelectedAttributes - the selected attributes.
paraAttributeIndex - the index of the new attribute.
返回:
the conditional entropy of selected attributes.
抛出:
java.lang.Exception

computeCore

public boolean[] computeCore(boolean[] paraAvailableAttributes)
                      throws java.lang.Exception
Find a core subject to the given measure. Overwrite the one in RoughDecisionSystem

覆盖:
类 RoughDecisionSystem 中的 computeCore
参数:
paraAvailableAttributes - available attributes
返回:
the core with the form of boolean vector.
抛出:
java.lang.Exception

computeAllReductsBacktrack

public boolean[][] computeAllReductsBacktrack(boolean[] paraAvailableAttributes)
                                       throws java.lang.Exception
Compute the set of all reducts using the backtrack algorithm. Note that this method invoks computeAllReductsBacktrack() instead of vice versa.

参数:
paraAvailableAttributes - the set of available attributes
抛出:
java.lang.Exception
另请参见:
computeAllReductsBacktrack()

computeAllReductsBacktrack

public boolean[][] computeAllReductsBacktrack()
                                       throws java.lang.Exception
Compute the set of all reducts using the backtrack algorithm. All attributes are available.

抛出:
java.lang.Exception

buildCandidateReducts

public void buildCandidateReducts(Instances[] paraInstancesArray,
                                  long paraSelectedAttributes,
                                  int attributeIndexLowerBound)
                           throws java.lang.Exception
Backtrack approach to produce candidate reducts.

参数:
paraInstancesArray - Instances array from the last level.
paraSelectedAttributes - Attributes already selected in the last level.
attributeIndexLowerBound - The lower bound of the atribute index. We can only look forward.
抛出:
java.lang.Exception

entropyBasedReduction

public boolean[] entropyBasedReduction()
                                throws java.lang.Exception
Find a (possibly) minimal reduct using the information entropy based approach.

返回:
the reduct with the form of boolean vector.
抛出:
java.lang.Exception

isCurrentReductOptimal

public boolean isCurrentReductOptimal()
                               throws java.lang.Exception
Is the current reduct optimal?

返回:
true if it is optimal.
抛出:
java.lang.Exception - if the reduct or the set of all reducts not computed yet.

computeAllReductsExhaustive

public boolean[][] computeAllReductsExhaustive(int paraAlgorithm)
                                        throws java.lang.Exception
Exhaustive reduction. By default all attributes are available.

参数:
paraAlgorithm - the algorithm employed.
返回:
a matrix to incate the set of all reducts.
抛出:
java.lang.Exception

computeAllReductsExhaustive

public boolean[][] computeAllReductsExhaustive(boolean[] paraAvailableAttributes,
                                               int paraAlgorithm)
                                        throws java.lang.Exception
Exhaustive reduction.

参数:
paraAvailableAttributes - which attributes are available. Sometimes we need to compute reducts of a subtable.
paraAlgorithm - the algorithm employed.
返回:
a matrix to incate the set of all reducts.
抛出:
java.lang.Exception - if the algorithm is not supported. Or other Exceptions threw by more fundamental methods.

computeAllReductsExhaustiveExponential

public boolean[][] computeAllReductsExhaustiveExponential(boolean[] paraAvailableAttributes)
                                                   throws java.lang.Exception
Exhaustive reduction using the exponential approach. This algorithm is suitable for very small datasets or datasets where most attributes are core.

参数:
paraAvailableAttributes - which attributes are available. Sometimes we need to compute reducts of a subtable.
返回:
a matrix to incate the set of all reducts.
抛出:
java.lang.Exception

computeAllSubreducts

public boolean[][] computeAllSubreducts()
                                 throws java.lang.Exception
Compute the set of all sub-reducts.

返回:
the set of all sub-reducts.
抛出:
java.lang.Exception

removeRedundantSubreducts

public long[] removeRedundantSubreducts()
                                 throws java.lang.Exception
Remove redundant sub-reducts.

返回:
All sub-reducts without redundant.
抛出:
java.lang.Exception

computeAllReductsExhaustive

public long[] computeAllReductsExhaustive(long[] paraAttributeSetsInLong,
                                          int paraAlgorithm)
                                   throws java.lang.Exception
Exhaustive reduction. This method is a bit strange in that it is computed on the basis of a number of attribute subsets. It is employed to obtain subreducts.

参数:
paraAttributeSetsInLong - Attributes sets by long values. Each long value corresponds to an attribute subset. Each bit in the long represents whether or not the corresponding attribute is selected.
paraAlgorithm - the algorithm employed.
返回:
a matrix to incate the set of all reducts.
抛出:
java.lang.Exception - if the algorithm is not supported. Or other Exceptions threw by more fundamental methods.

computeOptimalReductBacktrack

public double computeOptimalReductBacktrack()
                                     throws java.lang.Exception
Compute one optimal reducts using the backtrack algorithm. All attributes are available.

抛出:
java.lang.Exception

optimalReductBacktrack

public void optimalReductBacktrack(Instances[] paraInstancesArray,
                                   long paraSelectedAttributes,
                                   int paraNumberOfSelectedAttributes,
                                   int paraAttributeLowerBound)
                            throws java.lang.Exception
Backtrack approach to produce an optimal.

参数:
paraInstancesArray - Instances array from the last level.
paraSelectedAttributes - Attributes already selected in the last level.
paraNumberOfSelectedAttributes - Number of already selected tests.
paraAttributeLowerBound - The lower bound of the attribute index. We can only look forward.
抛出:
java.lang.Exception

toString

public java.lang.String toString()
For toString(). See interface toString().

覆盖:
类 CostSensitiveDecisionSystem 中的 toString
返回:
object status.

main

public static void main(java.lang.String[] args)
Test information entopy.