-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprophet.py
More file actions
74 lines (49 loc) · 1.51 KB
/
Copy pathprophet.py
File metadata and controls
74 lines (49 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# -*- coding: utf-8 -*-
"""Prophet.ipynb
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/1mk7ub7byvB_okkXhR0Mlqh4UNiVu4H9f
"""
import pandas as pd
dataset=pd.read_csv("/content/nation_level_daily.csv")
dataset
dataset.info()
dataset.isnull().sum(axis = 0)
data=[]
for i in range(0,190):
string=str(dataset["Date"][i].split(" ")[0]) + "-"
if(dataset["Date"][i].split(" ")[1]=="January"):
string+=str(1)
if(dataset["Date"][i].split(" ")[1]=="February"):
string+=str(2)
if(dataset["Date"][i].split(" ")[1]=="March"):
string+=str(3)
if(dataset["Date"][i].split(" ")[1]=="April"):
string+=str(4)
if(dataset["Date"][i].split(" ")[1]=="May"):
string+=str(5)
if(dataset["Date"][i].split(" ")[1]=="June"):
string+=str(6)
if(dataset["Date"][i].split(" ")[1]=="July"):
string+=str(7)
if(dataset["Date"][i].split(" ")[1]=="August"):
string+=str(8)
string+="-" + str(2020)
data.append(string)
dataset['Date']=data
dataset
dataset['Date'] = pd.to_datetime(dataset['Date'])
dataset
dataset.rename(columns = {'Daily Confirmed':'y'}, inplace = True)
dataset
from fbprophet import Prophet
model = Prophet()
dataset.rename(columns = {'Date':'ds'}, inplace = True)
dataset
model.fit(dataset)
fut = model.make_future_dataframe(periods = 13, freq = 'M')
fut
forecast = model.predict(fut)
forecast.tail()
forecast[['ds', 'yhat', 'yhat_lower', 'yhat_upper']].tail()
fig2 = model.plot_components(forecast)