Ask code for the plot of classification of iris dataset?

I am learning this website:

But this website doesn't have R code for this figure. How to replicate this figure below?

It would be something like this -- I have made the models up myself.


split <- initial_split(iris)

test_df <- testing(split)
train_df <- training(split)

fit1 <- ranger(Species ~ Petal.Length, data = test_df)

new_df <- test_df %>% 
  mutate(pred = predict(fit1, test_df)$predictions,
         model_correct = pred == Species)

ggplot(new_df, aes(Petal.Length, Sepal.Length, colour = model_correct, shape = Species)) +

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.