Download app.py from abersbail/machine-learning-tabular-lab: direct link, hf CLI and curl.
- Browser
- Download file 1.73 kB
-
https://huggingface.co/spaces/abersbail/machine-learning-tabular-lab/resolve/main/app.py
- Command line
-
hf download hf://spaces/abersbail/machine-learning-tabular-lab/app.py
-
curl -L -o app.py https://huggingface.co/spaces/abersbail/machine-learning-tabular-lab/resolve/main/app.py
1.73 kB
| import gradio as gr | |
| from ml_tabular.service import TabularMLService | |
| service = TabularMLService() | |
| def train_model(file_obj, target_column, task_type, test_size, random_state): | |
| file_path = getattr(file_obj, "name", file_obj) | |
| return service.run(file_path, target_column, task_type, float(test_size), int(random_state)) | |
| with gr.Blocks( | |
| title="Machine Learning Tabular Lab", | |
| theme=gr.themes.Soft(primary_hue="green", secondary_hue="gray"), | |
| ) as demo: | |
| gr.Markdown( | |
| """ | |
| # Machine Learning Tabular Lab | |
| Upload a CSV dataset, choose the target column, and train a classic machine learning model on free CPU. | |
| """ | |
| ) | |
| dataset_input = gr.File(label="CSV Dataset", file_types=[".csv"]) | |
| target_input = gr.Textbox(label="Target Column", placeholder="target") | |
| task_input = gr.Dropdown( | |
| choices=["Auto", "Classification", "Regression"], | |
| value="Auto", | |
| label="Task Type", | |
| ) | |
| with gr.Row(): | |
| test_size_input = gr.Slider(0.1, 0.4, value=0.2, step=0.05, label="Test Split") | |
| random_state_input = gr.Slider(1, 999, value=42, step=1, label="Random State") | |
| run_button = gr.Button("Train Model", variant="primary") | |
| model_output = gr.Textbox(label="Selected Model", lines=1) | |
| metric_output = gr.Textbox(label="Metrics", lines=6) | |
| preview_output = gr.Textbox(label="Feature Preview", lines=8) | |
| status_output = gr.Textbox(label="Status", lines=3) | |
| run_button.click( | |
| fn=train_model, | |
| inputs=[dataset_input, target_input, task_input, test_size_input, random_state_input], | |
| outputs=[model_output, metric_output, preview_output, status_output], | |
| ) | |
| if __name__ == "__main__": | |
| demo.launch() | |