Skip to content

Instantly share code, notes, and snippets.

@mfmakahiya
Created July 30, 2019 07:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mfmakahiya/ed14cba5bf11a4ec6f43c1256d281786 to your computer and use it in GitHub Desktop.
Save mfmakahiya/ed14cba5bf11a4ec6f43c1256d281786 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