Skip to main content

classtrees

classtrees is a lightweight Python package that implements fast classification trees and random forest. It combines a NumPy-friendly Python API with a compiled C backend to deliver efficient training and prediction for binary and multiclass classification.

Key Features

  • Decision tree classifier with configurable tree height, split criteria, and feature subsampling
  • Random forest ensemble with bootstrap aggregation and support for parallel training
  • Predict class labels and class probabilities
  • Built as a C extension for performance
  • Designed for NumPy arrays and scientific workflows

Installation

Requirements

  • Python 3.10 or newer
  • NumPy
  • C compiler with OpenMP support (required to build the C extension)

Install from PyPI

python -m pip install classtrees

Install from source

python -m pip install .

Quick Start

import numpy as np
from classtrees import ClassTree, RandomForest

# training data
X = np.random.randn(100, 5)
y = (X[:, 0] > 0).astype(np.int64)

# single decision tree
tree = ClassTree(max_height=5, random_state=42)
tree.fit(X, y)
y_pred = tree.predict(X)
proba = tree.predict_proba(X)

# random forest
forest = RandomForest(n_estimators=50, max_height=8, random_state=42, n_jobs=1)
forest.fit(X, y)
forest_pred = forest.predict(X)
forest_proba = forest.predict_proba(X)

API

ClassTree

A single decision tree classifier.

Constructor arguments:

  • impurity: 'gini' or 'entropy' (default: 'gini')
  • max_height: maximum tree height, or None to grow until no valid split remains
  • min_samples_split: minimum samples required to split a node (default: 2)
  • min_samples_leaf: minimum samples required in each leaf node (default: 1)
  • max_features: number of features considered for splits, or None to use all features
  • random_state: random seed for reproducible training

Methods:

  • fit(X, y): train the classifier on feature matrix X and labels y
  • predict(X): return predicted class labels for input samples
  • predict_proba(X): return predicted class probabilities

RandomForest

An ensemble of decision trees with bootstrap sampling.

Constructor arguments:

  • n_estimators: number of trees in the forest (default: 100)
  • impurity, max_height, min_samples_split, min_samples_leaf, max_features, random_state: same as ClassTree
  • n_jobs: number of worker threads for training and prediction (default: 1). Use -1 to enable all available cores.

Methods:

  • fit(X, y): train the forest ensemble
  • predict(X): return ensemble class predictions
  • predict_proba(X): return averaged class probabilities from all trees

Documentation

Full documentation is available in the project docs/ folder and online at:

License

This project is licensed under the BSD-3-Clause license. See LICENSE for details.

Metadata

Release files for classtrees 1.1.3

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

Source distribution (sdist)

Source distribution for classtrees 1.1.3
File Size Uploaded Provenance Actions
classtrees-1.1.3.tar.gz 22.8 kB With provenance Details for classtrees-1.1.3.tar.gz

Release files / classtrees-1.1.3.tar.gz

Download URL classtrees-1.1.3.tar.gz
Size 22.8 kB
Tags Source
SHA-256 checksum
How to use checksums
da0d20c8096c9aacdedee04eb017df13c40420df7ce0c20f4ce2ffda03b2f655
BLAKE2b-256 checksum
How to use checksums
1304553c936565e6ddfaa9efb87dbf7ba67e29bc35e50e0195df50f9d3fc2031
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 Jun 7, 2026.

Transparency log

Security for classtrees 1.1.3

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.

Full provenance

1 file in this release has been uploaded with provenance metadata.

Attestation for classtrees-1.1.3.tar.gz

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 Jun 7, 2026.

Transparency log

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.

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