[英]Slope from linear regression
I have a plot- 我有个阴谋
When I am trying to do linear regression on it- 当我尝试对其进行线性回归时-
df=pd.read_csv('tau.csv')
xx= df['xx'].tolist()
yy=df['yy'].tolist()
from scipy.stats import linregress
#print(linregress(xx,yy))
slope, intercept, r_value, p_value, std_err=linregress(xx,yy)
print(slope)
plt.plot(xx,yy,'ro')
plt.xlabel('log(l)')
plt.ylabel('log(Rl)')
plt.title('Fractal dimension with '+str(slope))
plt.show()
I get the slope as nan. 我得到的坡度为南。
my data- 我的数据
Looks like you have nan
in your data: 看起来您的数据中有
nan
:
x = [1,2, np.nan]
y = [2,4,6]
linregress(x,y)
>>> LinregressResult(slope=nan, intercept=nan, rvalue=nan, pvalue=nan, stderr=nan)
Also, you don't need to convert series to list, you can certainly do: 另外,您不需要将系列转换为列表,当然可以这样做:
lingress(df['xx'], df['yy'])
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.