0

The main aim is to add a deep learning classification method like CNN as an individual in ensemble in python.
The following code works fine:

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

But, the error:

'NoneType' object has no attribute 'predict_proba' 

comes up once running eclf1=eclf1.predict(XTest).

Just in case, The CNN consists of _fit_ function for training, and the following function:

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  
Gal Dreiman
  • 3,969
  • 2
  • 21
  • 40
Amn Kh
  • 531
  • 3
  • 7
  • 19

1 Answers1

0

Can you elaborate better what you did and which error you came across?

By your question only I can assume you tried to call 'predic_proba' after the line eclf1=eclf1.predict(XTest). And of course this will turn on an error because the eclf1.predict(XTest) returns an array, which doesn't have a predict() method. Try just changing it to:

pred_results=eclf1.predict(XTest)
pred_result_probs = eclf1.predict_proba(XTest)