Path: blob/master/lessons/lesson_08/code/solution-code/solution-code-8.ipynb
1904 views
Guided Practice: Logit Function and Odds
The above makes it more clear that a schools rank as it approaches 4 decreases the odds of getting admitted. The accuracy of the model with all features (removing one rank) is ~70%.
Below is some code to walk through confusion matrices. It'll be useful for working through the Titanic problem.
Below the ROC curve is based on various thresholds: it shows with a false positive rate (x-axis) ~0, it also expects a true positive rate (y-axis) ~0 (the same, ish, for the top right hand of the figure).
The second chart, which does not play with thesholds, shows the one true TPR and FPR point, joined to 0,0 and 1,1.
The first chart will be more effective as you compare models and determine where the decision line should exist for the data. The second simplifies the first in case this idea of thresholds is confusing.
Finally, you can use the roc_auc_score
function to calculate the area under these curves (AUC).
Note: sklearn also has logistic regression:
Titanic Problem
** Goals **
Spend a few minutes determining which data would be most important to use in the prediction problem. You may need to create new features based on the data available. Consider using a feature selection aide in sklearn. But a worst case scenario; identify one or two strong features that would be useful to include in the model.
Spend 1-2 minutes considering which metric makes the most sense to optimize. Accuracy? FPR or TPR? AUC? Given the business problem (understanding survival rate aboard the Titanic), why should you use this metric?
Build a tuned Logistic model. Be prepared to explain your design (including regularization), metric, and feature set in predicting survival using the tools necessary (such as a fit chart).
Teaching Notes
Note this is just one approach optimized for Area Under the Curve.
Age will need some work (since it is missing for a significant portion), and other data cleanup simplifies the data problem a little.