14.7. Chapter Exercise#
Apply the key ideas from this chapter in the connected task below. Work in your own notebook or local project. Keep your implementation, reasoning, and verification results together.
14.7.1. Evaluate a classifier for a decision#
Reuse the chapter’s real shopping-session data and define the target, features, baseline, and training/evaluation separation.
Compare scaled nearest neighbors with logistic regression using preprocessing fitted only on training data. Choose k or a decision threshold using the chapter’s validation approach.
Report a confusion matrix, accuracy, precision, recall, and an explicit error-cost comparison on held-out data. Explain which classifier you would use and why the highest accuracy need not give the best decision.
Return to the chapter lessons as needed: Classification, Nearest Neighbors, Training, Testing, and Accuracy, Nearest Neighbors with scikit-learn, Evaluating Classifiers, Logistic Regression.