question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature request: include mean absolute error (MAE) as scorer in sklearn.linear_model.ElasticNetCV

See original GitHub issue

Description

In scikit-learn v0.19.0, ElasticNet minimizes the objective function:

1 / (2 * n_samples) * ||y - Xw||^2_2 + alpha * l1_ratio * ||w||_1 + 0.5 * alpha * (1 - l1_ratio) * ||w||^2_2.

In words, the objective function is mean squared error (MSE) loss on the predicted variable, plus regularization terms. My feature request is to include an argument (with ‘mse’ as its default value) that would allow the user to switch to mean absolute error (MAE) loss on the predicted variable. For the equivalent in R, see https://cran.r-project.org/web/packages/glmnet/glmnet.pdf, particularly the documentation for cv.glmnet:

type.measure=“mae” (mean absolute error) can be used by all models except … “cox”

It would be great to also allow this functionality in sklearn.

Edit: as @agramfort pointed out below, glmnet only supports MAE for cross-validation, but not for model fitting. My request is to add an option for MAE in sklearn ElasticNet model fitting. This already exists in sklearn.ensemble.GradientBoostingRegressor (loss=‘quantile’ and alpha=0.50), if I am reading the documentation correctly. There’s also a linear-regression-with-MAE-loss option in sklearn.linear_model.HuberRegressor.html, if epsilon=0.0 (“The Huber Regressor optimizes the squared loss for the samples where |(y - X'w) / sigma| < epsilon and the absolute loss for the samples where |(y - X'w) / sigma| > epsilon”).

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:3
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
agramfortcommented, Sep 20, 2017

now we “just” need someone to take a stab at it 😃

0reactions
atorchcommented, Sep 19, 2017

Ok. I’m glad you think it’s doable and useful!

Read more comments on GitHub >

github_iconTop Results From Across the Web

sklearn.linear_model.ElasticNetCV
This parameter is ignored when fit_intercept is set to False. If True, the regressors X will be normalized before regression by subtracting the...
Read more >
Cross-validation in scikit-learn: mean absolute error of (X_test ...
I get the cross validation Mean Absolute Error (MAE) for the (X_train, ... mae = cross_val_score(reg, x, y, cv=5,scoring=scoring) mae.
Read more >
Zillow: End to End ML Workflow (Top 250: 0.06416) - Kaggle
This includes initial data exploration, handling missing data, feature ... use the models' Mean Absolute Error and RMSE (Root Mean Squared Error) to...
Read more >
scikit-learn 1.0 Released - Exxact Corporation
Feature : something that you couldn't do before. Efficiency : an existing feature now may not require as much computation or memory. Enhancement...
Read more >
scikit-learn user guide
For bug reports or feature requests, please make use of the issue tracker ... training score could have a great effect on cross...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found