【问题标题】:Semi-supervised learning for regression by scikit-learn通过 scikit-learn 进行回归的半监督学习
【发布时间】:2017-02-28 22:29:52
【问题描述】:

标签传播可以用于 scikit-learn 中的半监督回归任务吗? 根据其 API,答案是肯定的。 http://scikit-learn.org/stable/modules/label_propagation.html

但是,当我尝试运行以下代码时收到错误消息。

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))<0.3]=-999
label_propagation.LabelSpreading().fit(X,y_30)

在 label_propagation.LabelSpreading().fit(X,y_30) 行中显示“ValueError: Unknown label type: 'continuous'”。

我应该如何解决这个问题?非常感谢。

【问题讨论】:

    标签: python machine-learning scikit-learn regression


    【解决方案1】:

    它看起来像文档中的错误,代码本身显然只是分类(BasePropagation class.fit 调用的开头):

        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])
    

    理论上,您可以删除“check_classification_targets”调用并使用“类回归方法”,但这不是真正的回归,因为您永远不会“传播”任何在训练集中没有遇到的值,您只需将回归值视为类标识符。而且您将无法使用值“-1”,因为它是“未标记”的代号...

    【讨论】:

      猜你喜欢
      • 2017-08-22
      • 2019-04-16
      • 2014-04-20
      • 2019-02-08
      • 2015-06-01
      • 2020-05-23
      • 2013-12-01
      • 2018-10-18
      相关资源
      最近更新 更多