Semi-supervised learning for regression by scikit-learn
<p>Can Label Propagation be used for semi-supervised regression tasks in scikit-learn?
According to its API, the answer is YES.
<a href="http://scikit-learn.org/stable/modules/label_propagation.html" rel="nofollow">http://scikit-learn.org/stable/modules/label_propagation.html</a></p>

<p>However, I got the error message when I tried to run the following code.</p>

<pre><code>from sklearn import datasets
from sklearn.semi_supervised import label_propagation
import numpy as np
rng=np.random.RandomState(0)
boston = datasets.load_boston()
X=boston.data
y=boston.target
y_30=np.copy(y)
y_30[rng.rand(len(y))&lt;0.3]=-999
label_propagation.LabelSpreading().fit(X,y_30)
</code></pre>

<hr>

<p>It shows that "ValueError: Unknown label type: 'continuous'" in the label_propagation.LabelSpreading().fit(X,y_30) line.</p>

<p>How should I solve the problem? Thanks a lot.</p>

<p>It looks like the error in the documentation, code itself clearly is classification only (beggining of the <code>.fit</code> call of the <a href="https://github.com/scikit-learn/scikit-learn/blob/412996f/sklearn/semi_supervised/label_propagation.py#L201" rel="nofollow">BasePropagation class</a>):</p>

<pre><code>    check_classification_targets(y)

    # actual graph construction (implementations should override this)
    graph_matrix = self._build_graph()

    # label construction
    # construct a categorical distribution for classification only
    classes = np.unique(y)
    classes = (classes[classes != -1])
</code></pre>

<p>In theory you could remove the "check_classification_targets" call and use "regression like method", but it will not be the true regression since you will never "propagate" any value which is not encountered in the training set, you will simply treat the regression value as the class identifier. And you will be unable to use value "-1" since it is a codename for "unlabeled"...</p>

python machine-learning scikit-learn regression