Upload folder using huggingface_hub
Browse filesFiles changed (5)
- README.md+7-7
- data.pyAdded+10
- requirements.txtAdded+2
- run.ipynbAdded+1
- run.pyAdded+15
123456789101112---title: Plot Guide Selection Mainemoji: 🌖colorFrom: pinkcolorTo: redsdk: gradiosdk_version: 4.40.0app_file: app.pypinned: false---Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference123456789101112---title: plot_guide_selection_mainemoji: 🔥colorFrom: indigocolorTo: indigosdk: gradiosdk_version: 4.40.0app_file: run.pypinned: falsehf_oauth: true---
12345678910import pandas as pdimport numpy as npimport random
df = pd.DataFrame({ 'height': np.random.randint(50, 70, 25), 'weight': np.random.randint(120, 320, 25), 'age': np.random.randint(18, 65, 25), 'ethnicity': [random.choice(["white", "black", "asian"]) for _ in range(25)]})12gradio-client @ git+https://github.com/gradio-app/gradio@4ba7b238e22ac042de14a6b69aa9d61536ddffba#subdirectory=client/pythonhttps://gradio-builds.s3.amazonaws.com/4ba7b238e22ac042de14a6b69aa9d61536ddffba/gradio-4.40.0-py3-none-any.whl1{"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: plot_guide_selection"]}, {"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": ["# Downloading files from the demo repo\n", "import os\n", "!wget -q https://github.com/gradio-app/gradio/raw/main/demo/plot_guide_selection/data.py"]}, {"cell_type": "code", "execution_count": null, "id": "44380577570523278879349135829904343037", "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "from data import df\n", "\n", "with gr.Blocks() as demo:\n", " plt = gr.LinePlot(df, x=\"weight\", y=\"height\")\n", " selection_total = gr.Number(label=\"Total Weight of Selection\")\n", "\n", " def select_region(selection: gr.SelectData):\n", " min_w, max_w = selection.index\n", " return df[(df[\"weight\"] >= min_w) & (df[\"weight\"] <= max_w)][\"weight\"].sum()\n", "\n", " plt.select(select_region, None, selection_total)\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}123456789101112131415import gradio as grfrom data import df
with gr.Blocks() as demo: plt = gr.LinePlot(df, x="weight", y="height") selection_total = gr.Number(label="Total Weight of Selection")
def select_region(selection: gr.SelectData): min_w, max_w = selection.index return df[(df["weight"] >= min_w) & (df["weight"] <= max_w)]["weight"].sum()
plt.select(select_region, None, selection_total)
if __name__ == "__main__": demo.launch()README.md+7-7
data.pyAdded+10
requirements.txtAdded+2
run.ipynbAdded+1
run.pyAdded+15