在Python中使用sklearn使用MAE训练线性模型 [英] Training Linear Models with MAE using sklearn in Python

查看:67
本文介绍了在Python中使用sklearn使用MAE训练线性模型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正尝试在python中使用sklearn训练线性模型,但不以均方误差(MSE)作为误差度量-但以平均绝对误差(MAE).我特别需要大学教授提出的具有MAE的线性模型.

I'm currently trying to train a linear model using sklearn in python but not with mean squared error (MSE) as error measure - but with mean absolute error (MAE). I specificially need a linear model with MAE as requirement from my professor at university.

我研究了 sklearn.linear_model.LinearRegression ,由于它是OLS回归器,因此无法提供其他错误度量.

I've looked into sklearn.linear_model.LinearRegression which since it is an OLS regressor does not provide alternative error measures.

因此,我检查了其他可用的回归变量,偶然发现了 sklearn.linear_model.HuberRegressor sklearn.linear_model.SGDRegressor .他们俩都将MAE作为其错误度量的一部分-但似乎没有提供简单的MAE.有没有一种方法可以为这些回归变量中的一个选择参数,以使最终的误差度量成为简单的MAE?还是在sklearn中有另一个我忽略的回归器?

Hence, I checked the other available regressors and stumbled upon sklearn.linear_model.HuberRegressor and sklearn.linear_model.SGDRegressor. They both mention MAE as part of their error measures - but do not seem to provide simple MAE. Is there a way to choose the parameters for one of those regressors so that the resulting error measure is a simple MAE? Or is there another regressor in sklearn which I've overlooked?

或者,还有另一个(易于使用)python 3.X软件包可以提供我所需的内容吗?

Alternatively, is there another (easy to use) python 3.X package which provides what I need?

感谢您的帮助!

推荐答案

在SGD中,如果将epsilon = 0与'epsilon_insensitive'一起使用,它应该像使用MAE一样工作.

In SGD, if you use 'epsilon_insensitive' with epsilon=0 it should work as if you used MAE.

您还可以查看statsmodels 分位数回归(使用MAE也称为中位数回归,中位数是分位数).

You could also take a look at statsmodels quantile regression (using MAE is also called median regression, and median is a quantile).

这篇关于在Python中使用sklearn使用MAE训练线性模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