I have a logistic regression model that I made using the glmnet
package. My response variable was coded as a factor, the levels of which I will refer to as "a" and "b".
The mathematics of logistic regression label one of the two classes as "0" and the other as "1". The feature coefficients of a logistic regression model are either positive, negative, or zero. If a feature "f"'s coefficient is positive, then increasing the value of "f" for a test observation x increases the probability that the model classifies x as being of class "1".
My question is: Given a glmnet
model, how do you know how glmnet
mapped your data's factor labels {"a", "b"} to the underlying mathematics' factor labels {"0", "1"}? Because you need to know that to interpret the model's coefficients properly.
You can figure this out manually by experimenting with the output of the predict
function when applied to toy observations. But it would be nice to how glmnet
implicitly handles that mapping to speed up the interpretation process.
Thank you!