runRulesDrl: Apply a set of rule transformations to a data frame

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/Rdrools.R

Description

This function is the core of the Rdrools package. Rules are applied on an input data frame and the results are returned as the output of the function. The columns on which the rules need to be applied have to be provided explicitly. Additionally, the new columns that would be created based on the rules have to be provided explicitly as well. The rules engine picks up a row from the data frame, applies the transformation to it based on rules provided and saves the result in an output data frame.

Usage

1
runRulesDrl(rules.session, input.df)

Arguments

rules.session

a session of the rules engine created using the rulesSessionDrl function

input.df

a data frame consisting of a set of rows you wish to transform, and columns you wish to use in the transformation

Details

If you are not familiar with the Drools file format, please have a look at the references provided in the Rdrools. More details on how conflicting rules are resolved using either salience or the Reete algorithm are also present in the references.

Transformation policy Transformations are applied row by row, iteratively. That is to say, all inputs required for a rule transformation should be present in columns as a part of that row itself. Each row should be considered independent of another; all input values required for a transformation should be available in that row itself. The expectation from rules engines are often misplaced.

Column Mismatch Please make sure that the list of output columns provided through the output.columns parameter is exhaustive. Any additional column which is created through the rules transformation but is not present in the list would inhibit proper functioning. In most cases, an error should be thrown.

Value

output.df a data frame which is the result of transformations applied to the input data frame(input.df), the columns being the list provided through the output.columns parameter in rulesSessionDrl

Author(s)

Ashwin Raaghav <ashwin.raaghav@mu-sigma.com>

SMS Chauhan <sms.chauhan@mu-sigma.com>

See Also

runRulesDrl, Rdrools

Other Interface Functions to Drools: executeRulesOnDataset, rulesSessionDrl

Examples

1
2
3
4
5
6
7
library(Rdrools)
data(class)
data(rules)
input.columns<-c('name', 'class', 'grade', 'email')
output.columns<-c('address', 'subject', 'body')
rulesSession<-rulesSessionDrl(rules, input.columns, output.columns)
output.df<-runRulesDrl(rulesSession, class)

Example output

Loading required package: rJava
Loading required package: Rdroolsjars
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

Rdrools documentation built on May 2, 2019, 8:23 a.m.