package sklearn

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
type tag = [
  1. | `CalibratedClassifierCV
]
type t = [ `BaseEstimator | `CalibratedClassifierCV | `ClassifierMixin | `MetaEstimatorMixin | `Object ] Obj.t
val of_pyobject : Py.Object.t -> t
val to_pyobject : [> tag ] Obj.t -> Py.Object.t
val as_estimator : t -> [ `BaseEstimator ] Obj.t
val as_meta_estimator : t -> [ `MetaEstimatorMixin ] Obj.t
val as_classifier : t -> [ `ClassifierMixin ] Obj.t
val create : ?base_estimator:[> `BaseEstimator ] Np.Obj.t -> ?method_:[ `Sigmoid | `Isotonic ] -> ?cv: [ `BaseCrossValidator of [> `BaseCrossValidator ] Np.Obj.t | `Prefit | `Arr of [> `ArrayLike ] Np.Obj.t | `I of int ] -> unit -> t

Probability calibration with isotonic regression or logistic regression.

The calibration is based on the :term:`decision_function` method of the `base_estimator` if it exists, else on :term:`predict_proba`.

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

Parameters ---------- base_estimator : instance BaseEstimator The classifier whose output need to be calibrated to provide more accurate `predict_proba` outputs.

method : 'sigmoid' or 'isotonic' The method to use for calibration. Can be 'sigmoid' which corresponds to Platt's method (i.e. a logistic regression model) or 'isotonic' which is a non-parametric approach. It is not advised to use isotonic calibration with too few calibration samples ``(<<1000)`` since it tends to overfit.

cv : integer, cross-validation generator, iterable or 'prefit', optional Determines the cross-validation splitting strategy. Possible inputs for cv are:

  • None, to use the default 5-fold cross-validation,
  • integer, to specify the number of folds.
  • :term:`CV splitter`,
  • An iterable yielding (train, test) splits as arrays of indices.

For integer/None inputs, if ``y`` is binary or multiclass, :class:`sklearn.model_selection.StratifiedKFold` is used. If ``y`` is neither binary nor multiclass, :class:`sklearn.model_selection.KFold` is used.

Refer :ref:`User Guide <cross_validation>` for the various cross-validation strategies that can be used here.

If 'prefit' is passed, it is assumed that `base_estimator` has been fitted already and all data is used for calibration.

.. versionchanged:: 0.22 ``cv`` default value if None changed from 3-fold to 5-fold.

Attributes ---------- classes_ : array, shape (n_classes) The class labels.

calibrated_classifiers_ : list (len() equal to cv or 1 if cv == 'prefit') The list of calibrated classifiers, one for each cross-validation fold, which has been fitted on all but the validation fold and calibrated on the validation fold.

References ---------- .. 1 Obtaining calibrated probability estimates from decision trees and naive Bayesian classifiers, B. Zadrozny & C. Elkan, ICML 2001

.. 2 Transforming Classifier Scores into Accurate Multiclass Probability Estimates, B. Zadrozny & C. Elkan, (KDD 2002)

.. 3 Probabilistic Outputs for Support Vector Machines and Comparisons to Regularized Likelihood Methods, J. Platt, (1999)

.. 4 Predicting Good Probabilities with Supervised Learning, A. Niculescu-Mizil & R. Caruana, ICML 2005

val fit : ?sample_weight:[> `ArrayLike ] Np.Obj.t -> x:[> `ArrayLike ] Np.Obj.t -> y:[> `ArrayLike ] Np.Obj.t -> [> tag ] Obj.t -> t

Fit the calibrated model

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

y : array-like, shape (n_samples,) Target values.

sample_weight : array-like of shape (n_samples,), default=None Sample weights. If None, then samples are equally weighted.

Returns ------- self : object Returns an instance of self.

val get_params : ?deep:bool -> [> tag ] Obj.t -> Dict.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 : x:[> `ArrayLike ] Np.Obj.t -> [> tag ] Obj.t -> [> `ArrayLike ] Np.Obj.t

Predict the target of new samples. The predicted class is the class that has the highest probability, and can thus be different from the prediction of the uncalibrated classifier.

Parameters ---------- X : array-like, shape (n_samples, n_features) The samples.

Returns ------- C : array, shape (n_samples,) The predicted class.

val predict_proba : x:[> `ArrayLike ] Np.Obj.t -> [> tag ] Obj.t -> [> `ArrayLike ] Np.Obj.t

Posterior probabilities of classification

This function returns posterior probabilities of classification according to each class on an array of test vectors X.

Parameters ---------- X : array-like, shape (n_samples, n_features) The samples.

Returns ------- C : array, shape (n_samples, n_classes) The predicted probas.

val score : ?sample_weight:[> `ArrayLike ] Np.Obj.t -> x:[> `ArrayLike ] Np.Obj.t -> y:[> `ArrayLike ] Np.Obj.t -> [> tag ] Obj.t -> float

Return the mean accuracy on the given test data and labels.

In multi-label classification, this is the subset accuracy which is a harsh metric since you require for each sample that each label set be correctly predicted.

Parameters ---------- X : array-like of shape (n_samples, n_features) Test samples.

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

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

Returns ------- score : float Mean accuracy of self.predict(X) wrt. y.

val set_params : ?params:(string * Py.Object.t) list -> [> tag ] Obj.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 classes_ : t -> [> `ArrayLike ] Np.Obj.t

Attribute classes_: get value or raise Not_found if None.

val classes_opt : t -> [> `ArrayLike ] Np.Obj.t option

Attribute classes_: get value as an option.

val calibrated_classifiers_ : t -> [> `ArrayLike ] Np.Obj.t

Attribute calibrated_classifiers_: get value or raise Not_found if None.

val calibrated_classifiers_opt : t -> [> `ArrayLike ] Np.Obj.t option

Attribute calibrated_classifiers_: get value as an option.

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.