如何在ensemble python中使用我自己的分类器

时间:2016-07-20 06:55:42

标签: python classification ensemble-learning sklearn-pandas

主要目的是在python的集合中添加像CNN这样的深度学习分类方法。
以下代码工作正常:

   clf1=CNN()   
   eclf1=VotingClassifier(estimators=[('lr', clf1)], voting='soft')
   eclf1=eclf1.fit(XTrain,YTrain)

但是,错误:

'NoneType' object has no attribute 'predict_proba' 
运行eclf1=eclf1.predict(XTest)后会出现

以防万一,CNN包含_fit_培训功能,以及以下功能:

def predict_proba(self,XTest):    
    #prediction=np.mean(np.argmax(teY, axis=1) == predict(teX))
    teX=XTest.reshape(len(XTest),3,112,112)
    p=predict(teX) 
    i = np.zeros((p.shape[0],p.max()+1))
    for x,y in enumerate(p):
        i[x,y] = 1 
    return i  

1 个答案:

答案 0 :(得分:0)

你能详细说明你做了什么以及你遇到了哪些错误?

根据您的问题,我可以假设您尝试拨打' predic_proba'在eclf1=eclf1.predict(XTest)行之后。当然,这将导致错误,因为eclf1.predict(XTest)返回一个没有predict()方法的数组。 尝试将其更改为:

pred_results=eclf1.predict(XTest)
pred_result_probs = eclf1.predict_proba(XTest)
相关问题