Here's the script:
dk <- read.csv("nflredux")
dk <- lapply(split(dk, dk$Position), function(x) x[sample(15), ])
dk <- dk[c("G","W","C","D","U")]
15*choose(15,3)*choose(15,2)*choose(4,2)*4
rows <- list(t(1:15), combn(15,3), combn(15,2), combn(4,2), t(1:4))
dims <- sapply(rows, NCOL)
inds <- expand.grid(mapply(`:`, 1, dims))
dim(inds)
extract <- function(ind) {
g <- inds[ind,]
do.call(rbind, lapply(1:5, function(i) dk[[i]][rows[[i]][,g[[i]]], ]))
}
extract(1)
win <- c(0, 0, 0)
for(i in 1:17000000)
{
extracted <- extract(i)
#print(i)
#print(sum(extracted$Price))
if(sum(extracted$Price) < 50000){
if(win[3] < sum(extracted$Points)){
#print(sum(extracted$Points))
win <- c(i, sum(extracted$Price), sum(extracted$Points))
print(win)
print(extracted)
}
}
}
print(win)
Also when I let the hockey script run for less than a few hours the team it gave me did very poorly...like dead last poorly. I would share the results but one of the players had an injury and I subbed him and the UTIL player out based on a best guess. I mean is this telling of this particular use of math to solve this particular problem. Not using the full data set. Not using the best results. Then subbing players out. I don't know, probably not. I'm going to add some filtering and make it run parallel so the results finish faster. As well as take a look at implementing Normal Distribution to determine best outcomes and weight towards those, regarding strong defense and aggression.
And again I don't want to steal credit for the most part, currently this is a script from here.
I'll have another update on DraftKings / DFS math on Friday, but I'll have other posts before then as well.
No comments:
Post a Comment