# Confusion Matrix of LSTM using Sklear getting error

I want to calculate the confusion Matrix of my LSTM model.
Shape of y_test= (17799,1)
y_Pred= (17799,1)

I used thefollowing code:
from sklearn.metrics import confusion_matrix
cm = confusion_matrix(y_test, y_pred)

getting following error:

raise ValueError("{0} is not supported".format(y_type))

ValueError: continuous is not supported

both y_test and y_predict are normalized using minmaxscaler(0,1)
first few rows of both varaibles looks like:
y_test={0,0,0,0.0216212}
y_predict={0.000433061,0.000433061,0.000433061,0.000450924}

Please suggest how to calculated confusion matrix, tp,fp,tn,fn .

• "ValueError: continuous is not supported": probably you have a regression problem (not classification), therefore confusion matrix cannot be calculated for the continuous (infinite) output range of the lstm Jun 21, 2018 at 10:45
• @Kaustubh is correct - you need to be sure it is classification, not regression. Here is a similar question, where I proposed a way to get a confision matrix, in case you do indeed have a regression problem. Jun 21, 2018 at 10:54
• Its a regression problem. How can i calculate tp,tn,fp,fn in this case_ Jun 21, 2018 at 12:09
• @Hazel - you basically need to make it a classification problem if you want to compute those metrics. Try the approach that I linked above. You need to make your target variable discrete, e.g. by predicting which bin the result comes into, instead of a concrete value. Jun 21, 2018 at 12:48