擅长:python、mysql、java
<p>我发现了问题。作为基本估计器,我设置了“DecisionTreeClassifier”。这是一个sting,没有fit()方法。AdaBoost不是字符串。在</p>
<pre><code>from sklearn.ensemble import AdaBoostClassifier
from sklearn.preprocessing import LabelEncoder
for label in dataset.columns:
dataset[label] = LabelEncoder().fit(dataset[label]).transform(dataset[label])
X = dataset.drop(['target'],axis=1)
Y = dataset['target']
AdaBoost = AdaBoostClassifier(n_estimators=400,learning_rate=0.01,algorithm='SAMME')
AdaBoost.fit(X,Y)
prediction = AdaBoost.score(X,Y)
print(prediction)
</code></pre>
<blockquote>
<p>0.9182668636139832</p>
</blockquote>