package sklearn

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
type tag = [
  1. | `MissingIndicator
]
type t = [ `BaseEstimator | `MissingIndicator | `Object | `TransformerMixin ] Obj.t
val of_pyobject : Py.Object.t -> t
val to_pyobject : [> tag ] Obj.t -> Py.Object.t
val as_transformer : t -> [ `TransformerMixin ] Obj.t
val as_estimator : t -> [ `BaseEstimator ] Obj.t
val create : ?missing_values: [ `S of string | `I of int | `Np_nan of Py.Object.t | `F of float | `None ] -> ?features:string -> ?sparse:[ `Auto | `Bool of bool ] -> ?error_on_new:bool -> unit -> t

Binary indicators for missing values.

Note that this component typically should not be used in a vanilla :class:`Pipeline` consisting of transformers and a classifier, but rather could be added using a :class:`FeatureUnion` or :class:`ColumnTransformer`.

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

.. versionadded:: 0.20

Parameters ---------- missing_values : number, string, np.nan (default) or None The placeholder for the missing values. All occurrences of `missing_values` will be imputed. For pandas' dataframes with nullable integer dtypes with missing values, `missing_values` should be set to `np.nan`, since `pd.NA` will be converted to `np.nan`.

features : str, default=None Whether the imputer mask should represent all or a subset of features.

  • If 'missing-only' (default), the imputer mask will only represent features containing missing values during fit time.
  • If 'all', the imputer mask will represent all features.

sparse : boolean or 'auto', default=None Whether the imputer mask format should be sparse or dense.

  • If 'auto' (default), the imputer mask will be of same type as input.
  • If True, the imputer mask will be a sparse matrix.
  • If False, the imputer mask will be a numpy array.

error_on_new : boolean, default=None If True (default), transform will raise an error when there are features with missing values in transform that have no missing values in fit. This is applicable only when ``features='missing-only'``.

Attributes ---------- features_ : ndarray, shape (n_missing_features,) or (n_features,) The features indices which will be returned when calling ``transform``. They are computed during ``fit``. For ``features='all'``, it is to ``range(n_features)``.

Examples -------- >>> import numpy as np >>> from sklearn.impute import MissingIndicator >>> X1 = np.array([np.nan, 1, 3], ... [4, 0, np.nan], ... [8, 1, 0]) >>> X2 = np.array([5, 1, np.nan], ... [np.nan, 2, 3], ... [2, 4, 0]) >>> indicator = MissingIndicator() >>> indicator.fit(X1) MissingIndicator() >>> X2_tr = indicator.transform(X2) >>> X2_tr array([False, True], [ True, False], [False, False])

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

Fit the transformer on X.

Parameters ---------- X : array-like, sparse matrix, shape (n_samples, n_features) Input data, where ``n_samples`` is the number of samples and ``n_features`` is the number of features.

Returns ------- self : object Returns self.

val fit_transform : ?y:Py.Object.t -> x:[> `ArrayLike ] Np.Obj.t -> [> tag ] Obj.t -> [> `ArrayLike ] Np.Obj.t

Generate missing values indicator for X.

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

Returns ------- Xt : ndarray or sparse matrix, shape (n_samples, n_features) or (n_samples, n_features_with_missing) The missing indicator for input data. The data type of ``Xt`` will be boolean.

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

Generate missing values indicator for X.

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

Returns ------- Xt : ndarray or sparse matrix, shape (n_samples, n_features) or (n_samples, n_features_with_missing) The missing indicator for input data. The data type of ``Xt`` will be boolean.

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

Attribute features_: get value or raise Not_found if None.

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

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