File size: 1,401 Bytes
23ab98a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
from typing import Any
import gradio as gr
import pandas as pd
import helpers

# --- Global Variables ---
df = None

# --- Gradio App ---
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()

        # When file uploaded, update dropdown
        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()