0

I would like to use C5.0 but with few error this is the code:

library(modeldata)
data(credit_data)
set.seed(2411)
in_train <- sample(1:nrow(credit_data), size = 3000)
train_data <- credit_data[ in_train,]
test_data  <- credit_data[-in_train,]
install.packages("C50")
library(C50)
tree_mod <- C5.0(x = train_data[, vars], y = train_data$Status)
tree_mod

I get the following error Error: package or namespace load failed for ‘C50’ in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]):


Error in C5.0(x = train_data[, vars], y = train_data$Status) : 
  could not find function "C5.0"

zachi
  • 511
  • 4
  • 13
  • 2
    Your code and the data provided in the website is not matching. – UseR10085 Dec 30 '22 at 11:41
  • Try installing the development version using the following code: `library("devtools"); install_github("topepo/C5.0");` – Quinten Dec 30 '22 at 11:41
  • https://www.kaggle.com/code/samueljoseph502/risky-bank-loans/data – zachi Dec 30 '22 at 11:57
  • This is the match site to the code – zachi Dec 30 '22 at 11:58
  • tried library("devtools"); install_github("topepo/C5.0") , it didnt work – zachi Dec 30 '22 at 12:07
  • Your code here doesn't actually load the package you're asking about (C5.0). Did you do that and just not include it in your question? – camille Dec 30 '22 at 16:04
  • I have the install.packages("C50") before , but now I added it to the code – zachi Dec 30 '22 at 16:30
  • Try restarting your R session. It isn't really clear from your question, but that's the type of error that can come after installing packages. Have you read through the package docs and been able to run their code? – camille Dec 30 '22 at 17:56
  • I tried to restart but with no success, this is the error for library (C50) Error: package or namespace load failed for ‘C50’ in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]): there is no package called ‘Cubist’ In addition: Warning message: – zachi Dec 30 '22 at 19:15
  • Your error message is telling you you're missing a package. Did you install that package as well? – camille Dec 30 '22 at 19:57
  • I installed the C50, this is still what I get : Error: package or namespace load failed for ‘C50’ in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]): there is no package called ‘Cubist’ – zachi Dec 31 '22 at 04:09
  • ’ AND when trying to install Cubist I get Error in download.file(url, destfile, method, mode = "wb", ...) : cannot open URL 'http://cran.rstudio.com/bin/windows/contrib/4.2/Cubist_0.4.1.zip' – zachi Dec 31 '22 at 04:24

1 Answers1

0

This solved my problem remotes::install_github("topepo/Cubist", upgrade = FALSE)

zachi
  • 511
  • 4
  • 13