8000 Labels don't stay clamped in LabelPropagation · Issue #3550 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

Labels don't stay clamped in LabelPropagation #3550

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

Closed
mattphotonman opened this issue Aug 11, 2014 · 5 comments
Closed

Labels don't stay clamped in LabelPropagation #3550

mattphotonman opened this issue Aug 11, 2014 · 5 comments
Labels
Milestone

Comments

@mattphotonman
Copy link

In some cases the labels don't stay clamped in LabelPropagation. For example:

from sklearn.semi_supervised import LabelPropagation
import numpy as np
lp = LabelPropagation(kernel = 'knn', n_neighbors = 2)
X = np.array([[1.,1.],[1.,0.],[0.,1.]])
y = np.array([1.,0.,-1.])
lp.fit(X,y)
print lp
print y
print lp.transduction_

# Produces:

LabelPropagation(alpha=1, gamma=20, kernel='knn', max_iter=30, n_neighbors=2,
         tol=0.001)
[ 1.  0. -1.]
[ 0.  0.  1.]

I think the problem occurs in label_propagation.py at line 235 and line 249. When alpha is equal to 1, y_static is set to 0 in line 235, and then line 249 doesn't change self.label_distributions_, whereas it should clamp the values of the labelled data points.

My understanding from the documentation is that for LabelPropagation it is always supposed to do hard clamping, and thus it should be completely independent of alpha. I'm not actually sure what the intention was here since the same fit method is used for LabelSpreading.

@kpysniak
Copy link
Contributor

@mattphotonman I think you're right. It seems like the alpha was not handled correctly and, currently, hard clamping takes place for alpha = 0.

@kpysniak
Copy link
Contributor

ping @GaelVaroquaux

@mattphotonman
Copy link
Author

Cool! (Do I have to close this?)

@kpysniak
Copy link
Contributor

If it's verified and confirmed to work, then it should be qualified to be get closed. However, we might wait for @GaelVaroquaux , because he marked the issue as a bug.

@amueller
Copy link
Member

We'll close the issue once the PR is merged. Sorry for the very slow reply.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants
0