predict.qCBARuleModel: Aplies qCBARuleModel

Description Usage Arguments Value See Also Examples

View source: R/rMARC.R

Description

Applies qcba rule model on provided data. Automatically detects whether one-rule or multi-rule classification is used

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## S3 method for class 'qCBARuleModel'
predict(
  object,
  newdata,
  testingType,
  loglevel = "WARNING",
  outputFiringRuleIDs = FALSE,
  outputConfidenceScores = FALSE,
  confScoreType = "ordered",
  positiveClass = NULL,
  ...
)

Arguments

object

qCBARuleModel class instance

newdata

data frame with data

testingType

either mixture for multi-rule classification or firstRule for one-rule classification. Applicable only when model is loaded from file.

loglevel

logger level from java.util.logging

outputFiringRuleIDs

if set to TRUE, instead of predictions, the function will return one-based IDs of rules used to classify each instance (one rule per instance).

outputConfidenceScores

if set to TRUE, instead of predictions, the function will return confidences of the firing rule

confScoreType

applicable only if 'outputConfidenceScores=TRUE', possible values 'ordered' for confidence computed only for training instances reaching this rule, or 'global' for standard rule confidence computed from the complete training data

positiveClass

This setting is only used if 'outputConfidenceScores=TRUE'. It should be used only for binary problems. In this case, the confidence values are recalculated so that these are not confidence values of the predicted class (default behaviour of 'outputConfidenceScores=TRUE') but rather confidence values associated with the class designated as positive

...

other arguments (currently not used)

Value

vector with predictions.

See Also

qcba

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
allData <- datasets::iris[sample(nrow(datasets::iris)),]
trainFold <- allData[1:100,]
testFold <- allData[101:nrow(datasets::iris),]
rmCBA <- cba(trainFold, classAtt="Species")
rmqCBA <- qcba(cbaRuleModel=rmCBA, datadf=trainFold)
print(rmqCBA@rules)
prediction <- predict(rmqCBA,testFold)
acc <- CBARuleModelAccuracy(prediction, testFold[[rmqCBA@classAtt]])
message(acc)
firingRuleIDs <- predict(rmqCBA,testFold,outputFiringRuleIDs=TRUE)
message("The second instance in testFold was classified by the following rule")
message(rmqCBA@rules[firingRuleIDs[2],1])
message("The second instance is")
message(testFold[2,])

qCBA documentation built on Nov. 19, 2020, 9:07 a.m.