Skip to main content

softdtree

softdtree is a Python library that implements classifier and regressor with Soft Decision Tree.

Installation

softdtree requires Eigen3, so install it beforehand,

macOS:

$ brew install eigen cmake

Ubuntu:

$ sudo apt-get install libeigen3-dev cmake

Then, install softdtree from PyPI:

$ pip install -U softdtree

Usage

The API of softdtree is compatible with scikit-learn.

Classifier:

from sklearn.datasets import load_digits
from sklearn.model_selection import cross_val_score
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import StandardScaler
from softdtree import SoftDecisionTreeClassifier

X, y = load_digits(n_class=4, return_X_y=True)

clf = Pipeline([
    ("scaler", StandardScaler()),
    ("tree", SoftDecisionTreeClassifier(
        max_depth=4, eta=0.01, max_epoch=100, random_seed=42)),                                                                           ])

scores = cross_val_score(clf, X, y, cv=5)
print(f"Accuracy: {scores.mean():.3f} ± {scores.std():.3f}")

Regressor:

from sklearn.datasets import load_diabetes
from sklearn.model_selection import cross_val_score
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import MinMaxScaler
from softdtree import SoftDecisionTreeRegressor

X, y = load_diabetes(return_X_y=True)

reg = Pipeline([
    ("scaler", MinMaxScaler()),
    ("tree", SoftDecisionTreeRegressor(
        max_depth=4, eta=0.1, max_epoch=100, random_seed=42)),
])

scores = cross_val_score(reg, X, y, cv=5)
print(f"R^2: {scores.mean():.3f} ± {scores.std():.3f}")

Parameters

  • max_depth (int): The maximum depth of the tree. The default is 8.
  • max_features (float): The ratio of the number of features used at each node. The number of features used is max(1, min(n_features, n_features * max_features)). The default is 1.0.
  • max_epoch (int): The maximum number of epochs to train. The default is 100.
  • batch_size (int): The number of samples used in one iteration. The default is 5.
  • eta (float): The learning rate. The default is 0.1.
  • beta1 (float): The exponential decay rate for the first moment estimates. The default is 0.9.
  • beta2 (float): The exponential decay rate for the second moment estimates. he default is 0.999.
  • epsilon (float): The term added to the denominator for numerical stability. The default is 1e-8.
  • tol (float): The tolerance for the optimization. The default is 1e-4.
  • verbose (int): If it is set to a value greater than 0, the estimator outputs a log. The default is 0.
  • random_seed (int): The random seed. If -1, then it will be set to a number generated by a uniformly-distributed integer random number generator. The default is -1.

References

  • O. Irsoy, O. T. Yildiz, and E. Alpaydin, "Soft Decision Trees," In Proc. ICPR2012, 2012.

License

softdtree is available as open source under the terms of the BSD-3-Clause License.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/yoshoku/softdtree This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

Metadata

Release files for softdtree 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for softdtree 0.1.0
File Size Uploaded Provenance
softdtree-0.1.0.tar.gz 10.5 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for softdtree 0.1.0
File Interpreter ABI Platform
softdtree-0.1.0-cp312-abi3-macosx_15_0_arm64.whl CPython 3.12 abi3 macOS 15.0+ ARM64 Details

Total release size: 78.7 kB

Release files / softdtree-0.1.0.tar.gz

Download URL softdtree-0.1.0.tar.gz
Size 10.5 kB
Tags Source
SHA-256 checksum
How to use checksums
02a231de275e3654d4f638eda07477e2061650ca782d318b7d91968d336997f9
BLAKE2b-256 checksum
How to use checksums
4bb2cdbaf1b2d49def35714394196b7c450e856eb732334bf3d9f0dbdedd8ee6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.15

Release files / softdtree-0.1.0-cp312-abi3-macosx_15_0_arm64.whl

Download URL softdtree-0.1.0-cp312-abi3-macosx_15_0_arm64.whl
Size 68.2 kB
Tags CPython 3.12 abi3 macOS 15.0+ ARM64
SHA-256 checksum
How to use checksums
9209e5a621537dcc6d04f016c3d576cb587b8702827e76b6ce47dc85275a3e7e
BLAKE2b-256 checksum
How to use checksums
e433d8856971be1dee859a5aa78673a721cfbb4ab7bac4bd4c2f7a3053595ac8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.15

Security for softdtree 0.1.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page