| title | CSV Predictor | |
|---|---|---|
| emoji | 📊 | |
| colorFrom | blue | |
| colorTo | indigo | |
| sdk | docker | |
| app_port | 8501 | |
| pinned | false | |
| short_description | Upload a CSV, train a model, view metrics & importances. | |
| tags |
|
A Streamlit web application for uploading a CSV file, auto-detecting the ML task, training a Random Forest model, and displaying test-set metrics and feature importances.
Live demo: huggingface.co/spaces/voidalc07/csv-predictor
# Create and activate a virtual environment
python3 -m venv .venv
source .venv/bin/activate
# Install dependencies
pip install -r requirements.txt
# Launch the app
streamlit run app.py
# Run the test suite
pytest tests/| Path | Responsibility |
|---|---|
app.py |
Streamlit UI only — renders widgets and calls into data_utils. Contains no data-processing logic. |
data_utils.py |
Pure data functions: loading CSVs and inferring column types. No UI imports. |
tests/test_data_utils.py |
Pytest unit tests for data_utils. |
sample_data/example.csv |
Generated synthetic dataset: 600-row binary classification of 30-day hospital readmission. Produced by scripts/generate_sample_data.py — do not edit by hand. |
scripts/generate_sample_data.py |
Seeded script that regenerates example.csv deterministically. Documents the built-in signal, noise features, and missing-value injection. |
requirements.txt |
Pinned Python dependencies. |
.streamlit/config.toml |
Streamlit theme configuration. |
conftest.py |
Empty pytest hook that anchors the project root on sys.path, allowing test modules to import top-level packages without install. |
UI and logic are separated (app.py vs data_utils.py) so that data functions can be tested independently of Streamlit and reused by future modules (e.g. a training pipeline) without importing any UI code. This boundary is enforced: data_utils.py has no Streamlit import, and app.py has no data-processing logic.
Task detection (detect_task) uses a three-rule heuristic: non-numeric target → classification; numeric target with low cardinality (≤ 20 unique values and ≤ 5 % of row count) → classification; otherwise → regression. This is a best guess — users will be able to override it in the UI.
Preprocessing is handled by a ColumnTransformer inside an sklearn Pipeline: median imputation + standard scaling for numeric columns; most-frequent imputation + one-hot encoding for categoricals. Keeping preprocessing inside the pipeline ensures the test split is never exposed to fit statistics from the training set.
Model — RandomForestClassifier / RandomForestRegressor with 100 estimators. Chosen as a robust baseline: resistant to feature scale, handles mixed types after encoding, rarely overfits on small datasets with default hyper-parameters, and exposes feature importances natively for a later UI step.
Metrics — classification returns accuracy, macro-F1, and (for binary targets) ROC-AUC. Regression returns R² and RMSE. Multiclass ROC-AUC is deferred until a multi-label probability display is added to the UI.
