BernoulliRBM()如何进行预测呢?

preeminence1 2015-02-03 11:58:40
最近在学neural_network,不知道用BernoulliRBM训练完数据后,如何进行预测?代码如下,请高手指教

countErrorNN = 0
indexNN = (1-ratio)*m

NNClassifier = BernoulliRBM().fit(returnMat[0:(1-ratio)*m+1,:],classLevelVector[0:(1-ratio)*m+1])
for i in range(int(testTotal)):
preNumSVM = NNClassifier.predict(returnMat[indexNN,0:11])
print 'The real num in line ',indexNN,'is ',classLevelVector[indexNN],', the predict num is ', preNumSVM
if preNumSVM != classLevelVector[indexNN]:
countErrorNN +=1
indexNN +=1

accuracySVM = (testTotal-countErrorNN)/testTotal
print 'The accuracy is ',accuracySVM


因为BernoulliRBM没有predict方法,所以会报错,请问该如何进行预测呢?
...全文
554 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
weixin_38356581 2018-07-18
  • 打赏
  • 举报
回复
在RMB后接一个分类器试试:
countErrorNN = 0
indexNN = (1-ratio)*m
rbm=BernoulliRBM(random_state=0,verbose=True)
logistic=linear_model.LogisticRegression()
NNClassifier =Pipeline(steps=[('rbm',rbm),('logistic',logistic)])
NNClassifier .fit(returnMat[0:(1-ratio)*m+1,:],classLevelVector[0:(1-ratio)*m+1])
for i in range(int(testTotal)):
preNumSVM = NNClassifier.predict(returnMat[indexNN,0:11])
print 'The real num in line ',indexNN,'is ',classLevelVector[indexNN],', the predict num is ', preNumSVM
if preNumSVM != classLevelVector[indexNN]:
countErrorNN +=1
indexNN +=1

accuracySVM = (testTotal-countErrorNN)/testTotal
print 'The accuracy is ',accuracySVM
rushiruyan 2015-04-05
  • 打赏
  • 举报
回复
http://scikit-learn.org/dev/auto_examples/neural_networks/plot_rbm_logistic_classification.html

37,720

社区成员

发帖
与我相关
我的任务
社区描述
JavaScript,VBScript,AngleScript,ActionScript,Shell,Perl,Ruby,Lua,Tcl,Scala,MaxScript 等脚本语言交流。
社区管理员
  • 脚本语言(Perl/Python)社区
  • IT.BOB
加入社区
  • 近7日
  • 近30日
  • 至今

试试用AI创作助手写篇文章吧