View source: R/rule_based_assessment.R
rule_based_assessment | R Documentation |
Provides a stats::glm type wrapper around user-defined function specifying rules for a classification function.
rule_based_assessment(formula, data, rules)
formula |
an object of class stats::formula, should specify the target and all predictors used in the rule function as a linear combination, e.g. target ~ rule1 + rule2. |
data |
a dataframe containing the variables and target of the rule function. |
rules |
a function implementing the rules-based classification. |
an object class similar to "glm" that can be used with a 'predict' method.
d <- data.frame( y=c("apple", "apple", "not apple", "not apple"), shape=c("round", "round", "square", "round"), colour=c("green", "red", "green", "purple") ) f <- function(shape, colour) { ifelse(shape == "round" & colour %in% c("green", "red"), "apple", "not apple") } apple_classifier <- rule_based_assessment(y ~ shape + colour, d, f) predict(apple_classifier, newdata=data.frame(shape="round", colour="indigo"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.