A classifier assigns observations to predefined categories, such as labels or group membership, rather than predicting a numeric response. section 4.1 section 1.0
A practical classification workflow includes:
- Estimate a probability for each observation from a fitted model. section 5.2.3
- Convert probabilities into binary predictions with a decision threshold. section 5.2.3
- Adjust the cutoff when false positives and false negatives have different costs, then evaluate predictive power with classification metrics. section 5.2.3
Raisin classification
A logistic regression uses MinorAxisLength and Perimeter to estimate whether Class equals 1. A probability of 0.698821 becomes prediction 1 under the default 0.50 cutoff. section 5.2.3
>>> import numpy as np >>> raisins_subset['prediction'] = (raisins_subset['probability'] \ >>> .apply(lambda x: 0 if x < 0.5 else 1))
Inspect the Python transformation that maps probabilities below 0.5 to 0 and all other probabilities to 1. section 5.2.3






























