1

I've been working on a machine learning project for a while and I've come up with an algorithm that does what I want it to do (predict some values). I wondered if it is possible to calculate R-squared for my results.

My results are like this (test):

Predictions  Observations:
4.25         4.30
4.15         4.25
3.70         3.75
3.25         3.15
...

How can I calculate R-squared for this?

Comp_Warrior
  • 2,173
Sinead
  • 13

1 Answers1

0

To calculate an R-squared with the above results, you can perform simple linear regression with Predictions as your predictor, x, variable and Observations as your outcome, y, variable using any standard statistical program.

The below R code will allow you to do so:

slr <- lm(Observations ~ Predictions, data=yourdata)

summary(slr)

  • 1
    Also, R-squared here is just the square of the Pearson correlation, to be calculated using the appropriate function or command in your favourite software. – Nick Cox Sep 03 '13 at 15:22
  • @NickCox, you are very correct as well (thanks for adding that to my answer), Sinead, whichever approach you choose will net you the same R-squared, cheers! – Matt Reichenbach Sep 03 '13 at 15:32