.. _example_linear_model_plot_robust_fit.py: Robust linear estimator fitting =============================== Here a sine function is fit with a polynomial of order 3, for values close to zero. Robust fitting is demoed in different situations: - No measurement errors, only modelling errors (fitting a sine with a polynomial) - Measurement errors in X - Measurement errors in y The median absolute deviation to non corrupt new data is used to judge the quality of the prediction. What we can see that: - RANSAC is good for strong outliers in the y direction - TheilSen is good for small outliers, both in direction X and y, but has a break point above which it performs worst than OLS. .. rst-class:: horizontal * .. image:: images/plot_robust_fit_001.png :scale: 47 * .. image:: images/plot_robust_fit_002.png :scale: 47 * .. image:: images/plot_robust_fit_003.png :scale: 47 * .. image:: images/plot_robust_fit_004.png :scale: 47 * .. image:: images/plot_robust_fit_005.png :scale: 47 **Python source code:** :download:`plot_robust_fit.py ` .. literalinclude:: plot_robust_fit.py :lines: 28- **Total running time of the example:** 6.00 seconds ( 0 minutes 6.00 seconds)