🌍 Become a marimo ambassador!

Apply
65 / 103
Sklearn Classification Workbook

Sklearn Classification Workbook

by marimo team

Bootstrap scikit-learn classification models with automatic preprocessing and cross-validation.

About this notebook

This notebook builds two classification models with scikit-learn. It reads a CSV file that you upload. If you upload no file, it uses a synthetic dataset from scikit-learn make_classification with 1000 rows and 5 features. It uses polars and pandas for data, skrub to encode features, and scipy for parameter distributions.

You select the target column from a dropdown. Two sliders set the number of cross-validation folds and the number of random search runs. You click the Run Analysis button to start the work. The notebook then shows tables with F1, accuracy, precision, and recall for each model. It also shows train scores next to test scores.

Each model runs inside a scikit-learn pipeline. A skrub TableVectorizer encodes mixed column types before the classifier. The notebook compares logistic regression and histogram gradient boosting. RandomizedSearchCV tunes each model with stratified k-fold splits. The authors note that these results are a starting point and that you may need to look deeper.

Related notebooks