| | from models.registry import MODEL_GROUPS, REGRESSION_GRAPHS, CLASSIFICATION_GRAPHS |
| | import gradio as gr |
| | import pandas as pd |
| | import os |
| |
|
| | def reset_on_task_change(task_type): |
| | """ |
| | When task changes: |
| | - Model Group β Basic |
| | - Model β first model of Basic group for selected task |
| | """ |
| | model_group = "Basic" |
| | models = MODEL_GROUPS[model_group][task_type] |
| | model_names = list(models.keys()) |
| |
|
| | return ( |
| | gr.update(value=model_group), |
| | gr.update(choices=model_names, value=model_names[0]) |
| | ) |
| |
|
| |
|
| | def update_models(task_type, model_group): |
| | models = MODEL_GROUPS.get(model_group, {}).get(task_type, {}) |
| | model_names = list(models.keys()) |
| |
|
| | return gr.update( |
| | choices=model_names, |
| | value=model_names[0] if model_names else None |
| | ) |
| |
|
| |
|
| | def update_graphs(task_type): |
| | graphs = ( |
| | REGRESSION_GRAPHS |
| | if task_type == "Regression" |
| | else CLASSIFICATION_GRAPHS |
| | ) |
| |
|
| | return gr.update( |
| | choices=graphs, |
| | value=graphs[0], |
| | ) |
| |
|
| | import os |
| |
|
| | def preview_csv(file, max_rows=10): |
| | if not file: |
| | return None |
| |
|
| | size_mb = os.path.getsize(file.name) / (1024 * 1024) |
| |
|
| | if size_mb > 50: |
| | return None |
| |
|
| | return pd.read_csv(file.name, nrows=max_rows) |
| |
|
| |
|
| |
|
| | def reset_metrics_on_file_clear(file): |
| | if file is None: |
| | return pd.DataFrame(), None |
| | return gr.update(), gr.update() |
| |
|
| |
|
| | def toggle_csv_preview(show): |
| | return gr.update(visible=show) |