Logistic regression – eval(family$initialize) : y values must be 0 <= y <= 1

You added the as.factor(dataCancer$Classification) in the script, but even if the dataset dataCancer is attached, a command like the one above does not transform the dataset variable Classification into a factor. It only returns a factor on the console.

Since you want to fit the model on the training dataset, you either specify

training_data$Classification <- as.factor(training_data$Classification)
classification_model <- glm(Classification ~ ., data = 
                           training_data, family = binomial) 

or use the as.factor function in the glm line code

classification_model <- glm(as.factor(Classification) ~ ., data = 
                           training_data, family = binomial)

Leave a Comment

tech