美国疫情预测

2020-2-02,1,11
2020-2-12,1,13
2020-2-22,0,34
2020-3-03,16,105
2020-3-13,356,2235
2020-3-23,11219,46443
2020-4-02,27174,217263
2020-4-12,29129,530830
2020-4-22,17733,843981
2020-5-02,51428,1095023
2020-5-12,22802,1408636
2020-5-22,22140,1592723
2020-6-01,23225,1816820
2020-6-11,33388,2089626
2020-6-21,46042,2330578
2020-7-01,63860,2727853
2020-7-11,61848,3355646
2020-7-21,65279,3898550
2020-7-31,2773,4501116
2020-8-10,49721,5199444
2020-8-20,43947,5655974
2020-9-05,53813,6389057

import pandas as pd
from sklearn.linear_model import LinearRegression
from sklearn.preprocessing import PolynomialFeatures
import matplotlib.pyplot as plt
import numpy as np #做矩阵

data = pd.read_csv("data.txt",header=None)
data[0]=pd.to_datetime(data[0])

data=data.sort_index()
data.index =data[0]
totle=data[1]
print(data)
print(totle)

totle =totle.reset_index()[1]

totle.index=totle.index+1

plt.scatter(totle.index,totle)
liner_reg=LinearRegression()
x_data =totle.index[:,np.newaxis]
y_data=totle[:,np.newaxis]
liner_reg.fit(x_data,y_data)
plt.scatter(x_data,y_data)
plt.plot(x_data,liner_reg.predict(x_data))
plt.show()
liner_reg.coef_,liner_reg.intercept_
plt.scatter(x_data,y_data) 
poly=PolynomialFeatures(3)
x_data_poly=poly.fit_transform(x_data) 
liner_reg=LinearRegression() 
liner_reg.fit(x_data_poly,y_data)
plt.scatter(np.arange(1,40),liner_reg.predict([[i**0,i**1,i**2,i**3]for i in np.arange(1,40)]))
plt.show()

傻瓜预测法,没啥东西

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值