8000 DOC fix docstring in semi_supervised module following doc guideline (… · jeremiedbb/scikit-learn@594fc85 · GitHub
[go: up one dir, main page]

Skip to content

Commit 594fc85

Browse files
shubchatglemaitre
authored andcommitted
DOC fix docstring in semi_supervised module following doc guideline (scikit-learn#16042)
1 parent dd93e01 commit 594fc85

File tree

1 file changed

+58
-56
lines changed

1 file changed

+58
-56
lines changed

sklearn/semi_supervised/_label_propagation.py

Lines changed: 58 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -76,29 +76,29 @@ class BaseLabelPropagation(ClassifierMixin, BaseEstimator, metaclass=ABCMeta):
7676
7777
Parameters
7878
----------
79-
kernel : {'knn', 'rbf', callable}
79+
kernel : {'knn', 'rbf'} or callable, default='rbf'
8080
String identifier for kernel function to use or the kernel function
8181
itself. Only 'rbf' and 'knn' strings are valid inputs. The function
82-
passed should take two inputs, each of shape [n_samples, n_features],
83-
and return a [n_samples, n_samples] shaped weight matrix
82+
passed should take two inputs, each of shape (n_samples, n_features),
83+
and return a (n_samples, n_samples) shaped weight matrix.
8484
85-
gamma : float
86-
Parameter for rbf kernel
85+
gamma : float, default=20
86+
Parameter for rbf kernel.
8787
88-
n_neighbors : integer > 0
89-
Parameter for knn kernel
88+
n_neighbors : int, default=7
89+
Parameter for knn kernel. Need to be strictly positive.
9090
91-
alpha : float
92-
Clamping factor
91+
alpha : float, default=1.0
92+
Clamping factor.
9393
94-
max_iter : integer
95-
Change maximum number of iterations allowed
94+
max_iter : int, default=30
95+
Change maximum number of iterations allowed.
9696
97-
tol : float
97+
tol : float, default=1e-3
9898
Convergence tolerance: threshold to consider the system at steady
99-
state
99+
state.
100100
101-
n_jobs : int or None, optional (default=None)
101+
n_jobs : int, default=None
102102
The number of parallel jobs to run.
103103
``None`` means 1 unless in a :obj:`joblib.parallel_backend` context.
104104
``-1`` means using all processors. See :term:`Glossary <n_jobs>`
@@ -158,11 +158,12 @@ def predict(self, X):
158158
Parameters
159159
----------
160160
X : array-like of shape (n_samples, n_features)
161+
The data matrix.
161162
162163
Returns
163164
-------
164-
y : array_like, shape = [n_samples]
165-
Predictions for input data
165+
y : ndarray of shape (n_samples,)
166+
Predictions for input data.
166167
"""
167168
probas = self.predict_proba(X)
168169
return self.classes_[np.argmax(probas, axis=1)].ravel()
@@ -177,12 +178,13 @@ def predict_proba(self, X):
177178
Parameters
178179
----------
179180
X : array-like of shape (n_samples, n_features)
181+
The data matrix.
180182
181183
Returns
182184
-------
183-
probabilities : array, shape = [n_samples, n_classes]
185+
probabilities : ndarray of shape (n_samples, n_classes)
184186
Normalized probability distributions across
185-
class labels
187+
class labels.
186188
"""
187189
check_is_fitted(self)
188190

@@ -211,15 +213,15 @@ def fit(self, X, y):
211213
Parameters
212214
----------
213215
X : array-like of shape (n_samples, n_features)
214-
A {n_samples by n_samples} size matrix will be created from this
216+
A matrix of shape (n_samples, n_samples) will be created from this.
215217
216-
y : array_like, shape = [n_samples]
217-
n_labeled_samples (unlabeled points are marked as -1)
218-
All unlabeled samples will be transductively assigned labels
218+
y : array-like of shape (n_samples,)
219+
`n_labeled_samples` (unlabeled points are marked as -1)
220+
All unlabeled samples will be transductively assigned labels.
219221
220222
Returns
221223
-------
222-
self : returns an instance of self.
224+
self : object
223225
"""
224226
X, y = check_X_y(X, y)
225227
self.X_ = X
@@ -307,43 +309,43 @@ class LabelPropagation(BaseLabelPropagation):
307309
308310
Parameters
309311
----------
310-
kernel : {'knn', 'rbf', callable}
312+
kernel : {'knn', 'rbf'} or callable, default='rbf'
311313
String identifier for kernel function to use or the kernel function
312314
itself. Only 'rbf' and 'knn' strings are valid inputs. The function
313-
passed should take two inputs, each of shape [n_samples, n_features],
314-
and return a [n_samples, n_samples] shaped weight matrix.
315+
passed should take two inputs, each of shape (n_samples, n_features),
316+
and return a (n_samples, n_samples) shaped weight matrix.
315317
316-
gamma : float
317-
Parameter for rbf kernel
318+
gamma : float, default=20
319+
Parameter for rbf kernel.
318320
319-
n_neighbors : integer > 0
320-
Parameter for knn kernel
321+
n_neighbors : int, default=7
322+
Parameter for knn kernel which need to be strictly positive.
321323
322-
max_iter : integer
323-
Change maximum number of iterations allowed
324+
max_iter : int, default=1000
325+
Change maximum number of iterations allowed.
324326
325-
tol : float
327+
tol : float, 1e-3
326328
Convergence tolerance: threshold to consider the system at steady
327-
state
329+
state.
328330
329-
n_jobs : int or None, optional (default=None)
331+
n_jobs : int, default=None
330332
The number of parallel jobs to run.
331333
``None`` means 1 unless in a :obj:`joblib.parallel_backend` context.
332334
``-1`` means using all processors. See :term:`Glossary <n_jobs>`
333335
for more details.
334336
335337
Attributes
336338
----------
337-
X_ : array, shape = [n_samples, n_features]
339+
X_ : ndarray of shape (n_samples, n_features)
338340
Input array.
339341
340-
classes_ : array, shape = [n_classes]
342+
classes_ : ndarray of shape (n_classes,)
341343
The distinct labels used in classifying instances.
342344
343-
label_distributions_ : array, shape = [n_samples, n_classes]
345+
label_distributions_ : ndarray of shape (n_samples, n_classes)
344346
Categorical distribution for each item.
345347
346-
transduction_ : array, shape = [n_samples]
348+
transduction_ : ndarray of shape (n_samples)
347349
Label assigned to each item via the transduction.
348350
349351
n_iter_ : int
@@ -413,50 +415,50 @@ class LabelSpreading(BaseLabelPropagation):
413415
414416
Parameters
415417
----------
416-
kernel : {'knn', 'rbf', callable}
418+
kernel : {'knn', 'rbf'} or callable, default='rbf'
417419
String identifier for kernel function to use or the kernel function
418420
itself. Only 'rbf' and 'knn' strings are valid inputs. The function
419-
passed should take two inputs, each of shape [n_samples, n_features],
420-
and return a [n_samples, n_samples] shaped weight matrix
421+
passed should take two inputs, each of shape (n_samples, n_features),
422+
and return a (n_samples, n_samples) shaped weight matrix.
421423
422-
gamma : float
423-
parameter for rbf kernel
424+
gamma : float, default=20
425+
Parameter for rbf kernel.
424426
425-
n_neighbors : integer > 0
426-
parameter for knn kernel
427+
n_neighbors : int, default=7
428+
Parameter for knn kernel which is a strictly positive integer.
427429
428-
alpha : float
430+
alpha : float, default=0.2
429431
Clamping factor. A value in (0, 1) that specifies the relative amount
430432
that an instance should adopt the information from its neighbors as
431433
opposed to its initial label.
432434
alpha=0 means keeping the initial label information; alpha=1 means
433435
replacing all initial information.
434436
435-
max_iter : integer
436-
maximum number of iterations allowed
437+
max_iter : int, default=30
438+
Maximum number of iterations allowed.
437439
438-
tol : float
440+
tol : float, default=1e-3
439441
Convergence tolerance: threshold to consider the system at steady
440-
state
442+
state.
441443
442-
n_jobs : int or None, optional (default=None)
444+
n_jobs : int, default=None
443445
The number of parallel jobs to run.
444446
``None`` means 1 unless in a :obj:`joblib.parallel_backend` context.
445447
``-1`` means using all processors. See :term:`Glossary <n_jobs>`
446448
for more details.
447449
448450
Attributes
449451
----------
450-
X_ : array, shape = [n_samples, n_features]
452+
X_ : ndarray of shape (n_samples, n_features)
451453
Input array.
452454
453-
classes_ : array, shape = [n_classes]
455+
classes_ : ndarray of shape (n_classes,)
454456
The distinct labels used in classifying instances.
455457
456-
label_distributions_ : array, shape = [n_samples, n_classes]
458+
label_distributions_ : ndarray of shape (n_samples, n_classes)
457459
Categorical distribution for each item.
458460
459-
transduction_ : array, shape = [n_samples]
461+
transduction_ : ndarray of shape (n_samples,)
460462
Label assigned to each item via the transduction.
461463
462464
n_iter_ : int

0 commit comments

Comments
 (0)
0