data("iris")
classifier <- RCAR(Species ~ ., iris)
classifier
# inspect the rule base sorted by the larges class weight
inspect(sort(classifier$rules, by = "weight"))
# make predictions for the first few instances of iris
predict(classifier, head(iris))
table(pred = predict(classifier, iris), true = iris$Species)
# plot the cross-validation curve as a function of lambda and add a
# red line at lambda.1se used to determine lambda.
plot(classifier$model$cv)
abline(v = log(classifier$model$cv$lambda.1se), col = "red")
# plot the coefficient profile plot (regularization path) for each class
# label. Note the line for the chosen lambda is only added to the last plot.
# You can manually add it to the others.
plot(classifier$model$reg_model, xvar = "lambda", label = TRUE)
abline(v = log(classifier$model$cv$lambda.1se), col = "red")
#' inspect rule 11 which has a large weight for class virginica
inspect(classifier$model$all_rules[11])
Run the code above in your browser using DataLab