質問

I have a small question about the J48 from Weka. I run this algorithm from R, using RWeka. Probably an easy solution, but i can't seem to find it on the web. A very small example:

require(RWeka)
Attr1 <- as.factor(c('0302','0302','0320'))
Attr2 <- as.factor(c('2','1','1'))
Target <- as.factor(c('target1','target2','target3'))
input <- data.frame(Attr1,Attr2,Target)
J48( Target ~ Attr1 + Attr2 , data= input, control= Weka_control(W=list(J48,m=1,U=T)))

I want the fit made by the J48 algorithm to fit on the data. This means I put the minimal items in the leafs to 1 and I dont prune the tree. I get the following output:

J48 pruned tree
------------------
: target1 (3.0/2.0)
Number of Leaves  :     1
Size of the tree :  1

Why doesn't it make Attr1 = 0320 -> target3 or Attr2 = 2 -> target1?

役に立ちましたか?

解決

I have simplified your code slightly and identified the problem. The option for the minimum number of leaves is set with "M", not "m". I discovered this by first querying the possible options

WOW(J48)  

The pertinent output of which says:

-M <minimum number of instances>
    Set minimum number of instances per leaf.  (default 2)

The important part of your code then becomes:


J48( Target ~ Attr1 + Attr2 , data= input, control= Weka_control(M=1,U=TRUE))

J48 unpruned tree
------------------

Attr1 = 0302
|   Attr2 = 1: target2 (1.0)
|   Attr2 = 2: target1 (1.0)
Attr1 = 0320: target3 (1.0)

Number of Leaves  :     3

Size of the tree :  5
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top