Logistic regression — classify a CSV from linear scores
Logistic regression computes a weighted sum of the columns and squashes it through a sigmoid into a probability. The class is whichever probability is highest. For more than two classes the same idea is one linear score per class (softmax). Training maximizes the likelihood of the observed labels, which is a convex problem: with the same data and the same penalty you get the same coefficients every time.
The coefficients are the interpretation. A positive coefficient means that column pushes the log-odds toward that class, holding the others fixed. That sentence is only true if the columns are on comparable scales and are not copies of each other. Standardize continuous columns, and do not include a column that is the sum of two others.
L2 keeps every coefficient small. L1 drives some of them to exactly zero, which is feature selection. Elastic-net mixes the two. The C parameter is the inverse of that penalty: a small C trusts the penalty more than the sample.
Settings that change this fit
- C
- Inverse penalty strength. Smaller C draws the decision scores toward zero and usually raises probability calibration at the cost of training accuracy.
- penalty
- L2 shrinks. L1 zeros. Elastic-net does both, with l1_ratio choosing the mix.