package sklearn

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
type tag = [
  1. | `MultiOutputClassifier
]
type t = [ `BaseEstimator | `ClassifierMixin | `MetaEstimatorMixin | `MultiOutputClassifier | `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_estimator : t -> [ `BaseEstimator ] Obj.t
val as_meta_estimator : t -> [ `MetaEstimatorMixin ] Obj.t
val create : ?n_jobs:int -> estimator:[> `BaseEstimator ] Np.Obj.t -> unit -> t

Multi target classification

This strategy consists of fitting one classifier per target. This is a simple strategy for extending classifiers that do not natively support multi-target classification

Parameters ---------- estimator : estimator object An estimator object implementing :term:`fit`, :term:`score` and :term:`predict_proba`.

n_jobs : int or None, optional (default=None) The number of jobs to use for the computation. It does each target variable in y in parallel. ``None`` means 1 unless in a :obj:`joblib.parallel_backend` context. ``-1`` means using all processors. See :term:`Glossary <n_jobs>` for more details.

.. versionchanged:: v0.20 `n_jobs` default changed from 1 to None

Attributes ---------- classes_ : array, shape = (n_classes,) Class labels.

estimators_ : list of ``n_output`` estimators Estimators used for predictions.

Examples -------- >>> import numpy as np >>> from sklearn.datasets import make_multilabel_classification >>> from sklearn.multioutput import MultiOutputClassifier >>> from sklearn.neighbors import KNeighborsClassifier

>>> X, y = make_multilabel_classification(n_classes=3, random_state=0) >>> clf = MultiOutputClassifier(KNeighborsClassifier()).fit(X, y) >>> clf.predict(X-2:) array([1, 1, 0], [1, 1, 1])

val fit : ?sample_weight:[> `ArrayLike ] Np.Obj.t -> ?fit_params:(string * Py.Object.t) list -> 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 of shape (n_samples, n_features) The input data. Y : array-like of shape (n_samples, n_classes) The target values. sample_weight : array-like of shape (n_samples,) or None Sample weights. If None, then samples are equally weighted. Only supported if the underlying classifier supports sample weights. **fit_params : dict of string -> object Parameters passed to the ``estimator.fit`` method of each step.

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 partial_fit : ?classes:[> `ArrayLike ] Np.Obj.t list -> ?sample_weight:[> `ArrayLike ] Np.Obj.t -> x:[> `Spmatrix ] Np.Obj.t -> y:[> `Spmatrix ] Np.Obj.t -> [> tag ] Obj.t -> t

Incrementally fit the model to data. Fit a separate model for each output variable.

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

y : (sparse) array-like, shape (n_samples, n_outputs) Multi-output targets.

classes : list of numpy arrays, shape (n_outputs) Each array is unique classes for one output in str/int Can be obtained by via ``np.unique(y[:, i]) for i in range(y.shape[1])``, where y is the target matrix of the entire dataset. This argument is required for the first call to partial_fit and can be omitted in the subsequent calls. Note that y doesn't need to contain all labels in `classes`.

sample_weight : array-like of shape (n_samples,), default=None Sample weights. If None, then samples are equally weighted. Only supported if the underlying regressor supports sample weights.

Returns ------- self : object

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

Predict multi-output variable using a model trained for each target variable.

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

Returns ------- y : (sparse) array-like, shape (n_samples, n_outputs) Multi-output targets predicted across multiple predictors. Note: Separate models are generated for each predictor.

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

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

Parameters ---------- X : array-like, shape n_samples, n_features Test samples

y : array-like, shape n_samples, n_outputs True values for X

Returns ------- scores : float accuracy_score of self.predict(X) versus 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 -> Py.Object.t

Attribute estimators_: get value or raise Not_found if None.

val estimators_opt : t -> Py.Object.t option

Attribute estimators_: 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.