predict.RuleSetRST {RoughSets} | R Documentation |
Prediction of decision classes using rule-based classifiers.
Description
The prediction method for objects inheriting from the RuleSetRST
class.
Usage
## S3 method for class 'RuleSetRST'
predict(object, newdata, ...)
Arguments
object |
an object inheriting from the |
newdata |
an object inheriting from the |
... |
additional parameters for a rule voting strategy. It can be applied only to the methods which classify
new objects by voting. Currently, those methods include
A custom function passed using the |
Value
A data.frame with a single column containing predictions for objects from newdata
.
Author(s)
Andrzej Janusz
See Also
Rule induction methods implemented within RST include: RI.indiscernibilityBasedRules.RST
,
RI.CN2Rules.RST
, RI.LEM2Rules.RST
and RI.AQRules.RST
.
For details on rule induction methods based on FRST see RI.GFRS.FRST
and RI.hybridFS.FRST
.
Examples
##############################################
## Example: Classification Task
##############################################
data(RoughSetData)
wine.data <- RoughSetData$wine.dt
set.seed(13)
wine.data <- wine.data[sample(nrow(wine.data)),]
## Split the data into a training set and a test set,
## 60% for training and 40% for testing:
idx <- round(0.6 * nrow(wine.data))
wine.tra <-SF.asDecisionTable(wine.data[1:idx,],
decision.attr = 14,
indx.nominal = 14)
wine.tst <- SF.asDecisionTable(wine.data[(idx+1):nrow(wine.data), -ncol(wine.data)])
true.classes <- wine.data[(idx+1):nrow(wine.data), ncol(wine.data)]
## discretization:
cut.values <- D.discretization.RST(wine.tra,
type.method = "unsupervised.quantiles",
nOfIntervals = 3)
data.tra <- SF.applyDecTable(wine.tra, cut.values)
data.tst <- SF.applyDecTable(wine.tst, cut.values)
## rule induction from the training set:
rules <- RI.LEM2Rules.RST(data.tra)
## predicitons for the test set:
pred.vals1 <- predict(rules, data.tst)
pred.vals2 <- predict(rules, data.tst,
votingMethod = X.laplace)
pred.vals3 <- predict(rules, data.tst,
votingMethod = X.rulesCounting)
## checking the accuracy of predictions:
mean(pred.vals1 == true.classes)
mean(pred.vals2 == true.classes)
mean(pred.vals3 == true.classes)