Skip to content

Commit

Permalink
DOC clean up assorted type specifications (scikit-learn#10441)
Browse files Browse the repository at this point in the history
  • Loading branch information
jnothman authored Jan 10, 2018
1 parent c7c14be commit c3bdc0a
Show file tree
Hide file tree
Showing 41 changed files with 78 additions and 107 deletions.
4 changes: 2 additions & 2 deletions sklearn/cluster/k_means_.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def _k_init(X, n_clusters, x_squared_norms, random_state, n_local_trials=None):
x_squared_norms : array, shape (n_samples,)
Squared Euclidean norm of each data point.
random_state : numpy.RandomState
random_state : RandomState
The generator used to initialize the centers.
n_local_trials : integer, optional
Expand Down Expand Up @@ -1495,7 +1495,7 @@ def _labels_inertia_minibatch(self, X):
Returns
-------
labels : array, shap (n_samples,)
labels : array, shape (n_samples,)
Cluster labels for each point.
inertia : float
Expand Down
11 changes: 6 additions & 5 deletions sklearn/covariance/empirical_covariance_.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def empirical_covariance(X, assume_centered=False):
X : ndarray, shape (n_samples, n_features)
Data from which to compute the covariance estimate
assume_centered : Boolean
assume_centered : boolean
If True, data are not centered before computation.
Useful when working with data whose mean is almost, but not exactly
zero.
Expand Down Expand Up @@ -142,7 +142,7 @@ def get_precision(self):
Returns
-------
precision_ : array-like,
precision_ : array-like
The precision matrix associated to the current covariance object.
"""
Expand All @@ -162,12 +162,12 @@ def fit(self, X, y=None):
Training data, where n_samples is the number of samples and
n_features is the number of features.
y : not used, present for API consistence purpose.
y
not used, present for API consistence purpose.
Returns
-------
self : object
Returns self.
"""
X = check_array(X)
Expand All @@ -193,7 +193,8 @@ def score(self, X_test, y=None):
X_test is assumed to be drawn from the same distribution than
the data used in fit (including centering).
y : not used, present for API consistence purpose.
y
not used, present for API consistence purpose.
Returns
-------
Expand Down
2 changes: 1 addition & 1 deletion sklearn/covariance/graph_lasso_.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ class GraphLassoCV(GraphLasso):
If verbose is True, the objective function and duality gap are
printed at each iteration.
assume_centered : Boolean
assume_centered : boolean
If True, data are not centered before computation.
Useful when working with data whose mean is almost, but not exactly
zero.
Expand Down
6 changes: 3 additions & 3 deletions sklearn/covariance/robust_covariance.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ class MinCovDet(EmpiricalCovariance):
store_precision : bool
Specify if the estimated precision is stored.
assume_centered : Boolean
assume_centered : bool
If True, the support of the robust location and the covariance
estimates is computed, and a covariance estimate is recomputed from
it, without centering the data.
Expand Down Expand Up @@ -606,12 +606,12 @@ def fit(self, X, y=None):
Training data, where n_samples is the number of samples
and n_features is the number of features.
y : not used, present for API consistence purpose.
y
not used, present for API consistence purpose.
Returns
-------
self : object
Returns self.
"""
X = check_array(X, ensure_min_samples=2, estimator='MinCovDet')
Expand Down
14 changes: 7 additions & 7 deletions sklearn/covariance/shrunk_covariance_.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,12 @@ def fit(self, X, y=None):
Training data, where n_samples is the number of samples
and n_features is the number of features.
y : not used, present for API consistence purpose.
y
not used, present for API consistence purpose.
Returns
-------
self : object
Returns self.
"""
X = check_array(X)
Expand Down Expand Up @@ -157,7 +157,7 @@ def ledoit_wolf_shrinkage(X, assume_centered=False, block_size=1000):
X : array-like, shape (n_samples, n_features)
Data from which to compute the Ledoit-Wolf shrunk covariance shrinkage.
assume_centered : Boolean
assume_centered : bool
If True, data are not centered before computation.
Useful to work with data whose mean is significantly equal to
zero but is not exactly zero.
Expand Down Expand Up @@ -380,12 +380,12 @@ def fit(self, X, y=None):
X : array-like, shape = [n_samples, n_features]
Training data, where n_samples is the number of samples
and n_features is the number of features.
y : not used, present for API consistence purpose.
y
not used, present for API consistence purpose.
Returns
-------
self : object
Returns self.
"""
# Not calling the parent object to fit, to avoid computing the
Expand Down Expand Up @@ -537,12 +537,12 @@ def fit(self, X, y=None):
X : array-like, shape = [n_samples, n_features]
Training data, where n_samples is the number of samples
and n_features is the number of features.
y : not used, present for API consistence purpose.
y
not used, present for API consistence purpose.
Returns
-------
self : object
Returns self.
"""
X = check_array(X)
Expand Down
3 changes: 2 additions & 1 deletion sklearn/cross_decomposition/pls_.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ class _PLS(six.with_metaclass(ABCMeta), BaseEstimator, TransformerMixin,
The algorithm used to estimate the weights. It will be called
n_components times, i.e. once for each iteration of the outer loop.
max_iter : an integer, the maximum number of iterations (default 500)
max_iter : int (default 500)
The maximum number of iterations
of the NIPALS inner loop (used only if algorithm="nipals")
tol : non-negative real, default 1e-06
Expand Down
11 changes: 6 additions & 5 deletions sklearn/datasets/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,20 +212,21 @@ def load_data(module_path, data_file_name):
Parameters
----------
data_file_name : String. Name of csv file to be loaded from
module_path/data/data_file_name. For example 'wine_data.csv'.
data_file_name : string
Name of csv file to be loaded from
module_path/data/data_file_name. For example 'wine_data.csv'.
Returns
-------
data : Numpy Array
data : Numpy array
A 2D array with each row representing one sample and each column
representing the features of a given sample.
target : Numpy Array
target : Numpy array
A 1D array holding target variables for all the samples in `data.
For example target[0] is the target varible for data[0].
target_names : Numpy Array
target_names : Numpy array
A 1D array containing the names of the classifications. For example
target_names[0] is the name of the target[0] class.
"""
Expand Down
15 changes: 9 additions & 6 deletions sklearn/datasets/mlcomp.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,17 @@ def load_mlcomp(name_or_id, set_="raw", mlcomp_root=None, **kwargs):
Parameters
----------
name_or_id : the integer id or the string name metadata of the MLComp
dataset to load
name_or_id : int or str
The integer id or the string name metadata of the MLComp
dataset to load
set_ : select the portion to load: 'train', 'test' or 'raw'
set_ : str, default='raw'
Select the portion to load: 'train', 'test' or 'raw'
mlcomp_root : the filesystem path to the root folder where MLComp datasets
are stored, if mlcomp_root is None, the MLCOMP_DATASETS_HOME
environment variable is looked up instead.
mlcomp_root : str, optional
The filesystem path to the root folder where MLComp datasets
are stored, if mlcomp_root is None, the MLCOMP_DATASETS_HOME
environment variable is looked up instead.
**kwargs : domain specific kwargs to be passed to the dataset loader.
Expand Down
2 changes: 0 additions & 2 deletions sklearn/dummy.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ def fit(self, X, y, sample_weight=None):
Returns
-------
self : object
Returns self.
"""
if self.strategy not in ("most_frequent", "stratified", "uniform",
"constant", "prior"):
Expand Down Expand Up @@ -386,7 +385,6 @@ def fit(self, X, y, sample_weight=None):
Returns
-------
self : object
Returns self.
"""
if self.strategy not in ("mean", "median", "quantile", "constant"):
raise ValueError("Unknown strategy type: %s, expected "
Expand Down
2 changes: 1 addition & 1 deletion sklearn/ensemble/_gradient_boosting.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ def _random_sample_mask(np.npy_intp n_total_samples,
n_total_in_bag : int
The number of elements in the sample mask which are set to 1.
random_state : np.RandomState
random_state : RandomState
A numpy ``RandomState`` object.
Returns
Expand Down
2 changes: 0 additions & 2 deletions sklearn/ensemble/bagging.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@ def fit(self, X, y, sample_weight=None):
Returns
-------
self : object
Returns self.
"""
return self._fit(X, y, self.max_samples, sample_weight=sample_weight)

Expand Down Expand Up @@ -275,7 +274,6 @@ def _fit(self, X, y, max_samples=None, max_depth=None, sample_weight=None):
Returns
-------
self : object
Returns self.
"""
random_state = check_random_state(self.random_state)

Expand Down
2 changes: 0 additions & 2 deletions sklearn/ensemble/forest.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,6 @@ def fit(self, X, y, sample_weight=None):
Returns
-------
self : object
Returns self.
"""
# Validate or convert input data
X = check_array(X, accept_sparse="csc", dtype=DTYPE)
Expand Down Expand Up @@ -1895,7 +1894,6 @@ def fit(self, X, y=None, sample_weight=None):
Returns
-------
self : object
Returns self.
"""
self.fit_transform(X, y, sample_weight=sample_weight)
Expand Down
9 changes: 4 additions & 5 deletions sklearn/ensemble/gradient_boosting.py
Original file line number Diff line number Diff line change
Expand Up @@ -987,7 +987,6 @@ def fit(self, X, y, sample_weight=None, monitor=None):
Returns
-------
self : object
Returns self.
"""
# if not warmstart - clear the estimator state
if not self.warm_start:
Expand Down Expand Up @@ -1412,7 +1411,7 @@ class GradientBoostingClassifier(BaseGradientBoosting, ClassifierMixin):
.. versionadded:: 0.19
init : BaseEstimator, None, optional (default=None)
init : estimator, optional
An estimator object that is used to compute the initial
predictions. ``init`` has to provide ``fit`` and ``predict``.
If None it uses ``loss.init_estimator``.
Expand Down Expand Up @@ -1493,7 +1492,7 @@ class GradientBoostingClassifier(BaseGradientBoosting, ClassifierMixin):
loss_ : LossFunction
The concrete ``LossFunction`` object.
init_ : BaseEstimator
init_ : estimator
The estimator that provides the initial predictions.
Set via the ``init`` argument or ``loss.init_estimator``.
Expand Down Expand Up @@ -1870,7 +1869,7 @@ class GradientBoostingRegressor(BaseGradientBoosting, RegressorMixin):
The alpha-quantile of the huber loss function and the quantile
loss function. Only if ``loss='huber'`` or ``loss='quantile'``.
init : BaseEstimator, None, optional (default=None)
init : estimator, optional (default=None)
An estimator object that is used to compute the initial
predictions. ``init`` has to provide ``fit`` and ``predict``.
If None it uses ``loss.init_estimator``.
Expand Down Expand Up @@ -1945,7 +1944,7 @@ class GradientBoostingRegressor(BaseGradientBoosting, RegressorMixin):
loss_ : LossFunction
The concrete ``LossFunction`` object.
init_ : BaseEstimator
init_ : estimator
The estimator that provides the initial predictions.
Set via the ``init`` argument or ``loss.init_estimator``.
Expand Down
1 change: 0 additions & 1 deletion sklearn/ensemble/iforest.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ def fit(self, X, y=None, sample_weight=None):
Returns
-------
self : object
Returns self.
"""
X = check_array(X, accept_sparse=['csc'])
if issparse(X):
Expand Down
2 changes: 1 addition & 1 deletion sklearn/ensemble/voting_classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ def set_params(self, **params):
Parameters
----------
params: keyword arguments
params : keyword arguments
Specific parameters using e.g. set_params(parameter_name=new_value)
In addition, to setting the parameters of the ``VotingClassifier``,
the individual classifiers of the ``VotingClassifier`` can also be
Expand Down
9 changes: 3 additions & 6 deletions sklearn/ensemble/weight_boosting.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ def fit(self, X, y, sample_weight=None):
Returns
-------
self : object
Returns self.
"""
# Check parameters
if self.learning_rate <= 0:
Expand Down Expand Up @@ -188,7 +187,7 @@ def _boost(self, iboost, X, y, sample_weight, random_state):
sample_weight : array-like of shape = [n_samples]
The current sample weights.
random_state : numpy.RandomState
random_state : RandomState
The current random number generator
Returns
Expand Down Expand Up @@ -403,7 +402,6 @@ def fit(self, X, y, sample_weight=None):
Returns
-------
self : object
Returns self.
"""
# Check that algorithm is supported
if self.algorithm not in ('SAMME', 'SAMME.R'):
Expand Down Expand Up @@ -452,7 +450,7 @@ def _boost(self, iboost, X, y, sample_weight, random_state):
sample_weight : array-like of shape = [n_samples]
The current sample weights.
random_state : numpy.RandomState
random_state : RandomState
The current random number generator
Returns
Expand Down Expand Up @@ -949,7 +947,6 @@ def fit(self, X, y, sample_weight=None):
Returns
-------
self : object
Returns self.
"""
# Check loss
if self.loss not in ('linear', 'square', 'exponential'):
Expand Down Expand Up @@ -986,7 +983,7 @@ def _boost(self, iboost, X, y, sample_weight, random_state):
sample_weight : array-like of shape = [n_samples]
The current sample weights.
random_state : numpy.RandomState
random_state : RandomState
The current random number generator
Returns
Expand Down
2 changes: 0 additions & 2 deletions sklearn/feature_selection/from_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ def fit(self, X, y=None, **fit_params):
Returns
-------
self : object
Returns self.
"""
if self.prefit:
raise NotFittedError(
Expand Down Expand Up @@ -192,7 +191,6 @@ def partial_fit(self, X, y=None, **fit_params):
Returns
-------
self : object
Returns self.
"""
if self.prefit:
raise NotFittedError(
Expand Down
Loading

0 comments on commit c3bdc0a

Please sign in to comment.