I found this document on the web: https://www.erpublication.org/admin/vol_issue1/upload%20Image/IJETR032129.pdf
There it uses on page 4 to build a decision tree with RWeka package and J48 function in R. In his example, he has both numerical and categorical values.
So, I made a test, with just on column trying to predict the other. Here is a sample:
VALUE CHURNED_F
2 1
2 0
2 0
2 0
2 0
1 0
This is my code:
m2 <- J48(`CHURNED_F` ~ ., data = head(train[, -c(1)]))
But I get this error:
Error in .jcall(o, "Ljava/lang/Class;", "getClass") :
weka.core.UnsupportedAttributeTypeException: weka.classifiers.trees.j48.C45PruneableClassifierTree: Cannot handle numeric class!
I don't understand the error, first of all it is a categorical class. Second, in the example in the document it perfectly uses both categorical and numerical columns.
How can I get this to work?
J48 requires the class be categorical, or in the case of R, a factor. I believe that your "Churned_F" variable is numeric. You can check what type your variables are by using the structure function:
str(train)
The code below allows you to build a J48 tree. Here I ensure "CHURNED_F" is a factor.
library(RWeka)
train <- data.frame(VALUE = c(2,2,2,2,2,1), CHURNED_F = factor(c(1,0,0,0,0,0)))
m2 <- J48(CHURNED_F ~., data = train)