0

Im trying to increase the limit of trials parameter which is currently set to 100 in C50 package. I tried to do this using fix.

library(C50)
data(churn)
fix(C5.0.default)  # i change the maxtrials <- 200
treeModel <- C5.0(x = churnTrain[, -20], y = churnTrain$churn, trials = 150)

Then i get the following error when trials are less than 200.

could not find function "makeNamesFile"

I restart R and then try using fixInNamespace and changed the trials to 200.

fixInNamespace("C5.0.default", pos="package:C50")    
treeModel <- C5.0(x = churnTrain[, -20], y = churnTrain$churn, trials = 150)

The model works for trials below 100 but gives a following error for trials above 100. This is the standard error that C5.0 gives when user inputs the trials above 100.

number of boosting iterations must be between 1 and 100

I want to increase no of trials(boosting) for C5 model. How do i do that? This might be an implementation constraint but since xgboost can handle more than 100 boosting iteration there might be a way for C5 to handle this.

I am able to increase the iteration to more than 100 with fix call. But the thing is that i need to run all the R scripts that are in source version of C50 package. What can i do to avoid this. I tried installing C50 package from the source and gave this a try but it didnt work out.

Chirayu Chamoli
  • 2,076
  • 1
  • 17
  • 32
  • May I know, from where you got `CS50 package`? – Tony Montana Sep 21 '16 at 13:14
  • Please explain what "doesnt[sic!] work" means. `fixInNamespace("C5.0.default", pos="package:C50")` works just fine on my system. – Roland Sep 21 '16 at 13:22
  • https://stackoverflow.com/questions/24017429/c5-0-number-of-boosting-iterations-stops-early/36050855#36050855 – AidanGawronski Sep 21 '16 at 13:22
  • The generic is called `C5.0` not `C5`. How do you call the function? – Roland Sep 21 '16 at 13:45
  • I cannot reproduce this. Thus, you need to provide a reproducible example. – Roland Sep 21 '16 at 13:52
  • You do not need to uninstall. Just restart R. – Roland Sep 21 '16 at 13:55
  • I tried your example (first 4 lines, with the "fix" call). I cannot reproduce the problem, I got an error message saying that number of iterations must be between 1 and 200. Then I tried with "trials=180" and it worked - produced a result and gave no error. – Tomas Kalibera Sep 22 '16 at 07:32
  • It says "Number of boosting iterations: 180" and "cat(treeModel$output)" shows trials 0-179. – Tomas Kalibera Sep 22 '16 at 10:35
  • I have the same version. I get requested/actual 180. Frankly even though it seems to be working on my machine, editing code of package functions in sealed namespaces is not a good thing to do. It may be cleaner, yet more work indeed, to modify the package sources, build it and install it. – Tomas Kalibera Sep 22 '16 at 13:17

1 Answers1

0

I could get more than 100 trails by tweaking the source code from this link. You need to source the R files, then you can change the default no of trails to get more than 100 trials.

# Allow for more than 100 Boosting
setwd('Path to R files')
files <- list.files(pattern = "\\.R$")
lapply(files, source)
fix(C5.0.default)
Chirayu Chamoli
  • 2,076
  • 1
  • 17
  • 32