There are situations when we need to find a regressor for a dataset of non-decreasing points that can present low-level oscillations (such as noise). A linear regression can easily achieve a very high score (considering that the slope is about constant), but it works like a denoiser, producing a line that can't capture the internal dynamics we'd like to model. For these situations, scikit-learn offers the IsotonicRegression class, which produces a piecewise interpolating function, minimizing the following functional:
An example (with a toy dataset) is provided next:
import numpy as np
X = np.arange(-5, 5, 0.1)
Y = X + np.random.uniform(-0.5, 1, size=X.shape)
The following graph shows a plot of the dataset. As everyone can see, it can be easily modeled by a linear regressor, but without a high non-linear function, it is very difficult to capture the...