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:

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

  • $\begingroup$ "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 $\endgroup$
    – pcko1
    Jun 21, 2018 at 10:45
  • 1
    $\begingroup$ @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. $\endgroup$
    – n1k31t4
    Jun 21, 2018 at 10:54
  • $\begingroup$ Its a regression problem. How can i calculate tp,tn,fp,fn in this case_ $\endgroup$
    – Hazel
    Jun 21, 2018 at 12:09
  • $\begingroup$ @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. $\endgroup$
    – n1k31t4
    Jun 21, 2018 at 12:48

1 Answer 1


A confusion matrix can be drawn for a classification problem, where the Machine Learning Model (in your case LSTM) predicts the target variable into one of the N classes.

Can you confirm that your problem is a Classification problem and not a Regression one?

If in case you have a regression problem, then you might want to use a different evaluation metric.

  • $\begingroup$ its a regression problem. So how can i compute tp,fp tn ,fn in this case_ $\endgroup$
    – Hazel
    Jun 21, 2018 at 12:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.