数据预测,制做线性回归方程
import pandas
from matplotlib import pyplot
from scipy.stats import linregress
sale=pandas.read_excel(‘销售.xlsx‘,dtype={‘date‘:str})
slope,intercept,r,p,std_err=linregress(sale.index,sale.revenue)
exp=sale.index*slope+intercept
pyplot.scatter(sale.index,sale.revenue) #绘制散点图
pyplot.plot(sale.index,exp,color=‘red‘) #绘制直线图
pyplot.title(f"y={slope}*x+{intercept}") #得出线性回归方差
pyplot.xticks(sale.index,sale.date,rotation=45) #sale.index确定刻度大小,sale.date确定刻度上的数据
pyplot.tight_layout()
pyplot.show() 相关推荐
yangkang 2020-11-09
lbyd0 2020-11-17
KANSYOUKYOU 2020-11-16
wushengyong 2020-10-28
腾讯soso团队 2020-11-06
Apsaravod 2020-11-05
PeterChangyb 2020-11-05
gyunwh 2020-11-02