Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
##Load Packages
library(tidyverse)
library(rpart)
library(rpart.plot)
##Manipulate
model_data <- dataset
##Create Categorical
pp90_bin <- cut(model_data$points_per_90,
breaks = c(0, 2.5, 5.5, 100),
labels = c("Low", "Medium", "High"),
right = FALSE,
include.lowest = TRUE
)
model_data$pp90_bin <- pp90_bin
##Decision Tree
fantasy_tree <- rpart(pp90_bin ~ now_cost + selected_by_percent + goals_scored + assists + clean_sheets + pos, data = model_data, method = "class")
##visualize
rpart.plot(fantasy_tree)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.