coser.datamodel.informationsystem
类 RoughInformationSystem

java.lang.Object
  继承者 Instances
      继承者 coser.datamodel.informationsystem.RoughInformationSystem
直接已知子类:
BooleanInformationSystem, NominalInformationSystem, NumericInformationSystem

public class RoughInformationSystem
extends Instances

Summary: Information systems for rough sets however without algorithm implementation. The following data are claimed:
1) basic information of the information system;
2) basic information for nominal and numeric information systems;
3) reduct related information; and
4) subreduct related information.
No algorithm is implemented. Some methods are essentially abstract, so does this class.

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: The very beginning. .
Written time: April 12, 2012.
Last modify time: April 12, 2012.


字段摘要
修饰符 和 类型 字段 和 描述
protected  boolean[] allConditions
          The set of all conditional attributes.
protected  boolean[][] allReducts
          The set of all reducts.
protected  java.lang.String allReductsFilename
          The file for all reducts.
protected  boolean[][] allSubreducts
          The set of all subreducts.
protected  java.lang.String allSubreductsFilename
          The file for all subreducts.
protected  java.lang.String arffFilename
          The file for the basic information system.
protected  long backtrackSteps
          Backtrack steps, only useful in subclasses.
protected  long[] candidateReductArray
          Candidate reduct array, useful in the process of reduction.
protected  long[] candidateSubreductArray
          Candidate sub-reduct array
protected  double[] candidateSubreductEntropyArray
          Candidate sub-reduct entropy array
protected  boolean[] core
          The array that indicate the set of core attributes.
protected  boolean[] currentReduct
          The current reduct represented by an boolean array.
protected  boolean[] currentSelectedAttributes
          Currently selected attributes.
protected  long endTime
          Reduction end time, only useful in subclasses.
protected  int minimalReductSize
          The size of the minimal reduct.
protected  int numberOfAttributes
          Number of all attributes.
protected  int numberOfCandidateReducts
          The number of candidate reducts.
protected  int numberOfCandidateSubreducts
          Number of candidate sub-reducts
protected  int numberOfInstances
          Number of dataMatrixs.
protected  boolean[] optimalReduct
          The optimal reduct.
protected  java.lang.String runTimeInformation
          Runtime information, only useful in subclasses.
protected  long startTime
          Reduction start time, only useful in subclasses.
static int STRANGE_VALUE
          Used to indicate that the value is not computed yet.
 
构造方法摘要
构造函数 和 描述
RoughInformationSystem(Instances paraDataset)
          Construct the information system, essentially clone a information system.
RoughInformationSystem(Instances paraDataset, boolean[] paraSelectedAttributes)
          Construct a new sub information system with selected attributes.
RoughInformationSystem(Instances paraDataset, int paraCapacity)
          Construct the information system.
RoughInformationSystem(Instances source, int first, int toCopy)
          Construct the information system.
RoughInformationSystem(java.io.Reader paraReader)
          Construct the rough information system.
RoughInformationSystem(java.lang.String name, FastVector attInfo, int capacity)
          Construct the information system.
 
方法摘要
修饰符 和 类型 方法 和 描述
 boolean[] computeCore()
          Compute the core, essentially an abstract method.
 boolean[] computeCore(boolean[] paraAvailableAttributes)
          Find a core with available attributes, should be overridden.
 void delete(boolean[] paraIndices)
          Delete elements marked FALSE in a boolean array.
 RoughInformationSystem[] divideInTwo(double paraPercentage)
          Divide the decision system in two according to the given percentage.
