SF.asDecisionTable: Converting a data.frame into a 'DecisionTable' object

View source: R/IOFunctions.R

SF.asDecisionTableR Documentation

Converting a data.frame into a DecisionTable object

Description

This function converts data.frames into DecisionTable objects. This is a standard data representation in the RoughSets package.

Usage

SF.asDecisionTable(dataset, decision.attr = NULL, indx.nominal = NULL)

Arguments

dataset

data.frame that contains objects/instances and attributes/features in its rows and columns, respectively. See in Section Details.

decision.attr

an integer value representing the index position of the decision attribute. If this parameter is ignored, then the function will treat the data as an information system or newdata/test data. In other words, it is necessary to define the index of the decision attribute in order to construct a decision table (e.g. a training data set).

indx.nominal

a logical vector indicating nominal attributes in the data. If this parameter is not given, then the function will use a heuristic to guess which of the attributes are nominal. The following rules will be applied used:

  • an attribute contains character values or factors: it will be recognized as a nominal attribute.

  • an attribute contains integer or numeric values: it will be recognized as a numeric attribute.

  • indx.nominal: the indicated attributes will be considered as nominal.

Details

An object of the "DecisionTable" class adds a few attributes to a standard data.frame:

  • desc.attrs: a list containing the names of attributes and their range/possible symbolic values. There are two kinds of representation in this parameters which depend on whether the attributes are nominal or numeric, for example:

    • nominal attribute: a = c(1,2,3) means that the attribute a has values 1, 2, and 3.

    • numeric attribute: a = c(10, 20) means that the attribute a has values between 10 and 20.

  • nominal.attrs: a logical vector whose length equals the number of columns in the data. In this vector TRUE values indicate that the corresponding attribute is a nominal. For example: nominal.attrs = c(FALSE, TRUE, FALSE) means that the first and third attributes are numeric and the second one is nominal.

  • decision.attr: a numeric value representing the index of the decision attribute. It is necessary to define the index of the decision attribute in order to construct a proper decision system. If the value of decision.attr is NULL, the constructed object will correspond to an information system. It is strongly recommended to place the decision attribute as the last data column.

"DecisionTable" objects allow to use all methods of standard data.frame objects. The function SF.read.DecisionTable can be used to import data from a file and then construct DecisionTable object.

Value

An object of the "DecisionTable" class.

Author(s)

Andrzej Janusz

See Also

SF.read.DecisionTable, SF.applyDecTable.

Examples

################################################################
## Example : converting from datasets in data.frame
##            into decision table
################################################################
## Let use iris which is available in R be dataset
decision.table <- SF.asDecisionTable(dataset = iris, decision.attr = 5,
                  indx.nominal = 5)

RoughSets documentation built on May 29, 2024, 7:34 a.m.