Fork me on GitHub

sklearn.isotonic.IsotonicRegression

class sklearn.isotonic.IsotonicRegression(y_min=None, y_max=None, increasing=True)

Isotonic regression model.

The isotonic regression optimization problem is defined by:

min sum w_i (y[i] - y_[i]) ** 2

subject to y_[i] <= y_[j] whenever X[i] <= X[j]
and min(y_) = y_min, max(y_) = y_max
where:
  • y[i] are inputs (real numbers)
  • y_[i] are fitted
  • X specifies the order. If X is non-decreasing then y_ is non-decreasing.
  • w[i] are optional strictly positive weights (default to 1.0)
Parameters :

y_min : optional, default: None

If not None, set the lowest value of the fit to y_min.

y_max : optional, default: None

If not None, set the highest value of the fit to y_max.

References

Isotonic Median Regression: A Linear Programming Approach Nilotpal Chakravarti Mathematics of Operations Research Vol. 14, No. 2 (May, 1989), pp. 303-308

Attributes

X_ ndarray (n_samples, ) A copy of the input X.
y_ ndarray (n_samples, ) Isotonic fit of y.

Methods

fit(X, y[, sample_weight, weight]) Fit the model using X, y as training data.
fit_transform(X, y[, sample_weight, weight]) Fit model and transform y by linear interpolation.
get_params([deep]) Get parameters for this estimator.
predict(T) Predict new data by linear interpolation.
score(X, y) Returns the coefficient of determination R^2 of the prediction.
set_params(**params) Set the parameters of this estimator.
transform(T) Transform new data by linear interpolation
__init__(y_min=None, y_max=None, increasing=True)
fit(X, y, sample_weight=None, weight=None)

Fit the model using X, y as training data.

Parameters :

X : array-like, shape=(n_samples,)

Training data.

y : array-like, shape=(n_samples,)

Training target.

sample_weight : array-like, shape=(n_samples,), optional, default: None

Weights. If set to None, all weights will be set to 1 (equal weights).

Returns :

self : object

Returns an instance of self.

Notes

X is stored for future use, as transform needs X to interpolate new input data.

fit_transform(X, y, sample_weight=None, weight=None)

Fit model and transform y by linear interpolation.

Parameters :

X : array-like, shape=(n_samples,)

Training data.

y : array-like, shape=(n_samples,)

Training target.

sample_weight : array-like, shape=(n_samples,), optional, default: None

Weights. If set to None, all weights will be equal to 1 (equal weights).

Returns :

`y_` : array, shape=(n_samples,)

The transformed data.

Notes

X doesn’t influence the result of fit_transform. It is however stored for future use, as transform needs X to interpolate new input data.

get_params(deep=True)

Get parameters for this estimator.

Parameters :

deep: boolean, optional :

If True, will return the parameters for this estimator and contained subobjects that are estimators.

Returns :

params : mapping of string to any

Parameter names mapped to their values.

predict(T)

Predict new data by linear interpolation.

Parameters :

T : array-like, shape=(n_samples,)

Data to transform.

Returns :

`T_` : array, shape=(n_samples,)

Transformed data.

score(X, y)

Returns the coefficient of determination R^2 of the prediction.

The coefficient R^2 is defined as (1 - u/v), where u is the regression sum of squares ((y_true - y_pred) ** 2).sum() and v is the residual sum of squares ((y_true - y_true.mean()) ** 2).sum(). Best possible score is 1.0, lower values are worse.

Parameters :

X : array-like, shape = (n_samples, n_features)

Test samples.

y : array-like, shape = (n_samples,)

True values for X.

Returns :

score : float

R^2 of self.predict(X) wrt. y.

set_params(**params)

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as pipelines). The former have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.

Returns :self :
transform(T)

Transform new data by linear interpolation

Parameters :

T : array-like, shape=(n_samples,)

Data to transform.

Returns :

`T_` : array, shape=(n_samples,)

The transformed data

Previous
Next