I am using library(RWeka) and running the JRip function on a data set. Does anybody know of a way of accessing the rules result set programmatically so I can access each rule individually?
Here is an example for illustrative purposes only:
> library(datasets)
> head(npk)
block N P K yield
1 1 0 1 1 49.5
2 1 1 1 0 62.8
3 1 0 0 0 46.8
4 1 1 0 1 57.0
5 2 1 0 0 59.8
6 2 1 1 1 58.5
> tree_rip <- JRip(block ~ ., data = npk)
> tree_rip
JRIP rules:
===========
(yield <= 48.8) => block=4 (5.0/2.0)
(yield <= 52) => block=5 (4.0/1.0)
=> block=3 (15.0/11.0)
Number of Rules : 3
I would like to access the results in a dataframe/table fashion. The closest is retrieving a single blob string in the following manner:
> tree_rip$classifier
[1] "Java-Object{JRIP rules:\n===========\n\n(yield <= 48.8) => block=4 (5.0/2.0)\n(yield <= 52) => block=5 (4.0/1.0)\n => block=3 (15.0/11.0)\n\nNumber of Rules : 3\n}"
I need something that would allow me to get each result separately, just as it is printed when I call tree_rip
, so I can not only get the length of rules found, but access them one by one.
At the very least something like this (but ideally accessing each result variable separately for every row):
[1] (yield <= 48.8) => block=4 (5.0/2.0)
[2] (yield <= 52) => block=5 (4.0/1.0)
...
thanks!