freddyaboulton HF staff commited on
Commit
ef48b80
β€’
1 Parent(s): 0b06667
Files changed (3) hide show
  1. README.md +2 -2
  2. app.py +50 -0
  3. requirements.txt +4 -0
README.md CHANGED
@@ -1,8 +1,8 @@
1
  ---
2
  title: Timeseries Forecasting With Prophet
3
- emoji: πŸ¦€
4
  colorFrom: gray
5
- colorTo: pink
6
  sdk: gradio
7
  sdk_version: 3.1.7
8
  app_file: app.py
 
1
  ---
2
  title: Timeseries Forecasting With Prophet
3
+ emoji: πŸ“ˆ
4
  colorFrom: gray
5
+ colorTo: green
6
  sdk: gradio
7
  sdk_version: 3.1.7
8
  app_file: app.py
app.py ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import pypistats
3
+ from datetime import date
4
+ from dateutil.relativedelta import relativedelta
5
+ import pandas as pd
6
+ from prophet import Prophet
7
+
8
+
9
+ pd.options.plotting.backend = "plotly"
10
+
11
+
12
+ def get_forecast(lib, time):
13
+
14
+ data = pypistats.overall(lib, total=True, format="pandas")
15
+ data = data.groupby("category").get_group("with_mirrors").sort_values("date")
16
+ start_date = date.today() - relativedelta(months=int(time.split(" ")[0]))
17
+ df = data[(data['date'] > str(start_date))]
18
+
19
+ df1 = df[['date','downloads']]
20
+ df1.columns = ['ds','y']
21
+
22
+ m = Prophet()
23
+ m.fit(df1)
24
+ future = m.make_future_dataframe(periods=90)
25
+ forecast = m.predict(future)
26
+ fig1 = m.plot(forecast)
27
+ return fig1
28
+
29
+
30
+ with gr.Blocks() as demo:
31
+
32
+ gr.Markdown(
33
+ """
34
+ ## Pypi Download Stats πŸ“ˆ with Prophet Forecasting
35
+
36
+ See live download stats for popular open-source libraries πŸ€— along with a 3 month forecast using Prophet
37
+
38
+ The source is [here](https://huggingface.co/gradio/timeseries-forecasting-with-prophet).
39
+ """)
40
+ with gr.Row():
41
+ lib = gr.Dropdown(["pandas", "scikit-learn", "torch", "prophet"], label="Library", value="pandas")
42
+ time = gr.Dropdown(["3 months", "6 months", "9 months", "12 months"], label="Downloads over the last...", value="12 months")
43
+
44
+ plt = gr.Plot()
45
+
46
+ lib.change(get_forecast, [lib, time], plt)
47
+ time.change(get_forecast, [lib, time], plt)
48
+ demo.load(get_forecast, [lib, time], plt)
49
+
50
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ prophet==1.1
2
+ pandas
3
+ pypistats
4
+ plotly