Skip to main content
edited body
Source Link

So I believe you're building a model on the binary outcome {lose, win}:= {0, 1}, correct?

I'd recommend just using a one-hot-encoding or a sparse matrix to store these inputs, then the model should run just fine. This is very straightforward in R (sparse.model.matrix) or Python (pd.get_dummies(sparse=True)).

Here's a quick demo of how to builtbuild a sparse matrix in R out of sampled categories and select a subset of them with at least 5 observations.

library(MASS)
require(glmnet)
n <- 1000
x1 <- sample(paste(letters,1), n, replace=T)
x2 <- sample(paste(letters,2), n, replace=T)
x3 <- paste(x1,x2,sep='-')
xdf <- data.frame(x1,x2,x3)
xs <- sparse.model.matrix(~.-1, data=xdf)
vars <- colnames(xs)
colsmry <- colSums(xs)
colsubset <- colsmry > 4
xs_ss <- xs[,vars[colsubset]]
dim(xs)
dim(xs_ss)

So I believe you're building a model on the binary outcome {lose, win}:= {0, 1}, correct?

I'd recommend just using a one-hot-encoding or a sparse matrix to store these inputs, then the model should run just fine. This is very straightforward in R (sparse.model.matrix) or Python (pd.get_dummies(sparse=True)).

Here's a quick demo of how to built a sparse matrix in R out of sampled categories and select a subset of them with at least 5 observations.

library(MASS)
require(glmnet)
n <- 1000
x1 <- sample(paste(letters,1), n, replace=T)
x2 <- sample(paste(letters,2), n, replace=T)
x3 <- paste(x1,x2,sep='-')
xdf <- data.frame(x1,x2,x3)
xs <- sparse.model.matrix(~.-1, data=xdf)
vars <- colnames(xs)
colsmry <- colSums(xs)
colsubset <- colsmry > 4
xs_ss <- xs[,vars[colsubset]]
dim(xs)
dim(xs_ss)

So I believe you're building a model on the binary outcome {lose, win}:= {0, 1}, correct?

I'd recommend just using a one-hot-encoding or a sparse matrix to store these inputs, then the model should run just fine. This is very straightforward in R (sparse.model.matrix) or Python (pd.get_dummies(sparse=True)).

Here's a quick demo of how to build a sparse matrix in R out of sampled categories and select a subset of them with at least 5 observations.

library(MASS)
require(glmnet)
n <- 1000
x1 <- sample(paste(letters,1), n, replace=T)
x2 <- sample(paste(letters,2), n, replace=T)
x3 <- paste(x1,x2,sep='-')
xdf <- data.frame(x1,x2,x3)
xs <- sparse.model.matrix(~.-1, data=xdf)
vars <- colnames(xs)
colsmry <- colSums(xs)
colsubset <- colsmry > 4
xs_ss <- xs[,vars[colsubset]]
dim(xs)
dim(xs_ss)
added 565 characters in body
Source Link

So I believe you're building a model on the binary outcome {lose, win}:= {0, 1}, correct?

I'd recommend just using a one-hot-encoding or a sparse matrix to store these inputs, then the model should run just fine. This is very straightforward in R (sparse.model.matrix) or Python (pd.get_dummies(sparse=True)).

Here's a quick demo of how to built a sparse matrix in R out of sampled categories and select a subset of them with at least 5 observations.

library(MASS)
require(glmnet)
n <- 1000
x1 <- sample(paste(letters,1), n, replace=T)
x2 <- sample(paste(letters,2), n, replace=T)
x3 <- paste(x1,x2,sep='-')
xdf <- data.frame(x1,x2,x3)
xs <- sparse.model.matrix(~.-1, data=xdf)
vars <- colnames(xs)
colsmry <- colSums(xs)
colsubset <- colsmry > 4
xs_ss <- xs[,vars[colsubset]]
dim(xs)
dim(xs_ss)

So I believe you're building a model on the binary outcome {lose, win}:= {0, 1}, correct?

I'd recommend just using a one-hot-encoding or a sparse matrix to store these inputs, then the model should run just fine. This is very straightforward in R (sparse.model.matrix) or Python (pd.get_dummies(sparse=True)).

So I believe you're building a model on the binary outcome {lose, win}:= {0, 1}, correct?

I'd recommend just using a one-hot-encoding or a sparse matrix to store these inputs, then the model should run just fine. This is very straightforward in R (sparse.model.matrix) or Python (pd.get_dummies(sparse=True)).

Here's a quick demo of how to built a sparse matrix in R out of sampled categories and select a subset of them with at least 5 observations.

library(MASS)
require(glmnet)
n <- 1000
x1 <- sample(paste(letters,1), n, replace=T)
x2 <- sample(paste(letters,2), n, replace=T)
x3 <- paste(x1,x2,sep='-')
xdf <- data.frame(x1,x2,x3)
xs <- sparse.model.matrix(~.-1, data=xdf)
vars <- colnames(xs)
colsmry <- colSums(xs)
colsubset <- colsmry > 4
xs_ss <- xs[,vars[colsubset]]
dim(xs)
dim(xs_ss)
Source Link

So I believe you're building a model on the binary outcome {lose, win}:= {0, 1}, correct?

I'd recommend just using a one-hot-encoding or a sparse matrix to store these inputs, then the model should run just fine. This is very straightforward in R (sparse.model.matrix) or Python (pd.get_dummies(sparse=True)).