{"id":26295,"date":"2021-12-17T08:43:18","date_gmt":"2021-12-17T03:13:18","guid":{"rendered":"https:\/\/python-programs.com\/?p=26295"},"modified":"2021-12-17T08:43:18","modified_gmt":"2021-12-17T03:13:18","slug":"python-program-for-coefficient-of-determination-r-squared-value","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-for-coefficient-of-determination-r-squared-value\/","title":{"rendered":"Python Program for Coefficient of Determination \u2013 R Squared Value"},"content":{"rendered":"

Before delving into the topic of Coefficient of Determination, it is important to grasp the importance of evaluating a machine learning model using error metrics.<\/p>\n

To solve any model in the field of Data Science, the developer must first analyze the efficiency of the model before applying it to the dataset. The model is evaluated using specific error metrics. One such error metric is the coefficient of determination.<\/p>\n

Coefficient of Determination:<\/strong><\/p>\n

The coefficient of determination, often known as the R2 score. It is used to evaluate the performance of a linear regression model.<\/p>\n

It is the degree of variation in the output-dependent attribute that can be predicted based on the input independent variable (s). It is used to determine how effectively the model reproduces observed results, based on the ratio of total deviation of results explained by the model.<\/p>\n

R square has a range between [0,1].<\/p>\n

Formula<\/strong><\/p>\n

R2<\/sup>= 1- SSres\u00a0<\/sub>\/ SStot<\/sub><\/strong><\/p>\n

where.<\/p>\n

SSres:<\/strong> SSres is the sum of the squares of the residual errors of the data model’s
\nSStot: <\/sub><\/strong>The total sum of the errors is represented by SStot.<\/p>\n

Note:<\/strong> The higher the R square value, the better the model and the outcomes.<\/p>\n

R2<\/sup> With Numpy<\/strong><\/h4>\n

Example:<\/strong><\/p>\n

Approach:<\/strong><\/p>\n