Skip to main content

Polars-based splitter functionalities for polars LazyFrames and DataFrames, similar to `sklearn.model_selection.train_test_split` and `sklearn.model_selection.StratifiedKFold`.

Project description

polars-splitters

Polars-based splitter functionalities for polars LazyFrames and DataFrames similar to sklearn.model_selection.train_test_split and sklearn.model_selection.StratifiedKFold.

features

  • split_into_train_eval
  • split_into_k_folds

installation

pip install polars-splitters

usage

import polars as pl
from polars_splitters import split_into_train_eval, split_into_k_folds

df = pl.DataFrame(
    {
        "feature_1": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],
        "treatment": [0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1],
        "outcome": [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1],
    }
)

df_train, df_test = split_into_train_eval(
    df,
    eval_rel_size=0.3,
    stratify_by=["treatment", "outcome"],
    shuffle=True,
    validate=True,
    as_lazy=False,
    rel_size_deviation_tolerance=0.1,
)

folds = split_into_k_folds(
    df,
    k=3,
    stratify_by=["treatment", "outcome"],
    shuffle=False,
    as_lazy=False
)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

polars_splitters-0.2.5.tar.gz (9.0 MB view details)

Uploaded Source

Built Distribution

polars_splitters-0.2.5-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file polars_splitters-0.2.5.tar.gz.

File metadata

  • Download URL: polars_splitters-0.2.5.tar.gz
  • Upload date:
  • Size: 9.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.3

File hashes

Hashes for polars_splitters-0.2.5.tar.gz
Algorithm Hash digest
SHA256 8c4cf96077bb6748d19f425c2700be714171b50773b82082db2fd29ba14673f4
MD5 0b56f0014be7dc7e2959b3a732955d1a
BLAKE2b-256 85564070bab2913b23fc451085b535208ef120483f8060f7d6ab2a6a126e5e92

See more details on using hashes here.

File details

Details for the file polars_splitters-0.2.5-py3-none-any.whl.

File metadata

File hashes

Hashes for polars_splitters-0.2.5-py3-none-any.whl
Algorithm Hash digest
SHA256 731fc8903a1531b5a49e369597275a57886161b7f163e5b318841ee95b67a0d4
MD5 577a07daa7d81a1eb4af5e96dd5d19ee
BLAKE2b-256 ecfe44ad91b7045b5374197a51538ee61470969163d82d40c16505a3907ea051

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page