Skip to content

Instantly share code, notes, and snippets.

@joshkyh
Forked from mfmakahiya/predict.r
Created August 15, 2019 00:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshkyh/04cc3d04139a537d445184c023e75c4f to your computer and use it in GitHub Desktop.
Save joshkyh/04cc3d04139a537d445184c023e75c4f to your computer and use it in GitHub Desktop.
# Predict the test set using the model
pred_lasso = predict(glmmod, test_sparse, type="response", s=best.lambda)
pred_lasso
# Apply a threshold
new_pred_lasso = ifelse(pred_lasso >= 0.5, 1, 0)
new_pred_lasso = data.frame(new_pred_lasso)
data_lasso = cbind(test[,2], new_pred_lasso)
names(data_lasso) = c("actual", "pred")
xtab_lasso = table(data_lasso$actual, data_lasso$pred)
cm_lasso = confusionMatrix(xtab_lasso)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment