import gradio as gr from predictive_ml_workbench.service import PredictiveMLWorkbenchService service = PredictiveMLWorkbenchService() def run_workbench(file_obj, workflow, target_column, test_size, cv_folds, max_clusters): file_path = getattr(file_obj, "name", file_obj) return service.run( csv_path=file_path, workflow=workflow, target_column=target_column, test_size=float(test_size), cv_folds=int(cv_folds), max_clusters=int(max_clusters), ) with gr.Blocks( title="Predictive ML Workbench", theme=gr.themes.Soft(primary_hue="green", secondary_hue="blue"), ) as demo: gr.Markdown( """ # Predictive ML Workbench Upload a CSV dataset and run end-to-end machine learning workflows for regression, classification, clustering, dimensionality reduction, preprocessing, model selection, and evaluation. """ ) with gr.Accordion("What this project covers", open=False): gr.Markdown( """ - Regression - Classification - Clustering - Dimensionality reduction - Preprocessing with numeric and categorical pipelines - Model selection with cross-validation - Evaluation with workflow-specific metrics and plots """ ) dataset_input = gr.File(label="CSV Dataset", file_types=[".csv"]) with gr.Row(): workflow_input = gr.Dropdown( choices=["Classification", "Regression", "Clustering", "Dimensionality Reduction"], value="Classification", label="Workflow", ) target_input = gr.Textbox( label="Target Column", placeholder="Required for regression/classification; optional otherwise", ) with gr.Row(): test_size_input = gr.Slider(0.1, 0.4, value=0.2, step=0.05, label="Test Split") cv_input = gr.Slider(2, 5, value=3, step=1, label="CV Folds") cluster_input = gr.Slider(3, 8, value=6, step=1, label="Max Clusters") run_button = gr.Button("Run Workflow", variant="primary") model_output = gr.Textbox(label="Selected Model / Method", lines=2) metrics_output = gr.Textbox(label="Metrics", lines=10) preview_output = gr.Textbox(label="Data Preview", lines=10) plot_output = gr.Plot(label="Visualization") status_output = gr.Textbox(label="Status", lines=3) run_button.click( fn=run_workbench, inputs=[ dataset_input, workflow_input, target_input, test_size_input, cv_input, cluster_input, ], outputs=[ model_output, metrics_output, preview_output, plot_output, status_output, ], ) if __name__ == "__main__": demo.launch()