Skip to content

Instantly share code, notes, and snippets.

@FthrsAnalytics
Created February 7, 2019 03:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FthrsAnalytics/a36f4f1e8fd2d1bc2f1b009d00ced99d to your computer and use it in GitHub Desktop.
Save FthrsAnalytics/a36f4f1e8fd2d1bc2f1b009d00ced99d to your computer and use it in GitHub Desktop.
##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