Skip to content

Commit 68268eb

Browse files
glemaitrealfaro96
andauthored
DOC follow doc guideline in SelfTrainingClassifier (scikit-learn#18922)
Co-authored-by: Juan Carlos Alfaro Jiménez <[email protected]>
1 parent 313568b commit 68268eb

File tree

1 file changed

+37
-38
lines changed

1 file changed

+37
-38
lines changed

sklearn/semi_supervised/_self_training.py

Lines changed: 37 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -41,47 +41,46 @@ class SelfTrainingClassifier(MetaEstimatorMixin, BaseEstimator):
4141
Invoking the ``fit`` method will fit a clone of the passed estimator,
4242
which will be stored in the ``base_estimator_`` attribute.
4343
44-
criterion : {'threshold', 'k_best'}, optional \
45-
(default='threshold')
44+
criterion : {'threshold', 'k_best'}, default='threshold'
4645
The selection criterion used to select which labels to add to the
4746
training set. If 'threshold', pseudo-labels with prediction
4847
probabilities above `threshold` are added to the dataset. If 'k_best',
4948
the `k_best` pseudo-labels with highest prediction probabilities are
5049
added to the dataset. When using the 'threshold' criterion, a
5150
:ref:`well calibrated classifier <calibration>` should be used.
5251
53-
threshold : float, optional (default=0.75)
52+
threshold : float, default=0.75
5453
The decision threshold for use with `criterion='threshold'`.
5554
Should be in [0, 1). When using the 'threshold' criterion, a
5655
:ref:`well calibrated classifier <calibration>` should be used.
5756
58-
k_best : int, optional (default=10)
57+
k_best : int, default=10
5958
The amount of samples to add in each iteration. Only used when
6059
`criterion` is k_best'.
6160
62-
max_iter : int or ``None``, optional (default=10)
61+
max_iter : int or None, default=10
6362
Maximum number of iterations allowed. Should be greater than or equal
6463
to 0. If it is ``None``, the classifier will continue to predict labels
6564
until no new pseudo-labels are added, or all unlabeled samples have
6665
been labeled.
6766
68-
verbose: bool, (default=False)
67+
verbose: bool, default=False
6968
Enable verbose output.
7069
7170
Attributes
7271
----------
7372
base_estimator_ : estimator object
7473
The fitted estimator.
7574
76-
classes_ : array or list of array of shape (n_classes,)
75+
classes_ : ndarray or list of ndarray of shape (n_classes,)
7776
Class labels for each output. (Taken from the trained
78-
``base_estimator_``)
77+
``base_estimator_``).
7978
80-
transduction_ : array, shape=(n_samples,)
79+
transduction_ : ndarray of shape (n_samples,)
8180
The labels used for the final fit of the classifier, including
8281
pseudo-labels added during fit.
8382
84-
labeled_iter_ : array, shape=(n_samples,)
83+
labeled_iter_ : ndarray of shape (n_samples,)
8584
The iteration in which each sample was labeled. When a sample has
8685
iteration 0, the sample was already labeled in the original dataset.
8786
When a sample has iteration -1, the sample was not labeled in any
@@ -144,17 +143,17 @@ def fit(self, X, y):
144143
145144
Parameters
146145
----------
147-
X : array-like, shape = (n_samples, n_features)
148-
array representing the data
146+
X : {array-like, sparse matrix} of shape (n_samples, n_features)
147+
Array representing the data.
149148
150-
y : array-like, shape = (n_samples,)
151-
array representing the labels. Unlabeled samples should have the
149+
y : {array-like, sparse matrix} of shape (n_samples,)
150+
Array representing the labels. Unlabeled samples should have the
152151
label -1.
153152
154153
Returns
155154
-------
156155
self : object
157-
returns an instance of self.
156+
Returns an instance of self.
158157
"""
159158
# we need row slicing support for sparce matrices
160159
X, y = self._validate_data(X, y, accept_sparse=[
@@ -263,13 +262,13 @@ def predict(self, X):
263262
264263
Parameters
265264
----------
266-
X : array-like, shape=(n_samples, n_features)
267-
array representing the data
265+
X : {array-like, sparse matrix} of shape (n_samples, n_features)
266+
Array representing the data.
268267
269268
Returns
270269
-------
271-
y : array-like, shape=(n_samples,)
272-
array with predicted labels
270+
y : ndarray of shape (n_samples,)
271+
Array with predicted labels.
273272
"""
274273
check_is_fitted(self)
275274
return self.base_estimator_.predict(X)
@@ -279,30 +278,30 @@ def predict_proba(self, X):
279278
280279
Parameters
281280
----------
282-
X : array-like, shape=(n_samples, n_features)
283-
array representing the data
281+
X : {array-like, sparse matrix} of shape (n_samples, n_features)
282+
Array representing the data.
284283
285284
Returns
286285
-------
287-
y : array-like, shape=(n_samples, n_features)
288-
array with prediction probabilities
286+
y : ndarray of shape (n_samples, n_features)
287+
Array with prediction probabilities.
289288
"""
290289
check_is_fitted(self)
291290
return self.base_estimator_.predict_proba(X)
292291

293292
@if_delegate_has_method(delegate='base_estimator')
294293
def decision_function(self, X):
295-
"""Calls decision function of the base_estimator.
294+
"""Calls decision function of the `base_estimator`.
296295
297296
Parameters
298297
----------
299-
X : array-like, shape=(n_samples, n_features)
300-
array representing the data
298+
X : {array-like, sparse matrix} of shape (n_samples, n_features)
299+
Array representing the data.
301300
302301
Returns
303302
-------
304-
y : array-like, shape=(n_samples, n_features)
305-
result of the decision function of the base_estimator
303+
y : ndarray of shape (n_samples, n_features)
304+
Result of the decision function of the `base_estimator`.
306305
"""
307306
check_is_fitted(self)
308307
return self.base_estimator_.decision_function(X)
@@ -313,33 +312,33 @@ def predict_log_proba(self, X):
313312
314313
Parameters
315314
----------
316-
X : array-like, shape=(n_samples, n_features)
317-
array representing the data
315+
X : {array-like, sparse matrix} of shape (n_samples, n_features)
316+
Array representing the data.
318317
319318
Returns
320319
-------
321-
y : array-like, shape=(n_samples, n_features)
322-
array with log prediction probabilities
320+
y : ndarray of shape (n_samples, n_features)
321+
Array with log prediction probabilities.
323322
"""
324323
check_is_fitted(self)
325324
return self.base_estimator_.predict_log_proba(X)
326325

327326
@if_delegate_has_method(delegate='base_estimator')
328327
def score(self, X, y):
329-
"""Calls score on the base_estimator.
328+
"""Calls score on the `base_estimator`.
330329
331330
Parameters
332331
----------
333-
X : array-like, shape=(n_samples, n_features)
334-
array representing the data
332+
X : {array-like, sparse matrix} of shape (n_samples, n_features)
333+
Array representing the data.
335334
336-
y : array-like, shape=(n_samples,)
337-
array representing the labels
335+
y : array-like of shape (n_samples,)
336+
Array representing the labels.
338337
339338
Returns
340339
-------
341340
score : float
342-
result of calling score on the base_estimator
341+
Result of calling score on the `base_estimator`.
343342
"""
344343
check_is_fitted(self)
345344
return self.base_estimator_.score(X, y)

0 commit comments

Comments
 (0)