Skip to content
polars-learnOverview

Examples

These examples are small enough to run locally and use real package interfaces. They illustrate composition and validation rather than benchmark performance or model accuracy.

Workflow What it demonstrates
Raw input to prediction Fit preprocessing and a model together; predict without supplying derived columns.
Sibling features and ordered dependencies Build features in successive specifications and drop temporary columns.
Parallel transformed and unchanged features Combine a scaler and FeaturePassthrough in a ColumnTransformer.
Lazy feature preparation Defer feature evaluation and collect explicitly at the model boundary.
Custom Python feature functions Define map_elements callbacks, compose stages, and pickle/restore fitted preparation.
Schema drift Reject missing columns and dtype changes, normalize explicitly allowed changes, and guard prediction in a pipeline.
Cross-validation Clone and fit the full pipeline per fold.
Persistence and warning filters Save a fitted pipeline and choose whether mismatches warn, fail, or are silenced.
Question Workflow Data
Can order value predict a fee? Held-out split, schema validation, feature selection, scaling, regression Generated locally, 80 orders
How stable is a full pipeline across folds? Clone and fit the entire preparation path per fold Local order fixture
Where should a lazy query become eager? Deferred Polars preparation and estimator boundary Local order fixture

Copy each complete Python block into a file and run it in the installed environment. Assertions and marked displayed output are validated by the documentation checker.