Created
September 10, 2014 23:44
-
-
Save Athospd/ac43a5d6feb21791023b to your computer and use it in GitHub Desktop.
Esboço tosqueira de Cross-validation
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
library(glmnet) | |
X = model.matrix(rchp ~ 1 | |
+ jogo_do_brasil*(competicao | |
+ jogo_do_brasil | |
+ fase2 | |
+ jogo_do_n1 | |
+ jogo_da_italia | |
+ I(log(soma_ranking)) | |
+ I(log(produto_ranking)) | |
+ soma_ranking | |
+ soma_ranking:I(fase2%in%c("Final","Semi")) | |
+ produto_ranking | |
+ alcance_habitual | |
+ I(alcance_habitual^2) | |
+ alcance_habitual | |
+ alcance_habitual:jogo_da_italia | |
+ I(log(alcance_habitual)) | |
+ I(alcance_habitual^3) | |
+ I(log(produto_ranking)*log(soma_ranking)))^4, dados)[,-1] | |
cv = cv.glmnet(x = X[treino & !outlier, ], | |
y = y[treino & !outlier], | |
alpha = 1, | |
family="gaussian", | |
nfolds = 10, | |
type.measure = "mse") | |
plot(cv) | |
bestLambda = cv$lambda.min | |
fit <- glmnet(x = X[treino & !outlier, ], | |
y = y[treino & !outlier], | |
alpha = 1, | |
lambda = bestLambda, | |
thresh = 1e-12, | |
family="gaussian") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment