我在数据集(图像)上使用转移学习得到特征向量
X =
[[0.06381412 1.5189143 0.7007909 ... 0.22550535 0.56980544 0.07307615]
[0.06381412 1.5189143 0.7007909 ... 0.22550535 0.56980544 0.07307615]
[0.06381412 1.5189143 0.7007909 ... 0.22550535 0.56980544 0.07307615]
...
[0.06381412 1.5189143 0.7007909 ... 0.22550535 0.56980544 0.07307615]
[0.06381412 1.5189143 0.7007909 ... 0.22550535 0.56980544 0.07307615]
[0.06381412 1.5189143 0.7007909 ... 0.22550535 0.56980544 0.07307615]]
imgs_train, imgs_test, y_train, y_test, = train_test_split(X, Y,test_size=0.33, random_state=42)
Mrfc = RandomForestClassifier(n_estimators = 1000,
bootstrap = True,
oob_score = True,
criterion = 'gini',
max_features = 'auto',
max_depth = dep,
min_samples_split = int(3000),
min_samples_leaf = int(1000),
max_leaf_nodes = None,
n_jobs=-1
)
Mrfc.fit(imgs_train,y_train)
y_predict = Mrfc.predict(imgs_train)
y\u predict的输出均为零:
[0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. ...]
Y包含标签(0或1) 模型无法做出预测。我能做什么
会不会是这样的,你的标签中有歪斜的类,所以全零的预测实际上给了你很高的精确度?在这种情况下,您可能需要尝试为您的RandomForestClassifier设置class\u weight=“balanced”
相关问题 更多 >
编程相关推荐