8000 .LabelPropagation alpha = 1 might result in changes of initial labels · Issue #7967 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

.LabelPropagation alpha = 1 might result in changes of initial labels #7967

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
giasemidis opened this issue Dec 2, 2016 · 1 comment
Closed

Comments

@giasemidis
Copy link

Description

According to documentation in http://scikit-learn.org/stable/modules/label_propagation.html, when the alpha parameter, clamping factor, is 1, the algorithm performs hard clamping, which does not allow the labels to change cluster. However this is not the case in the following case. I copied and slightly changed the example found in http://scikit-learn.org/stable/modules/generated/sklearn.semi_supervised.LabelPropagation.html#sklearn.semi_supervised.LabelPropagation

Steps/Code to Reproduce

from sklearn import datasets
from sklearn.semi_supervised import LabelPropagation
import numpy as np

np.random.seed(1) # fix random seed

label_prop_model = LabelPropagation()
iris = datasets.load_iris()

inds = np.random.randint(0, 2,size=len(iris.target))

random_unlabeled_points = np.where(inds)
random_labeleled_points = np.where(inds == 0)
labels = np.copy(iris.target)
labels[random_unlabeled_points] = -1
label_prop_model.fit(iris.data, labels)
ypred = label_prop_model.transduction_

fracunchanged = sum(iris.target[random_labeleled_points] == ypred[random_labeleled_points])/len(iris.target[random_labeleled_points])
print(fracunchanged)

Expected Results

If for alpha = 1, the algorithm performs hard clamping, I was expecting the transduction labels of the labelled data to be unchanged and equal to the initial labels, therefore the printed fraction should be 1. Any deviation from 1 indicates something is wrong.

Actual Results

Actually, I am getting 0.985294117647, indicating some initial labels changed during transduction.

Versions

sklearn version: '0.18.1'
numpy version: '1.11.2'

@amueller
Copy link
Member
amueller commented Dec 3, 2016

Thanks for the report. However, this is a duplicate of #3550 and there is a suggested fix in #7970. You can help by reviewing the suggested fix.

@amueller amueller closed this as completed Dec 3, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
0