Converting Numpy Lstsq residual value to R^2
Posted
by whatnick
on Stack Overflow
See other posts from Stack Overflow
or by whatnick
Published on 2010-06-16T14:27:37Z
Indexed on
2010/06/16
23:22 UTC
Read the original article
Hit count: 158
I am performing a least squares regression as below (univariate). I would like to express the significance of the result in terms of R^2. Numpy returns a value of unscaled residual, what would be a sensible way of normalizing this.
field_clean,back_clean = rid_zeros(backscatter,field_data)
num_vals = len(field_clean)
x = field_clean[:,row:row+1]
y = 10*log10(back_clean)
A = hstack([x, ones((num_vals,1))])
soln = lstsq(A, y )
m, c = soln [0]
residues = soln [1]
print residues
© Stack Overflow or respective owner