簡體   English   中英

ValueError:需要超過1個值才能使用scikit-learn中的分類器解包

[英]ValueError: need more than 1 value to unpack with classifier in scikit-learn

我有以下代碼可從我的數據集中學習:

>>> train_features[:5]
array([[2.0, 9.0, 37.0, 0.0, 28.71, 0.0, 243.63, False],
       [2.0, 0.0, 4.0, 0.0, 0.0, 0.0, 6.3100000000000005, False],
       [2.0, 3.0, 3.0, 0.0, 28.07, 0.0, 28.07, False],
       [2.0, 1.0, 2.0, 0.0, 5.49, 0.0, 14.48, False],
       [2.0, 3.0, 3.0, 0.0, 7.4700000000000015, 0.0, 7.4700000000000015,
        False]], dtype=object)

>>> train_labels[:5]
array([ True, False,  True, False,  True], dtype=bool)

>>> rf = RandomForestClassifier(n_estimators=10) 
>>> rf.fit(train_labels, train_features)

我在fit函數上遇到此錯誤:

ValueError:需要多個值才能解壓

我相信這是一個格式錯誤。 scikit-learn期望什么價值? 我在scikit-learn手冊中找不到輸入參考。

唯一的錯誤是您以相反的順序傳遞了參數。 更換:

rf.fit(train_labels, train_features)

通過:

rf.fit(train_features,train_labels)

希望它能解決此問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM