|
|
from typing import Any |
|
|
import gradio as gr |
|
|
import pandas as pd |
|
|
import helpers |
|
|
|
|
|
|
|
|
df = None |
|
|
|
|
|
|
|
|
with gr.Blocks() as demo: |
|
|
gr.Markdown("# π Datathon Dashboard with Gradio") |
|
|
|
|
|
with gr.Tab("Dataset Overview"): |
|
|
file_input = gr.File(label="Upload CSV", file_types=[".csv"]) |
|
|
preview = gr.HTML() |
|
|
shape = gr.Textbox(label="Dataset Info") |
|
|
|
|
|
file_input.change(helpers.load_data, inputs=file_input, outputs=[preview, shape]) |
|
|
|
|
|
with gr.Tab("Exploratory Data Analysis"): |
|
|
gr.Markdown("## π EDA Section") |
|
|
col_dropdown = gr.Dropdown(label="Select column to visualize", choices=[], interactive=True) |
|
|
plot = gr.Plot() |
|
|
|
|
|
|
|
|
def update_dropdown(file) -> dict[str, Any]: |
|
|
d = pd.read_csv(file.name) |
|
|
return gr.update(choices=d.columns.tolist()) |
|
|
|
|
|
file_input.change(update_dropdown, inputs=file_input, outputs=col_dropdown) |
|
|
col_dropdown.change(helpers.plot_column, inputs=col_dropdown, outputs=plot) |
|
|
|
|
|
with gr.Tab("Modeling (Optional)"): |
|
|
gr.Markdown("You can add ML model training or predictions here.") |
|
|
|
|
|
with gr.Tab("Insights"): |
|
|
gr.Markdown("## π Insights & Conclusion") |
|
|
gr.Markdown("Write your story, insights, and recommendations here.") |
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__": |
|
|
demo.launch() |
|
|
|