Spaces:
Sleeping
Sleeping
Delete ui/layout.py
Browse files- ui/layout.py +0 -91
ui/layout.py
DELETED
@@ -1,91 +0,0 @@
|
|
1 |
-
# ui/layout.py
|
2 |
-
import gradio as gr
|
3 |
-
from core.config import settings
|
4 |
-
|
5 |
-
def create_main_layout():
|
6 |
-
"""Defines and returns the entire Gradio UI structure."""
|
7 |
-
with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue", secondary_hue="indigo"), title=settings.APP_TITLE) as demo:
|
8 |
-
# State object to hold the DataAnalyzer instance
|
9 |
-
state_analyzer = gr.State()
|
10 |
-
|
11 |
-
# --- Header ---
|
12 |
-
gr.Markdown(f"<h1>{settings.APP_TITLE}</h1>")
|
13 |
-
gr.Markdown("A world-class data discovery platform that provides a complete suite of EDA tools and intelligently unlocks specialized analysis modules for Time-Series, Text, and Clustering.")
|
14 |
-
|
15 |
-
# --- Input Row ---
|
16 |
-
with gr.Row():
|
17 |
-
upload_button = gr.File(label="1. Upload Data File (CSV, Excel)", file_types=[".csv", ".xlsx"], scale=3)
|
18 |
-
analyze_button = gr.Button("β¨ Generate Intelligence Report", variant="primary", scale=1)
|
19 |
-
|
20 |
-
# --- Main Tabs ---
|
21 |
-
with gr.Tabs():
|
22 |
-
# Tab 1: AI Narrative
|
23 |
-
with gr.Tab("π€ AI-Powered Strategy Report", id="tab_ai"):
|
24 |
-
ai_report_output = gr.Markdown("### Your AI-generated report will appear here after analysis...")
|
25 |
-
|
26 |
-
# Tab 2: Data Profile
|
27 |
-
with gr.Tab("π Data Profile", id="tab_profile"):
|
28 |
-
with gr.Accordion("Missing Values Report", open=False):
|
29 |
-
profile_missing_df = gr.DataFrame()
|
30 |
-
with gr.Accordion("Numeric Features Summary", open=True):
|
31 |
-
profile_numeric_df = gr.DataFrame()
|
32 |
-
with gr.Accordion("Categorical Features Summary", open=True):
|
33 |
-
profile_categorical_df = gr.DataFrame()
|
34 |
-
|
35 |
-
# Tab 3: Overview Visuals
|
36 |
-
with gr.Tab("π Overview Visuals", id="tab_overview"):
|
37 |
-
with gr.Row():
|
38 |
-
plot_types = gr.Plot()
|
39 |
-
plot_missing = gr.Plot()
|
40 |
-
plot_correlation = gr.Plot()
|
41 |
-
|
42 |
-
# Tab 4: Interactive Explorer
|
43 |
-
with gr.Tab("π¨ Interactive Explorer", id="tab_explorer"):
|
44 |
-
gr.Markdown("### Univariate Analysis")
|
45 |
-
with gr.Row():
|
46 |
-
dd_hist_col = gr.Dropdown(label="Select Column for Histogram", interactive=True)
|
47 |
-
plot_histogram = gr.Plot()
|
48 |
-
gr.Markdown("### Bivariate Analysis")
|
49 |
-
with gr.Row():
|
50 |
-
with gr.Column(scale=1):
|
51 |
-
dd_scatter_x = gr.Dropdown(label="X-Axis (Numeric)", interactive=True)
|
52 |
-
dd_scatter_y = gr.Dropdown(label="Y-Axis (Numeric)", interactive=True)
|
53 |
-
dd_scatter_color = gr.Dropdown(label="Color By (Optional)", interactive=True)
|
54 |
-
with gr.Column(scale=2):
|
55 |
-
plot_scatter = gr.Plot()
|
56 |
-
|
57 |
-
# Tab 5: Time-Series Analysis (Conditional)
|
58 |
-
with gr.Tab("β Time-Series Analysis", id="tab_timeseries", visible=False) as tab_timeseries:
|
59 |
-
# ... layout for time series ...
|
60 |
-
pass # Placeholder for brevity
|
61 |
-
|
62 |
-
# Tab 6: Text Analysis (Conditional)
|
63 |
-
with gr.Tab("π Text Analysis", id="tab_text", visible=False) as tab_text:
|
64 |
-
# ... layout for text ...
|
65 |
-
pass # Placeholder for brevity
|
66 |
-
|
67 |
-
# Tab 7: Clustering Analysis (Conditional)
|
68 |
-
with gr.Tab("π§© Clustering (K-Means)", id="tab_cluster", visible=False) as tab_cluster:
|
69 |
-
with gr.Row():
|
70 |
-
with gr.Column(scale=1):
|
71 |
-
num_clusters = gr.Slider(minimum=2, maximum=10, value=3, step=1, label="Number of Clusters (K)", interactive=True)
|
72 |
-
md_cluster_summary = gr.Markdown()
|
73 |
-
with gr.Column(scale=2):
|
74 |
-
plot_cluster = gr.Plot()
|
75 |
-
plot_elbow = gr.Plot()
|
76 |
-
|
77 |
-
# Collect all components that need to be updated
|
78 |
-
# This is a bit verbose but necessary for Gradio's output mapping
|
79 |
-
components = {
|
80 |
-
"state_analyzer": state_analyzer, "upload_button": upload_button, "analyze_button": analyze_button,
|
81 |
-
"ai_report_output": ai_report_output, "profile_missing_df": profile_missing_df,
|
82 |
-
"profile_numeric_df": profile_numeric_df, "profile_categorical_df": profile_categorical_df,
|
83 |
-
"plot_types": plot_types, "plot_missing": plot_missing, "plot_correlation": plot_correlation,
|
84 |
-
"dd_hist_col": dd_hist_col, "plot_histogram": plot_histogram, "dd_scatter_x": dd_scatter_x,
|
85 |
-
"dd_scatter_y": dd_scatter_y, "dd_scatter_color": dd_scatter_color, "plot_scatter": plot_scatter,
|
86 |
-
"tab_timeseries": tab_timeseries, "tab_text": tab_text, "tab_cluster": tab_cluster,
|
87 |
-
"num_clusters": num_clusters, "md_cluster_summary": md_cluster_summary,
|
88 |
-
"plot_cluster": plot_cluster, "plot_elbow": plot_elbow,
|
89 |
-
}
|
90 |
-
|
91 |
-
return demo, components
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|