@@ -610,7 +610,7 @@ class MissingIndicator(TransformerMixin, BaseEstimator):
610
610
611
611
Parameters
612
612
----------
613
- missing_values : int, float, string , np.nan or None, default=np.nan
613
+ missing_values : int, float, str , np.nan or None, default=np.nan
614
614
The placeholder for the missing values. All occurrences of
615
615
`missing_values` will be imputed. For pandas' dataframes with
616
616
nullable integer dtypes with missing values, `missing_values`
@@ -620,29 +620,29 @@ class MissingIndicator(TransformerMixin, BaseEstimator):
620
620
Whether the imputer mask should represent all or a subset of
621
621
features.
622
622
623
- - If 'missing-only' (default), the imputer mask will only represent
623
+ - If ` 'missing-only'` (default), the imputer mask will only represent
624
624
features containing missing values during fit time.
625
- - If 'all', the imputer mask will represent all features.
625
+ - If ` 'all'` , the imputer mask will represent all features.
626
626
627
627
sparse : bool or 'auto', default='auto'
628
628
Whether the imputer mask format should be sparse or dense.
629
629
630
- - If 'auto' (default), the imputer mask will be of same type as
630
+ - If ` 'auto'` (default), the imputer mask will be of same type as
631
631
input.
632
- - If True, the imputer mask will be a sparse matrix.
633
- - If False, the imputer mask will be a numpy array.
632
+ - If ` True` , the imputer mask will be a sparse matrix.
633
+ - If ` False` , the imputer mask will be a numpy array.
634
634
635
635
error_on_new : bool, default=True
636
- If True, transform will raise an error when there are features with
637
- missing values in transform that have no missing values in fit. This is
638
- applicable only when `features='missing-only'`.
636
+ If ` True`, :meth:` transform` will raise an error when there are
637
+ features with missing values that have no missing values in
638
+ :meth:`fit`. This is applicable only when `features='missing-only'`.
639
639
640
640
Attributes
641
641
----------
642
- features_ : ndarray, shape (n_missing_features,) or (n_features,)
643
- The features indices which will be returned when calling ``transform``.
644
- They are computed during `` fit``. For ``features='all'``, it is
645
- to `` range(n_features)` `.
642
+ features_ : ndarray of shape (n_missing_features,) or (n_features,)
643
+ The features indices which will be returned when calling
644
+ :meth:`transform`. They are computed during :meth:` fit`. If
645
+ `features='all'`, `features_` is equal to ` range(n_features)`.
646
646
647
647
n_features_in_ : int
648
648
Number of features seen during :term:`fit`.
@@ -655,6 +655,11 @@ class MissingIndicator(TransformerMixin, BaseEstimator):
655
655
656
656
.. versionadded:: 1.0
657
657
658
+ See Also
659
+ --------
660
+ SimpleImputer : Univariate imputation of missing values.
661
+ IterativeImputer : Multivariate imputation of missing values.
662
+
658
663
Examples
659
664
--------
660
665
>>> import numpy as np
@@ -673,7 +678,6 @@ class MissingIndicator(TransformerMixin, BaseEstimator):
673
678
array([[False, True],
674
679
[ True, False],
675
680
[False, False]])
676
-
677
681
"""
678
682
679
683
def __init__ (
@@ -695,19 +699,19 @@ def _get_missing_features_info(self, X):
695
699
696
700
Parameters
697
701
----------
698
- X : {ndarray or sparse matrix}, shape (n_samples, n_features)
699
- The input data with missing values. Note that ``X`` has been
700
- checked in ``fit`` and ``transform`` before to call this function.
702
+ X : {ndarray, sparse matrix} of shape (n_samples, n_features)
703
+ The input data with missing values. Note that `X` has been
704
+ checked in :meth:`fit` and :meth:`transform` before to call this
705
+ function.
701
706
702
707
Returns
703
708
-------
704
- imputer_mask : {ndarray or sparse matrix}, shape \
709
+ imputer_mask : {ndarray, sparse matrix} of shape \
705
710
(n_samples, n_features)
706
711
The imputer mask of the original data.
707
712
708
- features_with_missing : ndarray, shape (n_features_with_missing)
713
+ features_with_missing : ndarray of shape (n_features_with_missing)
709
714
The features containing missing values.
710
-
711
715
"""
712
716
if not self ._precomputed :
713
717
imputer_mask = _get_mask (X , self .missing_values )
@@ -778,25 +782,23 @@ def _validate_input(self, X, in_fit):
778
782
return X
779
783
780
784
def _fit (self , X , y = None , precomputed = False ):
781
- """Fit the transformer on X .
785
+ """Fit the transformer on `X` .
782
786
783
787
Parameters
784
788
----------
785
- X : {array-like, sparse matrix}, shape (n_samples, n_features)
786
- Input data, where ``n_samples`` is the number of samples and
787
- ``n_features`` is the number of features.
788
- If `precomputed` is True, then `X` is a mask of the
789
- input data.
789
+ X : {array-like, sparse matrix} of shape (n_samples, n_features)
790
+ Input data, where `n_samples` is the number of samples and
791
+ `n_features` is the number of features.
792
+ If `precomputed=True`, then `X` is a mask of the input data.
790
793
791
794
precomputed : bool
792
795
Whether the input data is a mask.
793
796
794
797
Returns
795
798
-------
796
- imputer_mask : {ndarray or sparse matrix}, shape (n_samples, \
799
+ imputer_mask : {ndarray, sparse matrix} of shape (n_samples, \
797
800
n_features)
798
801
The imputer mask of the original data.
799
-
800
802
"""
801
803
if precomputed :
802
804
if not (hasattr (X , "dtype" ) and X .dtype .kind == "b" ):
@@ -834,38 +836,40 @@ def _fit(self, X, y=None, precomputed=False):
834
836
return missing_features_info [0 ]
835
837
836
838
def fit (self , X , y = None ):
837
- """Fit the transformer on X .
839
+ """Fit the transformer on `X` .
838
840
839
841
Parameters
840
842
----------
841
- X : {array-like, sparse matrix}, shape (n_samples, n_features)
842
- Input data, where ``n_samples`` is the number of samples and
843
- ``n_features`` is the number of features.
843
+ X : {array-like, sparse matrix} of shape (n_samples, n_features)
844
+ Input data, where `n_samples` is the number of samples and
845
+ `n_features` is the number of features.
846
+
847
+ y : Ignored
848
+ Not used, present for API consistency by convention.
844
849
845
850
Returns
846
851
-------
847
852
self : object
848
- Returns self .
853
+ Fitted estimator .
849
854
"""
850
855
self ._fit (X , y )
851
856
852
857
return self
853
858
854
859
def transform (self , X ):
855
- """Generate missing values indicator for X .
860
+ """Generate missing values indicator for `X` .
856
861
857
862
Parameters
858
863
----------
859
- X : {array-like, sparse matrix}, shape (n_samples, n_features)
864
+ X : {array-like, sparse matrix} of shape (n_samples, n_features)
860
865
The input data to complete.
861
866
862
867
Returns
863
868
-------
864
- Xt : {ndarray or sparse matrix}, shape (n_samples, n_features) \
869
+ Xt : {ndarray, sparse matrix} of shape (n_samples, n_features) \
865
870
or (n_samples, n_features_with_missing)
866
- The missing indicator for input data. The data type of ``Xt` `
871
+ The missing indicator for input data. The data type of `Xt `
867
872
will be boolean.
868
-
869
873
"""
870
874
check_is_fitted (self )
871
875
@@ -894,20 +898,22 @@ def transform(self, X):
894
898
return imputer_mask
895
899
896
900
def fit_transform (self , X , y = None ):
897
- """Generate missing values indicator for X .
901
+ """Generate missing values indicator for `X` .
898
902
899
903
Parameters
900
904
----------
901
- X : {array-like, sparse matrix}, shape (n_samples, n_features)
905
+ X : {array-like, sparse matrix} of shape (n_samples, n_features)
902
906
The input data to complete.
903
907
908
+ y : Ignored
909
+ Not used, present for API consistency by convention.
910
+
904
911
Returns
905
912
-------
906
- Xt : {ndarray or sparse matrix}, shape (n_samples, n_features) \
913
+ Xt : {ndarray, sparse matrix} of shape (n_samples, n_features) \
907
914
or (n_samples, n_features_with_missing)
908
- The missing indicator for input data. The data type of ``Xt` `
915
+ The missing indicator for input data. The data type of `Xt `
909
916
will be boolean.
910
-
911
917
"""
912
918
imputer_mask = self ._fit (X , y )
913
919
0 commit comments