我尝试使用带有RBM和MLPclassifier的管道,我的输入数据将首先传递给rbm,将降维(从513个特性降到100个特性(节点)),我成功地编写了代码,它似乎是正确的,但我最终得到了这个错误
UndefinedMetricWarning:在没有预测样本的标签中,精度和F分数定义不清,并被设置为0.0。“精度”,“预测”,平均值,warn_for)
precision recall f1-score support
0 0.00 0.00 0.00 25
1 0.00 0.00 0.00 28
2 0.00 0.00 0.00 28
3 0.00 0.00 0.00 34
4 0.00 0.00 0.00 25
avg / total 0.00 0.00 0.00 140这是我的密码
X_train, X_test, Y_train, Y_test = train_test_split(X,
Y,test_size=0.2,random_state=0)
mlp = MLPClassifier(hidden_layer_sizes=100,activation="tanh",max_iter=200)
rbm = BernoulliRBM(random_state=0, verbose=True)
classifier = Pipeline(steps=[('rbm', rbm), ('mlpclassifier', mlp)])
rbm.learning_rate = 0.06
rbm.n_iter = 20
rbm.n_components = 100
classifier.fit(X_train, Y_train)
print("MLP using RBM features:\n%s\n" % (metrics.classification_report(Y_test,
classifier.predict(X_test))))发布于 2017-08-03 07:48:38
谢谢你的回答,库马尔,我试着从测试集中抽取一个样本,并做一个预测。
print('the real label', Y_train[0])
print('the prediction', classifier.predict(X_train[0].reshape(1,-1)))这就是我作为输出所得到的
the real label [1 0 0 0 0]
the prediction [[0 0 0 0 0]]在我看来,分类器(管道)似乎没有经过训练!!
https://stackoverflow.com/questions/45473245
复制相似问题