1
$\begingroup$

I'm pretty new to both ML & scikit-learn. I've noticed that some example tutorials & codes online use patsy's dmatrices to prepare data for logistic regression. I don't understand why this is done. Example

In the case above for instance, isn't it sufficient to use the data in the dataset directly to train the logistic regression model? What exactly is the point of using patsy?

Thanks!

$\endgroup$
1
$\begingroup$

Mostly convenience. In this particular case, it takes care of one-hot encoding categorical variables e.g. C(occupation).

patsy takes care of other things under the hood as well, like dropping rows with missing values and adding a constant intercept variable.

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.