How to read and get the C5.0 Model out of R

439 Views Asked by At

I've searched and search but can't find the answer. I have a c5_model trained and ready but I needed to do 100 trails to get it working to the level I want it to. But I'm stuck on trying to get it out of the model in R. I have done a summary but how do I get the decision tree out. Which trial do I want to use? enter image description here

Update:

I'm building the model by doing the following

control <- trainControl(method = "repeatedcv", 
                    number = 5, 
                    repeats = 3, 
                    classProbs = TRUE, 
                    summaryFunction = twoClassSummary)
grid <- expand.grid( .winnow = c(FALSE), 
                 .trials=100, 
                 .model="tree" )
c5_model <- train(HasFraud ~ .,data = train, method = "C5.0",trControl = control,metric = "ROC",tuneGrid = grid,verbose = FALSE)

Is this the wrong method to train the model?

1

There are 1 best solutions below

0
On

An object of class C5.0 has a number of elements, as described in the help file you can pull up with ?C50::C5.0.default. One of those elements is tree. If you've assigned the output of a call to C5.0() to a value, say model, you can extract any of its elements using the $ operator. For example:

model <- C5.0(<the call you made that generated the model>)
model$tree