I am using Elasticnet from scikit-learn in python, I've also used Glmnet package in R for prototyping. I want to use weights in Elasticnet which apparently is not available as an option/argument in Elasticnet in scikit-learn. However it is available in glmnet/elnet in R.

Has anyone used weights with elasticnet in python? Any insight on how it can be done.


locked by whuber Dec 25 '17 at 23:21

This question exists because it has historical significance, but it is not considered a good, on-topic question for this site so please do not use it as evidence that you can ask similar questions here. This question and its answers are frozen and cannot be changed. See the help center for guidance on writing a good question.

Read more about locked posts here.

  • 1
    $\begingroup$ glmnet supports weights for both samples, and for various predictors to increase or decrease the regularization strength on a by-variable basis. Which are you asking about? $\endgroup$ – Matthew Drury Jul 29 '16 at 0:23
  • $\begingroup$ I was asking about sample, My sample had dates and I wanted to assign lower weight to older data wrt to newer data. I achieved it to some extent by duplicating records for newer dates. $\endgroup$ – Ashish Singhal Dec 7 '16 at 18:21

You can pass weights to SGDRegressor's fit method, although it is suggested for big training samples, n > 10000.

I have not used/tested this myself and I do not know the reasoning behind this suggestion, perhaps would be worth looking into for you.

One possible reason I can think of comes from using SGDClassifier for implementing logistic regression with elasticnet penalty, as suggested in Scikit documentation. As discussed here SGDClassifier may have slower convergence compared to better optimized solvers. I have experienced a similar issue with a multinomial logistic model.


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