8000 DOC Improve documentation of default values for imputers (#15964) · panpiort8/scikit-learn@c32dfaf · GitHub 8000
[go: up one dir, main page]

Skip to content

Commit c32dfaf

Browse files
pulkitmehtaworkPan Jan
authored andcommitted
DOC Improve documentation of default values for imputers (scikit-learn#15964)
1 parent 89f1468 commit c32dfaf

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

sklearn/impute/_base.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ class SimpleImputer(_BaseImputer):
126126
The placeholder for the missing values. All occurrences of
127127
`missing_values` will be imputed.
128128
129-
strategy : string, optional (default="mean")
129+
strategy : string, default='mean'
130130
The imputation strategy.
131131
132132
- If "mean", then replace missing values using the mean along
@@ -141,16 +141,16 @@ class SimpleImputer(_BaseImputer):
141141
.. versionadded:: 0.20
142142
strategy="constant" for fixed value imputation.
143143
144-
fill_value : string or numerical value, optional (default=None)
144+
fill_value : string or numerical value, default=None
145145
When strategy == "constant", fill_value is used to replace all
146146
occurrences of missing_values.
147147
If left to the default, fill_value will be 0 when imputing numerical
148148
data and "missing_value" for strings or object data types.
149149
150-
verbose : integer, optional (default=0)
150+
verbose : integer, default=0
151151
Controls the verbosity of the imputer.
152152
153-
copy : boolean, optional (default=True)
153+
copy : boolean, default=True
154154
If True, a copy of X will be created. If False, imputation will
155155
be done in-place whenever possible. Note that, in the following cases,
156156
a new copy will always be made, even if `copy=False`:
@@ -159,7 +159,7 @@ class SimpleImputer(_BaseImputer):
159159
- If X is encoded as a CSR matrix;
160160
- If add_indicator=True.
161161
162-
add_indicator : boolean, optional (default=False)
162+
add_indicator : boolean, default=False
163163
If True, a :class:`MissingIndicator` transform will stack onto output
164164
of the imputer's transform. This allows a predictive estimator
165165
to account for missingness despite imputation. If a feature has no
@@ -470,23 +470,23 @@ class MissingIndicator(TransformerMixin, BaseEstimator):
470470
`missing_values` will be indicated (True in the output array), the
471471
other values will be marked as False.
472472
473-
features : str, optional
473+
features : str, default=None
474474
Whether the imputer mask should represent all or a subset of
475475
features.
476476
477477
- If "missing-only" (default), the imputer mask will only represent
478478
features containing missing values during fit time.
479479
- If "all", the imputer mask will represent all features.
480480
481-
sparse : boolean or "auto", optional
481+
sparse : boolean or "auto", default=None
482482
Whether the imputer mask format should be sparse or dense.
483483
484484
- If "auto" (default), the imputer mask will be of same type as
485485
input.
486486
- If True, the imputer mask will be a sparse matrix.
487487
- If False, the imputer mask will be a numpy array.
488488
489-
error_on_new : boolean, optional
489+
error_on_new : boolean, default=None
490490
If True (default), transform will raise an error when there are
491491
features with missing values in transform that have no missing values
492492
in fit. This is applicable only when ``features="missing-only"``.

sklearn/impute/_iterative.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class IterativeImputer(_BaseImputer):
5252
If ``sample_posterior`` is True, the estimator must support
5353
``return_std`` in its ``predict`` method.
5454
55-
missing_values : int, np.nan, optional (default=np.nan)
55+
missing_values : int, np.nan, default=np.nan
5656
The placeholder for the missing values. All occurrences of
5757
``missing_values`` will be imputed.
5858
@@ -62,18 +62,18 @@ class IterativeImputer(_BaseImputer):
6262
``return_std`` in its ``predict`` method if set to ``True``. Set to
6363
``True`` if using ``IterativeImputer`` for multiple imputations.
6464
65-
max_iter : int, optional (default=10)
65+
max_iter : int, default=10
6666
Maximum number of imputation rounds to perform before returning the
6767
imputations computed during the final round. A round is a single
6868
imputation of each feature with missing values. The stopping criterion
6969
is met once `abs(max(X_t - X_{t-1}))/abs(max(X[known_vals]))` < tol,
7070
where `X_t` is `X` at iteration `t. Note that early stopping is only
7171
applied if ``sample_posterior=False``.
7272
73-
tol : float, optional (default=1e-3)
73+
tol : float, default=1e-3
7474
Tolerance of the stopping condition.
7575
76-
n_nearest_features : int, optional (default=None)
76+
n_nearest_features : int, default=None
7777
Number of other features to use to estimate the missing values of
7878
each feature column. Nearness between features is measured using
7979
the absolute correlation coefficient between each feature pair (after
@@ -83,12 +83,12 @@ class IterativeImputer(_BaseImputer):
8383
imputed target feature. Can provide significant speed-up when the
8484
number of features is huge. If ``None``, all features will be used.
8585
86-
initial_strategy : str, optional (default="mean")
86+
initial_strategy : str, default='mean'
8787
Which strategy to use to initialize the missing values. Same as the
8888
``strategy`` parameter in :class:`sklearn.impute.SimpleImputer`
8989
Valid values: {"mean", "median", "most_frequent", or "constant"}.
9090
91-
imputation_order : str, optional (default="ascending")
91+
imputation_order : str, default='ascending'
9292
The order in which the features will be imputed. Possible values:
9393
9494
"ascending"
@@ -102,34 +102,34 @@ class IterativeImputer(_BaseImputer):
102102
"random"
103103
A random order for each round.
104104
105-
skip_complete : boolean, optional (default=False)
105+
skip_complete : boolean, default=False
106106
If ``True`` then features with missing values during ``transform``
107107
which did not have any missing values during ``fit`` will be imputed
108108
with the initial imputation method only. Set to ``True`` if you have
109109
many features with no missing values at both ``fit`` and ``transform``
110110
time to save compute.
111111
112-
min_value : float, optional (default=None)
112+
min_value : float, default=None
113113
Minimum possible imputed value. Default of ``None`` will set minimum
114114
to negative infinity.
115115
116-
max_value : float, optional (default=None)
116+
max_value : float, default=None
117117
Maximum possible imputed value. Default of ``None`` will set maximum
118118
to positive infinity.
119119
120-
verbose : int, optional (default=0)
120+
verbose : int, default=0
121121
Verbosity flag, controls the debug messages that are issued
122122
as functions are evaluated. The higher, the more verbose. Can be 0, 1,
123123
or 2.
124124
125-
random_state : int, RandomState instance or None, optional (default=None)
125+
random_state : int, RandomState instance or None, default=None
126126
The seed of the pseudo random number generator to use. Randomizes
127127
selection of estimator features if n_nearest_features is not None, the
128128
``imputation_order`` if ``random``, and the sampling from posterior if
129129
``sample_posterior`` is True. Use an integer for determinism.
130130
See :term:`the Glossary <random_state>`.
131131
132-
add_indicator : boolean, optional (default=False)
132+
add_indicator : boolean, default=False
133133
If True, a :class:`MissingIndicator` transform will stack onto output
134134
of the imputer's transform. This allows a predictive estimator
135135
to account for missingness despite imputation. If a feature has no
@@ -443,7 +443,7 @@ def _get_abs_corr_mat(self, X_filled, tolerance=1e-6):
443443
X_filled : ndarray, shape (n_samples, n_features)
444444
Input data with the most recent imputations.
445445
446-
tolerance : float, optional (default=1e-6)
446+
tolerance : float, default=1e-6
447447
``abs_corr_mat`` can have nans, which will be replaced
448448
with ``tolerance``.
449449

0 commit comments

Comments
 (0)
0