protected  boolean[][] generateBooleanArrays(double paraPercentage)
          Generate two boolean arrays indicating two subsets.
 java.lang.String getAllReductsFilename()
          Get the sred filename.
 java.lang.String getAllReductsString()
          Get all reducts reprensented by a string, which can be written to a .reds file directly.
 java.lang.String getAllSubreductsFilename()
          Get the sred filename.
 java.lang.String getArffFilename()
          Get the arff filename of the current dataset.
 java.lang.String getArffSource()
          Get the arff source.
 long getBacktrackSteps()
          Get the backtrack steps.
 double[] getCandidateSubreductEntropyArray()
          Get the candidate subreduct entropy array.
 boolean[] getCurrentReduct()
          Get the current reduct.
 int getCurrentReductIndex()
          Get the index of the current index.
 int getNumberOfConditions()
          Get the number of conditions, only invoked by those who have not access to numberOfAttributes.
 boolean[] getOptimalReduct()
          Get the optimal reduct.
 long getReductionTime()
          Get the reduction run time.
 java.lang.String getReductString()
          Get the current reduct with the form of String.
 java.lang.String getRunTimeInformation()
          Get the run time information.
 boolean hasMissingValue()
          Has the information system missing value?
 void initializeForReduction()
          Check the information system.
 boolean isBoolean()
          Is the information system relational?
 boolean isNominal()
          Is the information system nominal?
 boolean isNormalized()
          Is the information system normalized?
protected  boolean isNormalizedJudge()
          Is the decision system normalized?
 boolean isNumeric()
          Is the information system numeric?
 RoughInformationSystem normalize()
          Normalize the current decision system and write to an arff file.
 void printAllReducts()
          Print all reducts.
 void readAllReducts()
          Read all reducts from the default reduct file, whose filename only differs from the arff file by the suffix.
 void readAllReducts(java.lang.String paraFilename)
          Read all reducts from a text file with the following format:
2
1,3,6
1,4,5,7
That is, the first line indicates the number of reducts.
 void readAllSubreducts()
          Read all reducts from the default reduct file, whose filename only differs from the arff file by the suffix.
 void readAllSubreducts(java.lang.String paraFilename)
          Read all reducts from a text file with the following format:
2
1,3,6
1,4,5,7
That is, the first line indicates the number of subreducts.
static long[] removeSupersets(long[] paraSets, int paraNumberOfConditions)
          Remove supersets, used to obtain reducts.
 void resetNumberOfAttributes()
          Reset number of attributes.
 void setAllReductsFilename()
          Set the reds filename such that it can be stored for and reloaded next time.
 void setAllReductsFilename(java.lang.String paraFilename)
          Set the red filename such that it can be stored for and reloaded next time.
 void setAllSubreductsFilename()
          Set the sred filename such that it can be stored for and reloaded next time.
 void setAllSubreductsFilename(java.lang.String paraFilename)
          Set the sred filename such that it can be stored for and reloaded next time.
 void setArffFilename(java.lang.String paraFilename)
          Set the arff filename such that it can be stored and reloaded next time.
 void setCurrentReduct(boolean[] paraCurrentReduct)
          Set the current reduct.
 void setCurrentReduct(long paraCurrentReduct)
          Set the current reduct.
 java.lang.String toString()
          For toString().
 void writeAllReducts()
          Write all reducts to the default reduct file, whose filename only differs from the arff file by the suffix.
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

字段详细信息

STRANGE_VALUE

public static int STRANGE_VALUE
Used to indicate that the value is not computed yet.


arffFilename

protected java.lang.String arffFilename
The file for the basic information system.


numberOfAttributes

protected int numberOfAttributes
Number of all attributes. This variable is used to avoid invoking numAttributes(), which might be time-consuming.


numberOfInstances

protected int numberOfInstances
Number of dataMatrixs. This variable is used to avoid invoking numInstances(), which might be time-consuming.


allConditions

protected boolean[] allConditions
The set of all conditional attributes. An array with only true values. It is used to save time while computing.


allReductsFilename

protected java.lang.String allReductsFilename
The file for all reducts.


allReducts

protected boolean[][] allReducts
The set of all reducts. This class only support reading reducts from a file. The computation of reducts is not supported because we do not know the characteristics of the information system (numeric, nominal, etc).


currentReduct

protected boolean[] currentReduct
The current reduct represented by an boolean array. It is more useful in subclasses.


currentSelectedAttributes

protected boolean[] currentSelectedAttributes
Currently selected attributes. Used in the process of reduction. Useful in subclasses.


