1
$\begingroup$

I saw this parameter in the sklearn.linear_model.ElasticNet. What is the purpose of this? What is the possible scenario where we want to force the coefficients to be positive? How is this achieved? Doesn't it affect model performance?

positive : bool, default=False
When set to True, forces the coefficients to be positive.

$\endgroup$

1 Answer 1

1
$\begingroup$

The parameter constrains all coefficients to be positive. You as the model builder or a subject matter expert may have insight to believe that all coefficients should be positive in this model.

You can search for "positive" in here which is the coordinate descent code that handles the positive coefficient to see how this is achieved.

Usage may effect model performance - depending on how you define model performance for the problem. If the definition is inferencing - learning the coefficients for interpretation and business action where there is a belief that all effects are positive, then no this may not effect performance. There may be times that the real-world says the coefficients must be positive (e.g. miles per gallon or km per liter, number of tires on a car cannot be negative) but an artifact of the model fit may make these negative and invalid. If the problem says pure prediction performance (as measured by some metric of choice) then usage of this parameter may effect performance.

There is a class of models using constraints that help the modeler adjust the model to the problem. Here is one.

This comes down to the modeler knowing if using this functionality is relevant to the problem.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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