I am trying to complete an assignment for one of my courses and the goal of this assignment is to implement the library(caret) into RStudio and insert the following code:
However, when I copy and paste this code, I get the message "Error: object 'intrain' not found" and "Error: object 'training' not found". The same error continues for the assignments of training and testing. Any help would be appreciated at this point. Thank you!
The arrows are helpful, but the rest of the code doesn't allow for continuation. I also have tried this code, and it says the following:
fitted.results <- predict(LogModel,newdata=testing,type='response')
Error in predict(LogModel, newdata = testing, type = "response") :
object 'LogModel' not found
Customer churn occurs when customers stop doing business with a company. Retaining existing customers is less expensive than it is to acquire new customers and hence, building a good predictive model for customer churn is of importance to many companies. Download the dataset Telco.customer.csv . Through this dataset, we attempt to predict behavior to retain customers using logistic regression.
Now, let's examine how the model fits using the following code.
testing$Churn - as.character(testing$Churn) testing$Churn[testing$Churn=="No"] - "0" testing$Churn[testing$Churn=="Yes"] - "1" fitted.results - predict(LogModel,newdata=testing,type='response') fitted.results - ifelse(fitted.results 0.5,1,0) misClasificError - mean(fitted.results != testing$Churn) print(paste('Logistic Regression Accuracy',1-misClasificError))
This provides the accuracy of the model.