core

protected boolean[] core
The array that indicate the set of core attributes. Useful in subclasses.


minimalReductSize

protected int minimalReductSize
The size of the minimal reduct.


optimalReduct

protected boolean[] optimalReduct
The optimal reduct. More useful in subclasses.


numberOfCandidateReducts

protected int numberOfCandidateReducts
The number of candidate reducts.


candidateReductArray

protected long[] candidateReductArray
Candidate reduct array, useful in the process of reduction.


allSubreductsFilename

protected java.lang.String allSubreductsFilename
The file for all subreducts. Now the concept of subreduct is only supported by nominal information systems. In the further, however, we may move the information systems. In that case, the information entropy is not applicable.


allSubreducts

protected boolean[][] allSubreducts
The set of all subreducts. Similar to the case of allReducts, it can be read, however not computed in this class.


numberOfCandidateSubreducts

protected int numberOfCandidateSubreducts
Number of candidate sub-reducts


candidateSubreductArray

protected long[] candidateSubreductArray
Candidate sub-reduct array


candidateSubreductEntropyArray

protected double[] candidateSubreductEntropyArray
Candidate sub-reduct entropy array


startTime

protected long startTime
Reduction start time, only useful in subclasses.


endTime

protected long endTime
Reduction end time, only useful in subclasses.


backtrackSteps

protected long backtrackSteps
Backtrack steps, only useful in subclasses.


runTimeInformation

protected java.lang.String runTimeInformation
Runtime information, only useful in subclasses.

构造方法详细信息

RoughInformationSystem

public RoughInformationSystem(java.io.Reader paraReader)
                       throws java.io.IOException
Construct the rough information system. Simply adopt everything of the super class. This is the most often invoked constructor.

参数:
paraReader - the input with the form of a Reader. We can generate a FileReader given an .arff filename.
抛出:
java.io.IOException

RoughInformationSystem

public RoughInformationSystem(Instances paraDataset)
Construct the information system, essentially clone a information system. Simply adopt everything of the super class.

参数:
paraDataset - the initial dataset with the form of Instance.

RoughInformationSystem

public RoughInformationSystem(Instances paraDataset,
                              int paraCapacity)
Construct the information system. Simply adopt everything of the super class.


RoughInformationSystem

public RoughInformationSystem(Instances source,
                              int first,
                              int toCopy)
Construct the information system. Simply adopt everything of the super class.


RoughInformationSystem

public RoughInformationSystem(java.lang.String name,
                              FastVector attInfo,
                              int capacity)
Construct the information system. Simply adopt everything of the super class.


RoughInformationSystem

public RoughInformationSystem(Instances paraDataset,
                              boolean[] paraSelectedAttributes)
Construct a new sub information system with selected attributes.

参数:
paraDataset - the initial dataset with the form of Instance.
paraSelectedAttributes - selected attributes, others are removed.
方法详细信息

initializeForReduction

public void initializeForReduction()
                            throws java.lang.Exception
Check the information system. Missing values are not supported.

抛出:
java.lang.Exception - missing values exists.

setArffFilename

public void setArffFilename(java.lang.String paraFilename)
Set the arff filename such that it can be stored and reloaded next time. It is not used to read the file this time. Also set the subreduct filename at the same time.

参数:
paraFilename - the given filename.

getArffFilename

public java.lang.String getArffFilename()
                                 throws java.lang.Exception
Get the arff filename of the current dataset.

抛出:
java.lang.Exception

resetNumberOfAttributes

public void resetNumberOfAttributes()
Reset number of attributes. This should be invoked while the information system is changed. E.g., attributes removed.


getCandidateSubreductEntropyArray

public double[] getCandidateSubreductEntropyArray()
Get the candidate subreduct entropy array. May be used somewhere else such as AllSubreductsDialog.java.


getRunTimeInformation

public java.lang.String getRunTimeInformation()
Get the run time information.

返回:
the run time informaion in a string.

isNominal

public boolean isNominal()
Is the information system nominal?

