package sklearn

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
type t
val of_pyobject : Py.Object.t -> t
val to_pyobject : t -> Py.Object.t
val create : ?y_min:Py.Object.t -> ?y_max:Py.Object.t -> ?increasing:[ `Bool of bool | `String of string ] -> ?out_of_bounds:string -> unit -> t

Isotonic regression model.

The isotonic regression optimization problem is defined by::

min sum w_i (yi - y_i) ** 2

subject to y_i <= y_j whenever Xi <= Xj and min(y_) = y_min, max(y_) = y_max

where:

  • ``yi`` are inputs (real numbers)
  • ``y_i`` are fitted
  • ``X`` specifies the order. If ``X`` is non-decreasing then ``y_`` is non-decreasing.
  • ``wi`` are optional strictly positive weights (default to 1.0)

Read more in the :ref:`User Guide <isotonic>`.

.. versionadded:: 0.13

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.

increasing : boolean or string, optional, default: True If boolean, whether or not to fit the isotonic regression with y increasing or decreasing.

The string value "auto" determines whether y should increase or decrease based on the Spearman correlation estimate's sign.

out_of_bounds : string, optional, default: "nan" The ``out_of_bounds`` parameter handles how x-values outside of the training domain are handled. When set to "nan", predicted y-values will be NaN. When set to "clip", predicted y-values will be set to the value corresponding to the nearest train interval endpoint. When set to "raise", allow ``interp1d`` to throw ValueError.

Attributes ---------- X_min_ : float Minimum value of input array `X_` for left bound.

X_max_ : float Maximum value of input array `X_` for right bound.

f_ : function The stepwise interpolating function that covers the input domain ``X``.

Notes ----- Ties are broken using the secondary method from Leeuw, 1977.

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

Isotone Optimization in R : Pool-Adjacent-Violators Algorithm (PAVA) and Active Set Methods Leeuw, Hornik, Mair Journal of Statistical Software 2009

Correctness of Kruskal's algorithms for monotone regression with ties Leeuw, Psychometrica, 1977

Examples -------- >>> from sklearn.datasets import make_regression >>> from sklearn.isotonic import IsotonicRegression >>> X, y = make_regression(n_samples=10, n_features=1, random_state=41) >>> iso_reg = IsotonicRegression().fit(X.flatten(), y) >>> iso_reg.predict(.1, .2) array(1.8628..., 3.7256...)

val fit : ?sample_weight:Ndarray.t -> x:Ndarray.t -> y:Ndarray.t -> t -> t

Fit the model using X, y as training data.

Parameters ---------- X : array-like of shape (n_samples,) Training data.

y : array-like of shape (n_samples,) Training target.

sample_weight : array-like of shape (n_samples,), 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 :meth:`transform` needs X to interpolate new input data.

val fit_transform : ?y:Ndarray.t -> ?fit_params:(string * Py.Object.t) list -> x:Ndarray.t -> t -> Ndarray.t

Fit to data, then transform it.

Fits transformer to X and y with optional parameters fit_params and returns a transformed version of X.

Parameters ---------- X : numpy array of shape n_samples, n_features Training set.

y : numpy array of shape n_samples Target values.

**fit_params : dict Additional fit parameters.

Returns ------- X_new : numpy array of shape n_samples, n_features_new Transformed array.

val get_params : ?deep:bool -> t -> Py.Object.t

Get parameters for this estimator.

Parameters ---------- deep : bool, default=True 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.

val predict : t:Ndarray.t -> t -> Ndarray.t

Predict new data by linear interpolation.

Parameters ---------- T : array-like of shape (n_samples,) Data to transform.

Returns ------- T_ : array, shape=(n_samples,) Transformed data.

val score : ?sample_weight:Ndarray.t -> x:Ndarray.t -> y:Ndarray.t -> t -> float

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

The coefficient R^2 is defined as (1 - u/v), where u is the residual sum of squares ((y_true - y_pred) ** 2).sum() and v is the total sum of squares ((y_true - y_true.mean()) ** 2).sum(). The best possible score is 1.0 and it can be negative (because the model can be arbitrarily worse). A constant model that always predicts the expected value of y, disregarding the input features, would get a R^2 score of 0.0.

Parameters ---------- X : array-like of shape (n_samples, n_features) Test samples. For some estimators this may be a precomputed kernel matrix or a list of generic objects instead, shape = (n_samples, n_samples_fitted), where n_samples_fitted is the number of samples used in the fitting for the estimator.

y : array-like of shape (n_samples,) or (n_samples, n_outputs) True values for X.

sample_weight : array-like of shape (n_samples,), default=None Sample weights.

Returns ------- score : float R^2 of self.predict(X) wrt. y.

Notes ----- The R2 score used when calling ``score`` on a regressor will use ``multioutput='uniform_average'`` from version 0.23 to keep consistent with :func:`~sklearn.metrics.r2_score`. This will influence the ``score`` method of all the multioutput regressors (except for :class:`~sklearn.multioutput.MultiOutputRegressor`). To specify the default value manually and avoid the warning, please either call :func:`~sklearn.metrics.r2_score` directly or make a custom scorer with :func:`~sklearn.metrics.make_scorer` (the built-in scorer ``'r2'`` uses ``multioutput='uniform_average'``).

val set_params : ?params:(string * Py.Object.t) list -> t -> t

Set the parameters of this estimator.

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

Parameters ---------- **params : dict Estimator parameters.

Returns ------- self : object Estimator instance.

val transform : t:Ndarray.t -> t -> Ndarray.t

Transform new data by linear interpolation

Parameters ---------- T : array-like of shape (n_samples,) Data to transform.

Returns ------- T_ : array, shape=(n_samples,) The transformed data

val x_min_ : t -> float

Attribute X_min_: see constructor for documentation

val x_max_ : t -> float

Attribute X_max_: see constructor for documentation

val f_ : t -> Py.Object.t

Attribute f_: see constructor for documentation

val to_string : t -> string

Print the object to a human-readable representation.

val show : t -> string

Print the object to a human-readable representation.

val pp : Format.formatter -> t -> unit

Pretty-print the object to a formatter.

OCaml

Innovation. Community. Security.