predict.CBARuleModel {arc}R Documentation

Apply Rule Model

Description

Method that matches rule model against test data.

Usage

## S3 method for class 'CBARuleModel'
predict(
  object,
  data,
  discretize = TRUE,
  outputFiringRuleIDs = FALSE,
  outputConfidenceScores = FALSE,
  confScoreType = "ordered",
  positiveClass = NULL,
  ...
)

Arguments

object

a CBARuleModel class instance

data

a data frame with data

discretize

boolean indicating whether the passed data should be discretized using information in the passed @cutp slot of the ruleModel argument.

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

A vector with predictions.

See Also

cbaIris

Examples

  allData <- datasets::iris[sample(nrow(datasets::iris)),]
  trainFold <- allData[1:100,]
  testFold <- allData[101:nrow(allData),]
  #increase for more accurate results in longer time
  target_rule_count <- 1000
  classAtt <- "Species"
  rm <- cba(trainFold, classAtt, list(target_rule_count = target_rule_count))
  prediction <- predict(rm, testFold)
  acc <- CBARuleModelAccuracy(prediction, testFold[[classAtt]])
  message(acc)

[Package arc version 1.3 Index]