Jguytibu
Jguytibu
5 Regression 167
5.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
5.2 Linear Regression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
5.3 Analysis via Linear Models . . . . . . . . . . . . . . . . . . . . . . . . . 171
5.3.1 Parameter Estimation . . . . . . . . . . . . . . . . . . . . . . . . 171
5.3.2 Model Selection and Prediction . . . . . . . . . . . . . . . . . . . 172
5.3.3 Cross-Validation and Predictive Residual Sum of Squares . . . . . 173
5.3.4 In-Sample Risk and Akaike Information Criterion . . . . . . . . . 175
5.3.5 Categorical Features . . . . . . . . . . . . . . . . . . . . . . . . 177
5.3.6 Nested Models . . . . . . . . . . . . . . . . . . . . . . . . . . . 180
5.3.7 Coefficient of Determination . . . . . . . . . . . . . . . . . . . . 181
5.4 Inference for Normal Linear Models . . . . . . . . . . . . . . . . . . . . 182
5.4.1 Comparing Two Normal Linear Models . . . . . . . . . . . . . . 183
5.4.2 Confidence and Prediction Intervals . . . . . . . . . . . . . . . . 186
5.5 Nonlinear Regression Models . . . . . . . . . . . . . . . . . . . . . . . . 188
5.6 Linear Models in Python . . . . . . . . . . . . . . . . . . . . . . . . . . 191
5.6.1 Modeling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
5.6.2 Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
5.6.3 Analysis of Variance (ANOVA) . . . . . . . . . . . . . . . . . . 196
Contents ix
7 Classification 251
7.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251
7.2 Classification Metrics . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253
7.3 Classification via Bayes’ Rule . . . . . . . . . . . . . . . . . . . . . . . 257
7.4 Linear and Quadratic Discriminant Analysis . . . . . . . . . . . . . . . . 259
7.5 Logistic Regression and Softmax Classification . . . . . . . . . . . . . . 266
7.6 K-Nearest Neighbors Classification . . . . . . . . . . . . . . . . . . . . . 268
7.7 Support Vector Machine . . . . . . . . . . . . . . . . . . . . . . . . . . . 269
7.8 Classification with Scikit-Learn . . . . . . . . . . . . . . . . . . . . . . . 277
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279
Bibliography 496
Index 505
P REFACE