[英]Pandas returns this: ValueError: Unknown label type: 'continuous'
我在使用 pandas 和 sklearn 進行機器學習時遇到了麻煩。 我的問題是
ValueError:未知標簽類型:“連續”
我試過
model = sklearn.tree.DecisionTreeClassifier()
model.fit(X, y)
並返回此錯誤:
ValueError Traceback (most recent call last)
<ipython-input-45-3caead2f350b> in <module>
----> 1 model.fit(ninp, out)
c:\users\user\appdata\local\programs\python\python38-32\lib\site-packages\sklearn\tree\_classes.py in fit(self, X, y, sample_weight, check_input, X_idx_sorted)
888 """
889
--> 890 super().fit(
891 X, y,
892 sample_weight=sample_weight,
c:\users\user\appdata\local\programs\python\python38-32\lib\site-packages\sklearn\tree\_classes.py in fit(self, X, y, sample_weight, check_input, X_idx_sorted)
179
180 if is_classification:
--> 181 check_classification_targets(y)
182 y = np.copy(y)
183
c:\users\user\appdata\local\programs\python\python38-32\lib\site-packages\sklearn\utils\multiclass.py in check_classification_targets(y)
170 if y_type not in ['binary', 'multiclass', 'multiclass-multioutput',
171 'multilabel-indicator', 'multilabel-sequences']:
--> 172 raise ValueError("Unknown label type: %r" % y_type)
173
174
ValueError: Unknown label type: 'continuous'
分類器將一組示例分類為離散類(即,它分配對應於 K 個類之一的標簽)。 如果您的目標( y
變量的內容)是連續的(例如介於 0 和 1 之間的浮點數),那么決策樹不知道如何處理它。
您有 2 個解決方案:
DecisionTreeRegressor
)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.