I'm trying to plot J48 decision tree based on string values attributes and predict the target variable(categorical), I have seen many examples plotting decision tree based on numerical values but i haven't come across based on strings.
Here is sample data set, J48 decision tree works fine.
library(RWeka)
library(party)
MyData2 <- read.csv(file="iris.csv", header=TRUE, sep=",")
m3 <- J48(species~ ., data = MyData2)`enter code here`
if(require("party", quietly = TRUE)) plot(m3)
sepal_length sepal_width petal_length petal_width species
5.1 3.5 1.4 0.2 setosa
4.9 3 1.4 0.2 setosa
7 3.2 4.7 1.4 versicolor
6.4 3.2 4.5 1.5 versicolor
6.3 3.3 6 2.5 virginica
5.8 2.7 5.1 1.9 virginica
If i rename the header sepal_length, sepal_width and to sepal_color and have values as "white", "black" with different combinations of colors to setosa, versicolor and virginca, how do i plot decision tree and predict the target species value.
Suppose if i have data set like below,
sepal_color sepal_color petal_color petal_color species
white black white black setosa
white yellow white yellow versicolor
green brown green brown virginica