R2 coefficient is often used to evaluate the effect of predicting the targets. In this tutorial, we will introduce some its basic information to help you understand and use it in machine learning.

**R2 coefficient formula**

where ** y_{ti}** is the

**-th true target,**

*i**is the*

**y**_{pi}**-th predicted target.**

*i***is the mean of**

*ý***.**

*y*_{0}…y_{n}**is the number of samples.**

*n***The value of R2**

The value R2 is in** [0,1]**

**The significance of R2**

We can use R2 coefficient to evaluate the effect of fitting true targets. The value of R2 is the bigger, the better.

For example, if there are two models on the same question.

Model 1: R2 = 0.8

Model 2: R2 = 0.7

We will choice model 1, which is better than model 2. Because 0.8 > 0.7.

**How to calculate R2 coefficient**

In scikit-learn, we can use

LinearRegression().score(X, y)

to calcuate R2 coefficient.