How do you plot a CostSensitiveClassifier tree in R?

前端 未结 1 1723
情书的邮戳
情书的邮戳 2020-12-20 00:14

In this case I\'m using the RWeka package and J48 within the Cost Sensitive Classifier function. I know with the package \"party\" I can plot a normal J48 tree, but not sure

相关标签:
1条回答
  • 2020-12-20 00:57

    Actually, it turns out to be pretty easy. Try

    library(RWeka)
    library(party)
    library(partykit)
    
    
    csc <- CostSensitiveClassifier(Species ~ ., data = iris, 
    control = Weka_control(`cost-matrix` = matrix(c(0,10, 0, 0, 0, 0, 0, 10, 0), 
    ncol = 3), 
    W = "weka.classifiers.trees.J48", 
    M = TRUE))
    
    plot(as.party.Weka_tree(csc))
    

    That gives me

    CostSensitiveClassifier plot

    The problem is, this model reports it's class as

    > class(csc)
    [1] "CostSensitiveClassifier" "Weka_meta"     "Weka_classifier"  
    

    and there is no method for those classes. However, there is one for "Weka_tree" which just calls as.party.Weka_tree and plots the result. I must admit I don't know the differences between a CostSensitiveClassifier tree and a J48 tree so I hope this plot is an accurate representation.

    0 讨论(0)
提交回复
热议问题