# Is there any way to calculate the true,false positives and negatives for a regression problem

I am trying to predict the glucose values of the patients for example values like 45,256,115 etc. based on some features. Currently I am calculating the accuracy in means of RMSE,MSE,R². Is there any way to calculate the accuracy in means of a confusion matrix by setting a threshold value like ±10 for the value predicted. For example if the actual value is 110 and my prediction is 100 then we can tell that's it's kind of accurate since 100+10=110 where 10 is the threshold value. Any suggestions and some code to elaborate it will be very helpful.

• What is it that you would like to do? Is it that you are not looking for a continuous outcome but rather something like "glucose is over a threshold", or is it that you would like a more in-depth view of the individual predictions and actuals? – S van Balen Feb 19 '20 at 8:48
• Yeah first I focused on continuous outcome but now I want to test how accurate the value can be predicted along with the threshold value without using regression scoring metrics. – HelloWorld Feb 19 '20 at 12:32
• How about reframing it in a classification problem? – S van Balen Feb 19 '20 at 15:04
• I don't think it can be reframed since I need to predict the blood glucose value.. any suggestion to reframe it ? – HelloWorld Feb 20 '20 at 2:20
• How about? glucose_value > THRESHOLD ? 1 : 0 Or binning it if you need more more resolution – S van Balen Feb 20 '20 at 8:11

if abs(y_pred[i] - y_true[i]) <= threshold: TP += 1 elif abs(y_pred[i] - y_true[i]) > threshold: TN += 1 ...