asymtree
A scikit-learn compatible decision tree classifier that rewards splits where one side's centroid is pulled far from the splitting boundary — centroid asymmetry.
Motivation
Standard decision trees choose splits purely on impurity (Gini / entropy). A split that perfectly separates classes but places both centroids equidistant from the boundary is treated the same as one where nearly all of one class is packed tightly on one side. asymtree exposes this asymmetry as an explicit objective, so you can tune how aggressively the tree favors interpretable, one-sided splits.
Mathematical background
For a candidate split on feature k at threshold t, with left samples
L = {x : x_k ≤ t} and right samples R = {x : x_k > t}, define:
asymmetry(k, t) = max(t − μ_L, μ_R − t) / (x_k_max − x_k_min)
where μ_L and μ_R are the feature-k means on each side. The denominator normalises by the feature range so scores are comparable across features and always lie in [0, 1].
Two combination strategies
Additive — score the split as a weighted sum:
score(k, t) = ΔGini(k, t) + λ · asymmetry(k, t)
Lexicographic — among all splits within ε of the best Gini improvement, pick the one with the highest asymmetry. Purity and asymmetry are fully decoupled.
Efficient implementation
μ_L and μ_R are maintained as running sums while the threshold scan moves left to right, giving the same O(n) cost per feature as the standard split search — no extra pass over the data.
Installation
pip install asymtree
Requirements: Python ≥ 3.9, scikit-learn ≥ 1.4, numpy ≥ 1.21.
A C compiler and Cython ≥ 3.0 are needed to build from source.
Quick start
from asymtree import AsymmetryDecisionTreeClassifier
# Additive mode: impurity + 0.5 × asymmetry
clf = AsymmetryDecisionTreeClassifier(
max_depth=4,
lambda_=0.5,
lexicographic=False,
random_state=42,
)
clf.fit(X_train, y_train)
print(clf.score(X_test, y_test))
# Lexicographic mode: purity first, asymmetry breaks ties
clf_lexico = AsymmetryDecisionTreeClassifier(
max_depth=4,
eps_impurity=1e-3,
lexicographic=True,
random_state=42,
)
clf_lexico.fit(X_train, y_train)
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
lambda_ |
float | 1.0 | Weight of the asymmetry term (additive mode only). |
eps_impurity |
float | 1e-4 | Tolerance band for lexicographic tiebreaking. |
lexicographic |
bool | False | If True, use lexicographic mode. |
max_depth |
int | None | None | Maximum tree depth. |
min_samples_split |
int | 2 | Minimum samples to split a node. |
min_samples_leaf |
int | 1 | Minimum samples in a leaf. |
max_features |
int | float | str | None | None | Number of features to consider per split. |
random_state |
int | None | None | Random seed. |
All other DecisionTreeClassifier parameters are forwarded unchanged.
Compatibility
AsymmetryDecisionTreeClassifier is a drop-in replacement for
sklearn.tree.DecisionTreeClassifier and works with all sklearn utilities:
cross-validation, pipelines, clone, GridSearchCV, plot_tree, etc.
from sklearn.model_selection import GridSearchCV
param_grid = {"max_depth": [3, 4, 5], "lambda_": [0.1, 0.5, 1.0]}
gs = GridSearchCV(AsymmetryDecisionTreeClassifier(), param_grid, cv=5)
gs.fit(X_train, y_train)
Running the tests
pip install pytest
pytest tests/
License
MIT
Release files for asymtree 0.1.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| asymtree-0.1.9.tar.gz | 183.7 kB | Details |
Built distributions (wheels)
Total release size:6.9 MB
Release files / asymtree-0.1.9.tar.gz
| Download URL | asymtree-0.1.9.tar.gz |
|---|---|
| Size | 183.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c476877442f50957dc2810d49df0108ce1a7eab9f6a4bc951d28f305197e8c9b
|
|
BLAKE2b-256 checksum How to use checksums |
3576fb31578323f009be7e1cd14629bf6ab2044f03a65453149bdd36e27b3898
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 29, 2026.
Transparency logRelease files / asymtree-0.1.9-cp312-cp312-win_amd64.whl
| Download URL | asymtree-0.1.9-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 255.9 kB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
ce922119910b866729bb5c2e349294af894ab93d4b34ad09a9080aa9afa78433
|
|
BLAKE2b-256 checksum How to use checksums |
81ebcc1fca2b4fe05506ae840177c1139e32bbb100a04cd7baa45010ff382246
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 29, 2026.
Transparency logRelease files / asymtree-0.1.9-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | asymtree-0.1.9-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 616.2 kB |
| Tags | CPython 3.12 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
3f4dc39fea56496d918b338a9199644220ee7a93a2f09aeba6475d1a05150944
|
|
BLAKE2b-256 checksum How to use checksums |
8b86fd782abc8e303edd9bbadf84adbde8e4bd54deaf239f03ab0648d1de593c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 29, 2026.
Transparency logRelease files / asymtree-0.1.9-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
| Download URL | asymtree-0.1.9-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl |
|---|---|
| Size | 594.1 kB |
| Tags | CPython 3.12 Linux glibc 2.17+ x86-32 Linux glibc 2.5+ x86-32 |
|
SHA-256 checksum How to use checksums |
89bc7d770e966c40e1f34fdcd509f981b1edb4285f76205d39d2434e43b45254
|
|
BLAKE2b-256 checksum How to use checksums |
c0c9d7262cbd4de1c60d9d4fddc1eb5ebbc9db86508ebff74df46013fd9635b2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 29, 2026.
Transparency logRelease files / asymtree-0.1.9-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | asymtree-0.1.9-cp312-cp312-macosx_11_0_arm64.whl |
|---|---|
| Size | 261.1 kB |
| Tags | CPython 3.12 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
7860d3b8ea243378c85a400b1c78a2e737ad3ef2c93cd61be36f587a60dc30bd
|
|
BLAKE2b-256 checksum How to use checksums |
701018cefbcf75c460f7c2d53ef970e39a33d2a50701bf5941aa76137ac74b7f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 29, 2026.
Transparency logRelease files / asymtree-0.1.9-cp311-cp311-win_amd64.whl
| Download URL | asymtree-0.1.9-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 254.9 kB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
2114f6c8a4862877d1d55f77c30a13407c7ac007b04c2fd78898fd5aa9a5bd5e
|
|
BLAKE2b-256 checksum How to use checksums |
51f2729221d72f3852d0d184ab9ea8293da22c5ed803a11835b047547a6c6bb2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 29, 2026.
Transparency logRelease files / asymtree-0.1.9-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | asymtree-0.1.9-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 593.4 kB |
| Tags | CPython 3.11 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
448d7f3a58684025b3db92744d6c8da7dc5af1a3adb4b0f7245c48b42ab36a7a
|
|
BLAKE2b-256 checksum How to use checksums |
f84b787b23da6600c63cb191b42ae6dfa9746bf015e5b2e6cf610b21fe8c8d22
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 29, 2026.
Transparency logRelease files / asymtree-0.1.9-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
| Download URL | asymtree-0.1.9-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl |
|---|---|
| Size | 575.9 kB |
| Tags | CPython 3.11 Linux glibc 2.17+ x86-32 Linux glibc 2.5+ x86-32 |
|
SHA-256 checksum How to use checksums |
95cc34b4f454d2405a630b690801bfe05058f65a336d71fe88ec876f9bba3f3e
|
|
BLAKE2b-256 checksum How to use checksums |
6823319ce23b51e022f7dffcc258cd2aace8c78bacacfd63fb8f42553e390935
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 29, 2026.
Transparency logRelease files / asymtree-0.1.9-cp311-cp311-macosx_11_0_arm64.whl
| Download URL | asymtree-0.1.9-cp311-cp311-macosx_11_0_arm64.whl |
|---|---|
| Size | 260.8 kB |
| Tags | CPython 3.11 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
bac128af83bb87fc5b361e77c2d6840cd5b8d6929ed3bc3941072a2dded8dbe4
|
|
BLAKE2b-256 checksum How to use checksums |
7552231c31c0b98caa87b5afda55ba234962cebc888d590327dfda8429987690
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 29, 2026.
Transparency logRelease files / asymtree-0.1.9-cp310-cp310-win_amd64.whl
| Download URL | asymtree-0.1.9-cp310-cp310-win_amd64.whl |
|---|---|
| Size | 254.9 kB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
37b43e0a31b2b94d5c680180585f941650e0e41d0fb87023846c0e3b2db9b12d
|
|
BLAKE2b-256 checksum How to use checksums |
970f871bdc1d16d20beb07fc9ba0ce28cdad06c7b0816994d8f2342a63266407
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 29, 2026.
Transparency logRelease files / asymtree-0.1.9-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | asymtree-0.1.9-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 572.2 kB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
ef69a573759a8c4ca966d993b0fa72df6e28665b3fdecc26875575c0a7d5b90b
|
|
BLAKE2b-256 checksum How to use checksums |
f0e488d216655a3cab6fe52e23372de369230d3026283170ec827b730ef752ed
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 29, 2026.
Transparency logRelease files / asymtree-0.1.9-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
| Download URL | asymtree-0.1.9-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl |
|---|---|
| Size | 552.4 kB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-32 Linux glibc 2.5+ x86-32 |
|
SHA-256 checksum How to use checksums |
92f7eb8aee4a052b14d042e748587683901738d2600a74409b04a3e885401407
|
|
BLAKE2b-256 checksum How to use checksums |
12da4f6bbb5c7587ad78fdc50ad16b204a6ece48634c65b4b04d508bdb86d646
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 29, 2026.
Transparency logRelease files / asymtree-0.1.9-cp310-cp310-macosx_11_0_arm64.whl
| Download URL | asymtree-0.1.9-cp310-cp310-macosx_11_0_arm64.whl |
|---|---|
| Size | 260.9 kB |
| Tags | CPython 3.10 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
d4b275660adab7d53e5340034677a7df458882aa6c4d6faaeb7cb907e1abb502
|
|
BLAKE2b-256 checksum How to use checksums |
dcfba0c6fe384c16269765d32f42ecc7ddbed7b9c55dead5f5b316899b5e5221
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 29, 2026.
Transparency logRelease files / asymtree-0.1.9-cp39-cp39-win_amd64.whl
| Download URL | asymtree-0.1.9-cp39-cp39-win_amd64.whl |
|---|---|
| Size | 255.2 kB |
| Tags | CPython 3.9 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
0092ec922ce60ec5c76a56ebf43128dbcb5414eeb054de0d96ea92a384a963c2
|
|
BLAKE2b-256 checksum How to use checksums |
1056be0133d0dcb6dc2f7950726c6692f822af67304af70bc58bf37a71ecea5e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 29, 2026.
Transparency logRelease files / asymtree-0.1.9-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | asymtree-0.1.9-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 571.1 kB |
| Tags | CPython 3.9 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
e4cc98b10c83ee5d17007359299b26919d375aa8c9cd72be15c219fa5673c864
|
|
BLAKE2b-256 checksum How to use checksums |
e9eb81f06cc1529ffa7c50379676d3ea8b82e3b4429a057ed75e508e68bc2a4d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 29, 2026.
Transparency logRelease files / asymtree-0.1.9-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl
| Download URL | asymtree-0.1.9-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl |
|---|---|
| Size | 551.2 kB |
| Tags | CPython 3.9 Linux glibc 2.17+ x86-32 Linux glibc 2.5+ x86-32 |
|
SHA-256 checksum How to use checksums |
fb0216f7bd98a74b07da7778da96098e409cfab5bb1422b6f4217c8bd481f4dc
|
|
BLAKE2b-256 checksum How to use checksums |
02e45af7278f5b623e957de055e59f2b7e8a442619b84d2ccb3f34ca1f6bdf48
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 29, 2026.
Transparency logRelease files / asymtree-0.1.9-cp39-cp39-macosx_11_0_arm64.whl
| Download URL | asymtree-0.1.9-cp39-cp39-macosx_11_0_arm64.whl |
|---|---|
| Size | 261.3 kB |
| Tags | CPython 3.9 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
9f1d008e2ecdd8d7950bc314e746c797503534f8afcb14826aed1c4da7933b26
|
|
BLAKE2b-256 checksum How to use checksums |
0cce58555b6c42d05e49943e06789f74490d8953800dcf2f86d774e023280de1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 29, 2026.
Transparency log