返回:
true only if all attributes are nominal.

isNumeric

public boolean isNumeric()
Is the information system numeric?

返回:
true only if all attributes are numeric.

isNormalized

public boolean isNormalized()
Is the information system normalized?

返回:
true only if all attribute values are in [0, 1].

isBoolean

public boolean isBoolean()
Is the information system relational?

返回:
true only if all attribute values are in relational.

hasMissingValue

public boolean hasMissingValue()
Has the information system missing value?


isNormalizedJudge

protected boolean isNormalizedJudge()
Is the decision system normalized? Set to protected such that it cannot run outside the package.


delete

public void delete(boolean[] paraIndices)
Delete elements marked FALSE in a boolean array.

参数:
paraIndices - The indices marked with false are removed. Although not checked, the length of paraIndices should be numberOfInstances.

divideInTwo

public RoughInformationSystem[] divideInTwo(double paraPercentage)
                                     throws java.lang.Exception
Divide the decision system in two according to the given percentage.

参数:
paraPercentage - The percentage of instances in the first subset.
返回:
Two decision systems in an array.
抛出:
java.lang.Exception

generateBooleanArrays

protected boolean[][] generateBooleanArrays(double paraPercentage)
                                     throws java.lang.Exception
Generate two boolean arrays indicating two subsets. May be invoked in subclasses.

参数:
paraPercentage - The percentage of instances in the first subset.
返回:
The two boolean arrays.
抛出:
java.lang.Exception

getNumberOfConditions

public int getNumberOfConditions()
Get the number of conditions, only invoked by those who have not access to numberOfAttributes.

返回:
the number of conditions.

getOptimalReduct

public boolean[] getOptimalReduct()
Get the optimal reduct. "Optimal" has different definitions in definition environment.
For a decision system, an optimal reduct is a minimal reduct.
For a test-cost-senstive decision system, an optimal reduct is a minimal test-cost reduct.
For a both-cost-senstive decision system, an optimal reduct is a minimal cost reduct.
Therefore, this method is essentially an abstract method.

返回:
the optimal reduct.

getBacktrackSteps

public long getBacktrackSteps()
Get the backtrack steps. Many subclasses need backtrack algorithms.

返回:
the backtrack steps.

setCurrentReduct

public void setCurrentReduct(long paraCurrentReduct)
Set the current reduct.

参数:
paraCurrentReduct - current reduct with a form of long.

setCurrentReduct

public void setCurrentReduct(boolean[] paraCurrentReduct)
Set the current reduct. The current reduct is a clone of the given array to avoid conflict.

参数:
paraCurrentReduct - current reduct with a form of boolean array.

getCurrentReduct

public boolean[] getCurrentReduct()
Get the current reduct.

返回:
the reduct with the form of boolean vector.

getCurrentReductIndex

public int getCurrentReductIndex()
                          throws java.lang.Exception
Get the index of the current index. Although the current reduct is obtained in subclasses, this method will not be overridden.

返回:
the index of the current reduct.
抛出:
java.lang.Exception - if the reduct or the set of all reducts not computed yet, or the current reduct is not valid.

computeCore

public boolean[] computeCore()
                      throws java.lang.Exception
Compute the core, essentially an abstract method.

返回:
the core with the form of boolean vector.
抛出:
java.lang.Exception
另请参见:
computeCore(boolean[])

computeCore

public boolean[] computeCore(boolean[] paraAvailableAttributes)
                      throws java.lang.Exception
Find a core with available attributes, should be overridden.

参数:
paraAvailableAttributes - available attributes
返回:
the core with the form of boolean vector.
抛出:
java.lang.Exception

getReductString

public java.lang.String getReductString()
                                 throws java.lang.Exception
Get the current reduct with the form of String.

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

normalize

public RoughInformationSystem normalize()
                                 throws java.lang.Exception
Normalize the current decision system and write to an arff file. Symbolic attributes are also normalized. Do not normalize the class. Missing values are set to 0.5.

返回:
the normalized decision system.
抛出:
java.lang.Exception

getArffSource

