Spaces:
Running
Running
Commit
•
7fd8a26
1
Parent(s):
cc80480
Upload folder using huggingface_hub
Browse files
README.md
CHANGED
@@ -1,12 +1,12 @@
|
|
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
emoji:
|
4 |
colorFrom: indigo
|
5 |
colorTo: indigo
|
6 |
sdk: gradio
|
7 |
sdk_version: 4.42.0
|
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: scatter_plot_demo_main
|
4 |
+
emoji: 🔥
|
5 |
colorFrom: indigo
|
6 |
colorTo: indigo
|
7 |
sdk: gradio
|
8 |
sdk_version: 4.42.0
|
9 |
+
app_file: run.py
|
10 |
pinned: false
|
11 |
+
hf_oauth: true
|
12 |
---
|
|
|
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
gradio-client @ git+https://github.com/gradio-app/gradio@8f5a8950c949996f7c439b11a7aa40edda3e8562#subdirectory=client/python
|
2 |
+
https://gradio-pypi-previews.s3.amazonaws.com/8f5a8950c949996f7c439b11a7aa40edda3e8562/gradio-4.42.0-py3-none-any.whl
|
run.ipynb
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: scatter_plot_demo"]}, {"cell_type": "code", "execution_count": null, "id": "272996653310673477252411125948039410165", "metadata": {}, "outputs": [], "source": ["!pip install -q gradio "]}, {"cell_type": "code", "execution_count": null, "id": "288918539441861185822528903084949547379", "metadata": {}, "outputs": [], "source": ["import pandas as pd\n", "from random import randint, random\n", "import gradio as gr\n", "\n", "\n", "temp_sensor_data = pd.DataFrame(\n", " {\n", " \"time\": pd.date_range(\"2021-01-01\", end=\"2021-01-05\", periods=200),\n", " \"temperature\": [randint(50 + 10 * (i % 2), 65 + 15 * (i % 2)) for i in range(200)],\n", " \"humidity\": [randint(50 + 10 * (i % 2), 65 + 15 * (i % 2)) for i in range(200)],\n", " \"location\": [\"indoor\", \"outdoor\"] * 100,\n", " }\n", ")\n", "\n", "food_rating_data = pd.DataFrame(\n", " {\n", " \"cuisine\": [[\"Italian\", \"Mexican\", \"Chinese\"][i % 3] for i in range(100)],\n", " \"rating\": [random() * 4 + 0.5 * (i % 3) for i in range(100)],\n", " \"price\": [randint(10, 50) + 4 * (i % 3) for i in range(100)],\n", " \"wait\": [random() for i in range(100)],\n", " }\n", ")\n", "\n", "with gr.Blocks() as scatter_plots:\n", " with gr.Row():\n", " start = gr.DateTime(\"2021-01-01 00:00:00\", label=\"Start\")\n", " end = gr.DateTime(\"2021-01-05 00:00:00\", label=\"End\")\n", " apply_btn = gr.Button(\"Apply\", scale=0)\n", " with gr.Row():\n", " group_by = gr.Radio([\"None\", \"30m\", \"1h\", \"4h\", \"1d\"], value=\"None\", label=\"Group by\")\n", " aggregate = gr.Radio([\"sum\", \"mean\", \"median\", \"min\", \"max\"], value=\"sum\", label=\"Aggregation\")\n", "\n", " temp_by_time = gr.ScatterPlot(\n", " temp_sensor_data,\n", " x=\"time\",\n", " y=\"temperature\",\n", " )\n", " temp_by_time_location = gr.ScatterPlot(\n", " temp_sensor_data,\n", " x=\"time\",\n", " y=\"temperature\",\n", " color=\"location\",\n", " )\n", "\n", " time_graphs = [temp_by_time, temp_by_time_location]\n", " group_by.change(\n", " lambda group: [gr.ScatterPlot(x_bin=None if group == \"None\" else group)] * len(time_graphs),\n", " group_by,\n", " time_graphs\n", " )\n", " aggregate.change(\n", " lambda aggregate: [gr.ScatterPlot(y_aggregate=aggregate)] * len(time_graphs),\n", " aggregate,\n", " time_graphs\n", " )\n", "\n", " price_by_cuisine = gr.ScatterPlot(\n", " food_rating_data,\n", " x=\"cuisine\",\n", " y=\"price\",\n", " )\n", " with gr.Row():\n", " price_by_rating = gr.ScatterPlot(\n", " food_rating_data,\n", " x=\"rating\",\n", " y=\"price\",\n", " color=\"wait\",\n", " show_actions_button=True,\n", " )\n", " price_by_rating_color = gr.ScatterPlot(\n", " food_rating_data,\n", " x=\"rating\",\n", " y=\"price\",\n", " color=\"cuisine\",\n", " )\n", "\n", "if __name__ == \"__main__\":\n", " scatter_plots.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
|
run.py
ADDED
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import pandas as pd
|
2 |
+
from random import randint, random
|
3 |
+
import gradio as gr
|
4 |
+
|
5 |
+
|
6 |
+
temp_sensor_data = pd.DataFrame(
|
7 |
+
{
|
8 |
+
"time": pd.date_range("2021-01-01", end="2021-01-05", periods=200),
|
9 |
+
"temperature": [randint(50 + 10 * (i % 2), 65 + 15 * (i % 2)) for i in range(200)],
|
10 |
+
"humidity": [randint(50 + 10 * (i % 2), 65 + 15 * (i % 2)) for i in range(200)],
|
11 |
+
"location": ["indoor", "outdoor"] * 100,
|
12 |
+
}
|
13 |
+
)
|
14 |
+
|
15 |
+
food_rating_data = pd.DataFrame(
|
16 |
+
{
|
17 |
+
"cuisine": [["Italian", "Mexican", "Chinese"][i % 3] for i in range(100)],
|
18 |
+
"rating": [random() * 4 + 0.5 * (i % 3) for i in range(100)],
|
19 |
+
"price": [randint(10, 50) + 4 * (i % 3) for i in range(100)],
|
20 |
+
"wait": [random() for i in range(100)],
|
21 |
+
}
|
22 |
+
)
|
23 |
+
|
24 |
+
with gr.Blocks() as scatter_plots:
|
25 |
+
with gr.Row():
|
26 |
+
start = gr.DateTime("2021-01-01 00:00:00", label="Start")
|
27 |
+
end = gr.DateTime("2021-01-05 00:00:00", label="End")
|
28 |
+
apply_btn = gr.Button("Apply", scale=0)
|
29 |
+
with gr.Row():
|
30 |
+
group_by = gr.Radio(["None", "30m", "1h", "4h", "1d"], value="None", label="Group by")
|
31 |
+
aggregate = gr.Radio(["sum", "mean", "median", "min", "max"], value="sum", label="Aggregation")
|
32 |
+
|
33 |
+
temp_by_time = gr.ScatterPlot(
|
34 |
+
temp_sensor_data,
|
35 |
+
x="time",
|
36 |
+
y="temperature",
|
37 |
+
)
|
38 |
+
temp_by_time_location = gr.ScatterPlot(
|
39 |
+
temp_sensor_data,
|
40 |
+
x="time",
|
41 |
+
y="temperature",
|
42 |
+
color="location",
|
43 |
+
)
|
44 |
+
|
45 |
+
time_graphs = [temp_by_time, temp_by_time_location]
|
46 |
+
group_by.change(
|
47 |
+
lambda group: [gr.ScatterPlot(x_bin=None if group == "None" else group)] * len(time_graphs),
|
48 |
+
group_by,
|
49 |
+
time_graphs
|
50 |
+
)
|
51 |
+
aggregate.change(
|
52 |
+
lambda aggregate: [gr.ScatterPlot(y_aggregate=aggregate)] * len(time_graphs),
|
53 |
+
aggregate,
|
54 |
+
time_graphs
|
55 |
+
)
|
56 |
+
|
57 |
+
price_by_cuisine = gr.ScatterPlot(
|
58 |
+
food_rating_data,
|
59 |
+
x="cuisine",
|
60 |
+
y="price",
|
61 |
+
)
|
62 |
+
with gr.Row():
|
63 |
+
price_by_rating = gr.ScatterPlot(
|
64 |
+
food_rating_data,
|
65 |
+
x="rating",
|
66 |
+
y="price",
|
67 |
+
color="wait",
|
68 |
+
show_actions_button=True,
|
69 |
+
)
|
70 |
+
price_by_rating_color = gr.ScatterPlot(
|
71 |
+
food_rating_data,
|
72 |
+
x="rating",
|
73 |
+
y="price",
|
74 |
+
color="cuisine",
|
75 |
+
)
|
76 |
+
|
77 |
+
if __name__ == "__main__":
|
78 |
+
scatter_plots.launch()
|