How Much Is Explained
Fit an ordinary least squares line to the points (x[i], y[i]) and return its R squared: the share of the variation in y that the line explains, from 0 to 1.
Example 1
x [0,1,2]
y [1,3,5]
returns 1.0
A perfect line explains everything.
Constraints
3 <= len(x) <= 40- Neither the xs nor the ys are all equal
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More statsmodels problems
- How Sure Is the SlopeBeginner
- Line Through ZeroBeginner
- Line Through the DataBeginner
- Reading Off the LineBeginner
- Room for the InterceptBeginner
- Slope From a TableBeginner
- What the Line MissesBeginner
- Echo of YesterdayEasy