Skip to main content

Incremental, interactive decision tree builder for risk specialists

Project description

Treecraft

CI Coverage PyPI version Downloads License

Treecraft is an interactive decision tree framework. Treecraft allows analysts to manually evaluate, override, and prune decision boundaries utilizing an interactive UI interface, while automatically refitting subtrees optimally beneath manual split points.

Treecraft Interface

The framework extends standard Scikit-Learn. Modifications made visually in the interface alter splits in the underlying tree graph. The resulting model can then be exported as a standard, fitted DecisionTreeClassifier or DecisionTreeRegressor compatible with standard sklearn pipelines.

Installation

This module provides an interactive interface built upon anywidget for integration into Jupyter ecosystems.

Install from source locally via standard python package deployment:

pip install -e .

Usage

Initiate the widget by supplying a pandas.DataFrame and declaring the target feature.

import pandas as pd
from sklearn.datasets import load_iris
from treecraft.widget import TreecraftWidget

data = load_iris()
df = pd.DataFrame(data.data, columns=data.feature_names)
df['target'] = data.target

# Instantiate the interactive widget
widget = TreecraftWidget(df=df, target='target', model_id='iris_model')
widget

Once the interactive visualization opens, users can apply initial hyperparameters, manually navigate tree partitions, append/remove split points, and verify node performance across configurable train/validation splits.

Pipeline Extraction

After modifying the boundaries visually to conform to the required constraints, extract the native Scikit-Learn estimator.

from sklearn.pipeline import make_pipeline

# Extract the fitted Scikit-Learn estimator structure
clf = widget.export_sklearn()
pipeline = make_pipeline(clf)

# Execute predictions
X_test = df.drop(columns=['target'])
predictions = pipeline.predict(X_test)

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ipytreecraft-0.1.0-py3-none-any.whl (1.4 MB view details)

Uploaded Python 3

File details

Details for the file ipytreecraft-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: ipytreecraft-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 1.4 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for ipytreecraft-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f50424fdd6c32fe59888daeee7bb1074738d0bc89fce036c4f2c1d709b02fd73
MD5 cea61b615b532467cc2d1a4be098b5b2
BLAKE2b-256 dbd8114878d7afc7d9d90a7e985a55a642ee2b1f7fbc0ed0ed700cd665ddf741

See more details on using hashes here.

Supported by

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