Thanks to visit codestin.com
Credit goes to github.com

Skip to content

DOC Improve docs of BaseLabelPropagation.transduction_ #24985

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Dec 1, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions sklearn/semi_supervised/_label_propagation.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,10 @@ def predict(self, X):
y : ndarray of shape (n_samples,)
Predictions for input data.
"""
# Note: since `predict` does not accept semi-supervised labels as input,
# `fit(X, y).predict(X) != fit(X, y).transduction_`.
# Hence, `fit_predict` is not implemented.
# See https://github.com/scikit-learn/scikit-learn/pull/24898
probas = self.predict_proba(X)
return self.classes_[np.argmax(probas, axis=1)].ravel()

Expand Down Expand Up @@ -244,7 +248,7 @@ def fit(self, X, y):
y : array-like of shape (n_samples,)
Target class values with unlabeled points marked as -1.
All unlabeled samples will be transductively assigned labels
internally.
internally, which are stored in `transduction_`.

Returns
-------
Expand Down Expand Up @@ -371,7 +375,7 @@ class LabelPropagation(BaseLabelPropagation):
Categorical distribution for each item.

transduction_ : ndarray of shape (n_samples)
Label assigned to each item via the transduction.
Label assigned to each item during :term:`fit`.

n_features_in_ : int
Number of features seen during :term:`fit`.
Expand Down Expand Up @@ -466,7 +470,7 @@ def fit(self, X, y):
y : array-like of shape (n_samples,)
Target class values with unlabeled points marked as -1.
All unlabeled samples will be transductively assigned labels
internally.
internally, which are stored in `transduction_`.

Returns
-------
Expand Down Expand Up @@ -531,7 +535,7 @@ class LabelSpreading(BaseLabelPropagation):
Categorical distribution for each item.

transduction_ : ndarray of shape (n_samples,)
Label assigned to each item via the transduction.
Label assigned to each item during :term:`fit`.

n_features_in_ : int
Number of features seen during :term:`fit`.
Expand Down