oct*_*ian 1 python dataframe pandas scikit-learn
我有一个数据集df_train和一些标签df_train_labels。
print(df_train.shape)
print(df_train_labels.shape)
Run Code Online (Sandbox Code Playgroud)
输出:
(1460, 6)
(1460,)
Run Code Online (Sandbox Code Playgroud)
和
print(df_train[0:4])
print(df_train_labels[0:4])
Run Code Online (Sandbox Code Playgroud)
输出
OverallQual GrLivArea GarageCars TotalBsmtSF FullBath YearBuilt
0 1 0.000000 1 1 1 1
1 1 0.000000 0 1 0 1
2 0 0.693147 0 2 0 2
3 0 1.098612 1 3 1 3
0 2.505338
1 2.493950
2 2.510994
3 2.472277
Name: SalePrice, dtype: float64
Run Code Online (Sandbox Code Playgroud)
我正在尝试根据这些数据拟合模型:
from sklearn.ensemble import RandomForestClassifier
clf = RandomForestClassifier(n_estimators=10)
clf = clf.fit(df_train, df_train_labels)
Run Code Online (Sandbox Code Playgroud)
但是,最后一行失败并出现以下错误:
raise ValueError("Unknown label type: %r" % y_type)
ValueError: Unknown label type: 'continuous'
Run Code Online (Sandbox Code Playgroud)
知道可能出什么问题吗?
RandomForestClassifier似乎不适用于浮动,所以我改用了RandomForestRegressor。
| 归档时间: |
|
| 查看次数: |
15074 次 |
| 最近记录: |