Skip to content
DeepForgeby svx
All problems
EasyStatisticsst-345

R Squared from Sums

Problem

The coefficient of determination is R^2 = 1 - SSE / TSS.

Given the residual sum of squares and the total sum of squares (TSS > 0), return R^2.

Hint

It is the fraction of variance not left in residuals.

Test cases

case 1
in: [10,100]
expected: 0.9
case 2
in: [0,50]
expected: 1
case 3
in: [25,25]
expected: 0
Starter codePython
def r_squared_from_sums(sse, tss):
    # Your code here
    pass

3 test cases · run your code against them in the editor