Skip to content

Commit ad4abdd

Browse files
committed
DOC cleanup some docstrings (not scipy standard yet)
1 parent ceb80b0 commit ad4abdd

File tree

1 file changed

+56
-55
lines changed

1 file changed

+56
-55
lines changed

sklearn/cross_validation.py

Lines changed: 56 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ class LeaveOneOut(object):
5252
5353
Parameters
5454
----------
55-
n: int
56-
Total number of elements
55+
n : int
56+
Total number of elements in dataset.
5757
58-
indices: boolean, optional (default True)
58+
indices : boolean, optional (default True)
5959
Return train/test split as arrays of indices, rather than a boolean
6060
mask array. Integer indices are required when dealing with sparse
6161
matrices, since those cannot be indexed by boolean masks.
@@ -81,7 +81,7 @@ class LeaveOneOut(object):
8181
[[1 2]] [[3 4]] [1] [2]
8282
8383
See also
84-
========
84+
--------
8585
LeaveOneLabelOut for splitting the data according to explicit,
8686
domain-specific stratification of the dataset.
8787
"""
@@ -126,13 +126,13 @@ class LeavePOut(object):
126126
127127
Parameters
128128
----------
129-
n: int
130-
Total number of elements
129+
n : int
130+
Total number of elements in dataset.
131131
132-
p: int
133-
Size of the test sets
132+
p : int
133+
Size of the test sets.
134134
135-
indices: boolean, optional (default True)
135+
indices : boolean, optional (default True)
136136
Return train/test split as arrays of indices, rather than a boolean
137137
mask array. Integer indices are required when dealing with sparse
138138
matrices, since those cannot be indexed by boolean masks.
@@ -200,7 +200,7 @@ def _validate_kfold(k, n_samples):
200200

201201

202202
class KFold(object):
203-
"""K-Folds cross validation iterator
203+
"""K-Folds cross validation iterator.
204204
205205
Provides train/test indices to split data in train test sets. Split
206206
dataset into k consecutive folds (without shuffling).
@@ -210,21 +210,21 @@ class KFold(object):
210210
211211
Parameters
212212
----------
213-
n: int
214-
Total number of elements
213+
n : int
214+
Total number of elements.
215215
216216
n_folds : int
217217
Number of folds.
218218
219-
indices: boolean, optional (default True)
219+
indices : boolean, optional (default True)
220220
Return train/test split as arrays of indices, rather than a boolean
221221
mask array. Integer indices are required when dealing with sparse
222222
matrices, since those cannot be indexed by boolean masks.
223223
224-
shuffle: boolean, optional
225-
whether to shuffle the data before splitting into batches
224+
shuffle : boolean, optional
225+
Whether to shuffle the data before splitting into batches.
226226
227-
random_state: int or RandomState
227+
random_state : int or RandomState
228228
Pseudo number generator state used for random sampling.
229229
230230
Examples
@@ -316,13 +316,13 @@ class StratifiedKFold(object):
316316
317317
Parameters
318318
----------
319-
y: array, [n_samples]
320-
Samples to split in K folds
319+
y : array-like, [n_samples]
320+
Samples to split in K folds.
321321
322322
n_folds : int
323323
Number of folds.
324324
325-
indices: boolean, optional (default True)
325+
indices : boolean, optional (default True)
326326
Return train/test split as arrays of indices, rather than a boolean
327327
mask array. Integer indices are required when dealing with sparse
328328
matrices, since those cannot be indexed by boolean masks.
@@ -414,7 +414,7 @@ class LeaveOneLabelOut(object):
414414
Arbitrary domain-specific stratification of the data to be used
415415
to draw the splits.
416416
417-
indices: boolean, optional (default True)
417+
indices : boolean, optional (default True)
418418
Return train/test split as arrays of indices, rather than a boolean
419419
mask array. Integer indices are required when dealing with sparse
420420
matrices, since those cannot be indexed by boolean masks.
@@ -499,7 +499,7 @@ class LeavePLabelOut(object):
499499
p : int
500500
Number of samples to leave out in the test split.
501501
502-
indices: boolean, optional (default True)
502+
indices : boolean, optional (default True)
503503
Return train/test split as arrays of indices, rather than a boolean
504504
mask array. Integer indices are required when dealing with sparse
505505
matrices, since those cannot be indexed by boolean masks.
@@ -574,7 +574,7 @@ class Bootstrap(object):
574574
"""Random sampling with replacement cross-validation iterator
575575
576576
Provides train/test indices to split data in train test sets
577-
while resampling the input n_bootstraps times: each time a new
577+
while resampling the input n_iterations times: each time a new
578578
random split of the data is performed and then samples are drawn
579579
(with replacement) on each side of the split to build the training
580580
and test sets.
@@ -911,7 +911,7 @@ class StratifiedShuffleSplit(object):
911911
912912
Parameters
913913
----------
914-
y: array, [n_samples]
914+
y : array, [n_samples]
915915
Labels of samples.
916916
917917
n_iterations : int (default 10)
@@ -928,7 +928,7 @@ class StratifiedShuffleSplit(object):
928928
int, represents the absolute number of train samples. If None,
929929
the value is automatically set to the complement of the test fraction.
930930
931-
indices: boolean, optional (default True)
931+
indices : boolean, optional (default True)
932932
Return train/test split as arrays of indices, rather than a boolean
933933
mask array. Integer indices are required when dealing with sparse
934934
matrices, since those cannot be indexed by boolean masks.
@@ -1044,36 +1044,37 @@ def cross_val_score(estimator, X, y=None, score_func=None, cv=None, n_jobs=1,
10441044
10451045
Parameters
10461046
----------
1047-
estimator: estimator object implementing 'fit'
1048-
The object to use to fit the data
1047+
estimator : estimator object implementing 'fit'
1048+
The object to use to fit the data.
10491049
1050-
X: array-like of shape at least 2D
1050+
X : array-like of shape at least 2D
10511051
The data to fit.
10521052
1053-
y: array-like, optional
1053+
y : array-like, optional
10541054
The target variable to try to predict in the case of
10551055
supervised learning.
10561056
1057-
score_func: callable, optional
1058-
callable, has priority over the score function in the estimator.
1057+
score_func : callable, optional
1058+
Score function to use for evaluation.
1059+
Has priority over the score function in the estimator.
10591060
In a non-supervised setting, where y is None, it takes the test
10601061
data (X_test) as its only argument. In a supervised setting it takes
10611062
the test target (y_true) and the test prediction (y_pred) as arguments.
10621063
1063-
cv: cross-validation generator, optional
1064+
cv : cross-validation generator, optional
10641065
A cross-validation generator. If None, a 3-fold cross
10651066
validation is used or 3-fold stratified cross-validation
10661067
when y is supplied and estimator is a classifier.
10671068
1068-
n_jobs: integer, optional
1069+
n_jobs : integer, optional
10691070
The number of CPUs to use to do the computation. -1 means
10701071
'all CPUs'.
10711072
1072-
verbose: integer, optional
1073-
The verbosity level
1073+
verbose : integer, optional
1074+
The verbosity level.
10741075
10751076
fit_params : dict, optional
1076-
parameters to pass to the fit method
1077+
Parameters to pass to the fit method of the estimator.
10771078
"""
10781079
X, y = check_arrays(X, y, sparse_format='csr')
10791080
cv = check_cv(cv, X, y, classifier=is_classifier(estimator))
@@ -1120,20 +1121,20 @@ def check_cv(cv, X=None, y=None, classifier=False):
11201121
11211122
Parameters
11221123
----------
1123-
cv: an integer, a cv generator instance, or None
1124+
cv : int, a cv generator instance, or None
11241125
The input specifying which cv generator to use. It can be an
11251126
integer, in which case it is the number of folds in a KFold,
11261127
None, in which case 3 fold is used, or another object, that
11271128
will then be used as a cv generator.
11281129
1129-
X: 2D ndarray
1130-
the data the cross-val object will be applied on
1130+
X : array-like
1131+
The data the cross-val object will be applied on.
11311132
1132-
y: 1D ndarray
1133-
the target variable for a supervised learning problem
1133+
y : array-like
1134+
The target variable for a supervised learning problem.
11341135
1135-
classifier: boolean optional
1136-
whether the task is a classification task, in which case
1136+
classifier : boolean optional
1137+
Whether the task is a classification task, in which case
11371138
stratified KFold will be used.
11381139
"""
11391140
is_sparse = sp.issparse(X)
@@ -1161,17 +1162,17 @@ def permutation_test_score(estimator, X, y, score_func, cv=None,
11611162
11621163
Parameters
11631164
----------
1164-
estimator: estimator object implementing 'fit'
1165-
The object to use to fit the data
1165+
estimator : estimator object implementing 'fit'
1166+
The object to use to fit the data.
11661167
1167-
X: array-like of shape at least 2D
1168+
X : array-like of shape at least 2D
11681169
The data to fit.
11691170
1170-
y: array-like
1171+
y : array-like
11711172
The target variable to try to predict in the case of
11721173
supervised learning.
11731174
1174-
score_func: callable
1175+
score_func : callable
11751176
Callable taking as arguments the test targets (y_test) and
11761177
the predicted targets (y_pred) and returns a float. The score
11771178
functions are expected to return a bigger value for a better result
@@ -1181,32 +1182,32 @@ def permutation_test_score(estimator, X, y, score_func, cv=None,
11811182
cv : integer or crossvalidation generator, optional
11821183
If an integer is passed, it is the number of fold (default 3).
11831184
Specific crossvalidation objects can be passed, see
1184-
sklearn.cross_validation module for the list of possible objects
1185+
sklearn.cross_validation module for the list of possible objects.
11851186
1186-
n_jobs: integer, optional
1187+
n_jobs : integer, optional
11871188
The number of CPUs to use to do the computation. -1 means
11881189
'all CPUs'.
11891190
1190-
labels: array-like of shape [n_samples] (optional)
1191+
labels : array-like of shape [n_samples] (optional)
11911192
Labels constrain the permutation among groups of samples with
11921193
a same label.
11931194
1194-
random_state: RandomState or an int seed (0 by default)
1195+
random_state : RandomState or an int seed (0 by default)
11951196
A random number generator instance to define the state of the
11961197
random permutations generator.
11971198
1198-
verbose: integer, optional
1199-
The verbosity level
1199+
verbose : integer, optional
1200+
The verbosity level.
12001201
12011202
Returns
12021203
-------
1203-
score: float
1204+
score : float
12041205
The true score without permuting targets.
12051206
12061207
permutation_scores : array, shape = [n_permutations]
12071208
The scores obtained for each permutations.
12081209
1209-
pvalue: float
1210+
pvalue : float
12101211
The returned value equals p-value if `score_func` returns bigger
12111212
numbers for better scores (e.g., zero_one). If `score_func` is rather a
12121213
loss function (i.e. when lower is better such as with

0 commit comments

Comments
 (0)