public java.lang.String getArffSource()
Get the arff source.

返回:
arff source as a string, which can be wrote to an arff file directly.

setAllReductsFilename

public void setAllReductsFilename()
Set the reds filename such that it can be stored for and reloaded next time. It is based on the arff filename.


setAllReductsFilename

public void setAllReductsFilename(java.lang.String paraFilename)
Set the red filename such that it can be stored for and reloaded next time. It is not used to read the file this time.

参数:
paraFilename - the given filename.

getAllReductsFilename

public java.lang.String getAllReductsFilename()
                                       throws java.lang.Exception
Get the sred filename.

返回:
the filename of all reducts
抛出:
java.lang.Exception

readAllReducts

public void readAllReducts()
                    throws java.io.IOException,
                           java.lang.Exception
Read all reducts from the default reduct file, whose filename only differs from the arff file by the suffix.

抛出:
java.io.IOException - if an error occurr while reading the file.
java.lang.Exception - if an attribute index exceeds the bound.

readAllReducts

public void readAllReducts(java.lang.String paraFilename)
                    throws java.io.IOException,
                           java.lang.Exception
Read all reducts from a text file with the following format:
2
1,3,6
1,4,5,7
That is, the first line indicates the number of reducts. Each line corresponds with a reduct, and each element corresponds with the index of the attribute.

参数:
paraFilename - the filename of the reduct file.
抛出:
java.io.IOException - if an error occurr while reading the file.
java.lang.Exception - if an attribute index exceeds the bound.

printAllReducts

public void printAllReducts()
Print all reducts. Only for testing


writeAllReducts

public void writeAllReducts()
                     throws java.io.IOException,
                            java.lang.Exception
Write all reducts to the default reduct file, whose filename only differs from the arff file by the suffix.

抛出:
java.io.IOException - if an error occurr while writing the file.
java.lang.Exception - if an attribute index exceeds the bound.

getAllReductsString

public java.lang.String getAllReductsString()
                                     throws java.io.IOException,
                                            java.lang.Exception
Get all reducts reprensented by a string, which can be written to a .reds file directly.

返回:
a string indicating all reducts.
抛出:
java.io.IOException
java.lang.Exception

getReductionTime

public long getReductionTime()
Get the reduction run time.

返回:
the reduction run time.

setAllSubreductsFilename

public void setAllSubreductsFilename()
Set the sred filename such that it can be stored for and reloaded next time. It is based on the arff filename.


setAllSubreductsFilename

public void setAllSubreductsFilename(java.lang.String paraFilename)
Set the sred filename such that it can be stored for and reloaded next time. It is not used to read the file this time.

参数:
paraFilename - the given filename.

getAllSubreductsFilename

public java.lang.String getAllSubreductsFilename()
                                          throws java.lang.Exception
Get the sred filename.

返回:
the filename of all subreducts
抛出:
java.lang.Exception

readAllSubreducts

public void readAllSubreducts()
                       throws java.io.IOException,
                              java.lang.Exception
Read all reducts from the default reduct file, whose filename only differs from the arff file by the suffix.

抛出:
java.io.IOException - if an error occurr while reading the file.
java.lang.Exception - if an attribute index exceeds the bound.

readAllSubreducts

public void readAllSubreducts(java.lang.String paraFilename)
                       throws java.io.IOException,
                              java.lang.Exception
Read all reducts from a text file with the following format:
2
1,3,6
1,4,5,7
That is, the first line indicates the number of subreducts. Each line corresponds with a reduct, and each element corresponds with the index of the attribute.

参数:
paraFilename - the filename of the reduct file.
抛出:
java.io.IOException - if an error occurr while reading the file.
java.lang.Exception - if an attribute index exceeds the bound.

removeSupersets

public static long[] removeSupersets(long[] paraSets,
                                     int paraNumberOfConditions)
                              throws java.lang.Exception
Remove supersets, used to obtain reducts.

返回:
a set of reducts without superflous attributes.
抛出:
java.lang.Exception

toString

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

返回:
object status.