-
Notifications
You must be signed in to change notification settings - Fork 0
/
00 runner.R
61 lines (54 loc) · 1.56 KB
/
00 runner.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
rm(list = ls())
gc()
# Dependencies:
library(tidyverse)
library(cfbfastR)
library(oddsapiR)
library(janitor)
library(stringdist)
library(magrittr)
library(xgboost)
library(tidymodels)
library(Ckmeans.1d.dp)
#Set Directory to script path.
runnerPath <- dirname(rstudioapi::getActiveDocumentContext()$path)
setwd(runnerPath)
# Global Variables
year = 2023
runModels = TRUE
# Make downstream directory
if(!dir.exists("downstream")){
dir.create("downstream")
}
# Make downstream directory and move crosswalk.
# If the file is nowhere to be found - throw an error
# If the file is in the same folder as runner - move it to downstream
# If the file is already in downstream - do nothing
if(!file.exists("cbsTeamXwalk2023.txt")){
if(!file.exists("downstream/cbsTeamXwalk2023.txt")){
stop("Please place 'cbsTeamXwalk2023.txt' in the runner.R filepath")
}
}else{
if(!file.exists("downstream/cbsTeamXwalk2023.txt")){
file.copy(from = "cbsTeamXwalk2023.txt", to = "downstream/cbsTeamXwalk2023.txt")
file.remove("cbsTeamXwalk2023.txt")
}
}
if(!file.exists("spXwalk.txt")){
if(!file.exists("downstream/spXwalk.txt")){
stop("Please place 'spXwalk.txt' in the runner.R filepath")
}
}else{
if(!file.exists("downstream/spXwalk.txt")){
file.copy(from = "spXwalk.txt", to = "downstream/spXwalk.txt")
file.remove("spXwalk.txt")
}
}
# Run files.
source("01 get games bets and ranks.R")
source("02 derive variables for models.R")
if(runModels){
source("model/01 xgb.R")
source("model/02 adjust prediction and save.R")
}
source("03 merge logos to condensed data.R")