Spaces:
Runtime error
Runtime error
Upload with huggingface_hub
Browse files- DESCRIPTION.md +1 -0
- README.md +5 -6
- requirements.txt +4 -0
- run.py +41 -0
DESCRIPTION.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
A simple dashboard showing pypi stats for python libraries. Updates on load, and has no buttons!
|
README.md
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
emoji: π₯
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: gradio
|
| 7 |
sdk_version: 3.6
|
| 8 |
-
app_file:
|
| 9 |
pinned: false
|
| 10 |
---
|
| 11 |
-
|
| 12 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
+
|
| 2 |
---
|
| 3 |
+
title: timeseries-forecasting-with-prophet_main
|
| 4 |
emoji: π₯
|
| 5 |
+
colorFrom: indigo
|
| 6 |
+
colorTo: indigo
|
| 7 |
sdk: gradio
|
| 8 |
sdk_version: 3.6
|
| 9 |
+
app_file: run.py
|
| 10 |
pinned: false
|
| 11 |
---
|
|
|
|
|
|
requirements.txt
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
prophet==1.1
|
| 2 |
+
pandas
|
| 3 |
+
pypistats
|
| 4 |
+
plotlyhttps://gradio-main-build.s3.amazonaws.com/c3bec6153737855510542e8154391f328ac72606/gradio-3.6-py3-none-any.whl
|
run.py
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
pd.options.plotting.backend = "plotly"
|
| 8 |
+
|
| 9 |
+
def get_forecast(lib, time):
|
| 10 |
+
|
| 11 |
+
data = pypistats.overall(lib, total=True, format="pandas")
|
| 12 |
+
data = data.groupby("category").get_group("with_mirrors").sort_values("date")
|
| 13 |
+
start_date = date.today() - relativedelta(months=int(time.split(" ")[0]))
|
| 14 |
+
df = data[(data['date'] > str(start_date))]
|
| 15 |
+
|
| 16 |
+
df1 = df[['date','downloads']]
|
| 17 |
+
df1.columns = ['ds','y']
|
| 18 |
+
|
| 19 |
+
m = Prophet()
|
| 20 |
+
m.fit(df1)
|
| 21 |
+
future = m.make_future_dataframe(periods=90)
|
| 22 |
+
forecast = m.predict(future)
|
| 23 |
+
fig1 = m.plot(forecast)
|
| 24 |
+
return fig1
|
| 25 |
+
|
| 26 |
+
with gr.Blocks() as demo:
|
| 27 |
+
gr.Markdown(
|
| 28 |
+
"""
|
| 29 |
+
**Pypi Download Stats π with Prophet Forecasting**: see live download stats for popular open-source libraries π€ along with a 3 month forecast using Prophet. The [ source code for this Gradio demo is here](https://huggingface.co/spaces/gradio/timeseries-forecasting-with-prophet/blob/main/app.py).
|
| 30 |
+
""")
|
| 31 |
+
with gr.Row():
|
| 32 |
+
lib = gr.Dropdown(["pandas", "scikit-learn", "torch", "prophet"], label="Library", value="pandas")
|
| 33 |
+
time = gr.Dropdown(["3 months", "6 months", "9 months", "12 months"], label="Downloads over the last...", value="12 months")
|
| 34 |
+
|
| 35 |
+
plt = gr.Plot()
|
| 36 |
+
|
| 37 |
+
lib.change(get_forecast, [lib, time], plt, queue=False)
|
| 38 |
+
time.change(get_forecast, [lib, time], plt, queue=False)
|
| 39 |
+
demo.load(get_forecast, [lib, time], plt, queue=False)
|
| 40 |
+
|
| 41 |
+
demo.launch()
|