简体   繁体   中英

weighted least absolute regression in python?

I was wondering if there's a function in Python that can find the best-fitted line (in 2D) or best-fitted plane (in 3D) of a set of data by least absolute deviation and while considering uncertainties of the points .

In fact, I have 3d points, which I want the best-fit plane of them. There is Weighted least square (WLS) fit function in both sklearn and statsmodel python libraries, and by putting q=0.5 in quantile regression of statsmodel I get the least absolute deviation. However, how can I have Weighted Least Absolute regression fit function?

Least-squares, or equivalently chi^2-based, methods are easier because their first derivative is a smooth function. If you want absolute deviation to be minimized then you can use scipy.minimize() with appropriately defined objective function. The other approach is to find ranges on which your objective function is smooth, optimize each range in a linear fashion, and then choose optimal value among these results.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM