i have a dataset and i used it for some training model including CNN model.... for thr CNN model i changed my data shape into 2D to 3D and 1D to 2D...
X_train=np.dstack(X_train).T
X_test=np.dstack(X_test).T
Y_train = np.reshape(Y_train,( Y_train.size,1))
Y_test = np.reshape(Y_test,( Y_test.size,1))
now i need to find testing,there i got struck because already shape was changed... so in tesing the shape causing problem can anyone fix it
Testing code
from sklearn.metrics import confusion_matrix
for i in range(len(model)):
print('Model',i)
cm=confusion_matrix(Y_test,model[i].predict(X_test))
TP=cm[0][0]
TN=cm[1][1]
FN=cm[1][0]
FP=cm[0][1]
print(cm)
print('Testing Accuracy=',(TP+TN)/(TP+TN+FN+FP))
print()
converting shape or any other ideas will be helpful
print(X_train.shape, Y_train.shape)
print(X_test.shape, Y_test.shape)
shape of the values before (5273, 17) (5273,) (586, 17) (586,)
shape after reshape (5273, 17, 1) (5273, 1) (586, 17, 1) (586, 1)
Traceback
AttributeError Traceback (most recent call last)
<ipython-input-74-6a1c49606155> in <module>()
4 for i in range(len(model)):
5 print('Model',i)
----> 6 cm=confusion_matrix(Y_test,model[i].predict(X_test))
7 TP=cm[0][0]
8 TN=cm[1][1]
AttributeError: 'float' object has no attribute 'predict'
Aucun commentaire:
Enregistrer un commentaire