Created
February 7, 2019 03:39
-
-
Save FthrsAnalytics/a36f4f1e8fd2d1bc2f1b009d00ced99d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##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