# R-squared for user-defined prediction algorithms

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?

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