package sklearn

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

A multi-label model that arranges binary classifiers into a chain.

Each model makes a prediction in the order specified by the chain using all of the available features provided to the model plus the predictions of models that are earlier in the chain.

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

.. versionadded:: 0.19

Parameters ---------- base_estimator : estimator The base estimator from which the classifier chain is built.

order : array-like of shape (n_outputs,) or 'random', optional By default the order will be determined by the order of columns in the label matrix Y.::

order = 0, 1, 2, ..., Y.shape[1] - 1

The order of the chain can be explicitly set by providing a list of integers. For example, for a chain of length 5.::

order = 1, 3, 2, 4, 0

means that the first model in the chain will make predictions for column 1 in the Y matrix, the second model will make predictions for column 3, etc.

If order is 'random' a random ordering will be used.

cv : int, cross-validation generator or an iterable, optional (default=None) Determines whether to use cross validated predictions or true labels for the results of previous estimators in the chain. If cv is None the true labels are used when fitting. Otherwise possible inputs for cv are:

  • integer, to specify the number of folds in a (Stratified)KFold,
  • :term:`CV splitter`,
  • An iterable yielding (train, test) splits as arrays of indices.

random_state : int, RandomState instance or None, optional (default=None) If ``order='random'``, determines random number generation for the chain order. In addition, it controls the random seed given at each `base_estimator` at each chaining iteration. Thus, it is only used when `base_estimator` exposes a `random_state`. Pass an int for reproducible output across multiple function calls. See :term:`Glossary <random_state>`.

Attributes ---------- classes_ : list A list of arrays of length ``len(estimators_)`` containing the class labels for each estimator in the chain.

estimators_ : list A list of clones of base_estimator.

order_ : list The order of labels in the classifier chain.

See also -------- RegressorChain: Equivalent for regression MultioutputClassifier: Classifies each output independently rather than chaining.

References ---------- Jesse Read, Bernhard Pfahringer, Geoff Holmes, Eibe Frank, 'Classifier Chains for Multi-label Classification', 2009.

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

Evaluate the decision_function of the models in the chain.

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

Returns ------- Y_decision : array-like, shape (n_samples, n_classes ) Returns the decision function of the sample for each model in the chain.

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

Fit the model to data matrix X and targets Y.

Parameters ---------- X : array-like, sparse matrix, shape (n_samples, n_features) The input data. Y : array-like, shape (n_samples, n_classes) The target values.

Returns ------- self : object

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 on the data matrix X using the ClassifierChain model.

Parameters ---------- X : array-like, sparse matrix, shape (n_samples, n_features) The input data.

Returns ------- Y_pred : array-like, shape (n_samples, n_classes) The predicted values.

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

Predict probability estimates.

Parameters ---------- X : array-like, sparse matrix, shape (n_samples, n_features)

Returns ------- Y_prob : array-like, shape (n_samples, n_classes)

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 estimators_ : t -> [> `ArrayLike ] Np.Obj.t

Attribute estimators_: get value or raise Not_found if None.

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

Attribute estimators_: get value as an option.

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

Attribute order_: get value or raise Not_found if None.

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

Attribute order_: 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 : Stdlib.Format.formatter -> t -> unit

Pretty-print the object to a formatter.