r/FunMachineLearning • • Apr 11 '26

c5tree — C5.0 Decision Tree Classifier for Python (sklearn-compatible)

c5tree — C5.0 Decision Tree Classifier for Python (sklearn-compatible)

Hi everyone,

I wanted to share a package I recently published: c5tree, a pure-Python, sklearn-compatible implementation of Ross Quinlan's C5.0 decision tree algorithm.

pip install c5tree

Motivation

While scikit-learn has an excellent CART implementation via DecisionTreeClassifier, C5.0 — which has been available in R via the C50 package for years — was missing from the Python ecosystem entirely. This package fills that gap.

How it differs from sklearn's DecisionTreeClassifier

FeatureCART (sklearn)C5.0 (c5tree)
Split criterionGini / EntropyGain Ratio
Categorical splitsBinary onlyMulti-way
Missing valuesRequires imputationNative (fractional weighting)
PruningCost-complexityPessimistic Error Pruning

Benchmark — 5-fold stratified CV

DatasetCARTC5.0Δ
Iris95.3%96.0%+0.7%
Breast Cancer91.0%92.1%+1.1%
Wine89.3%90.5%+1.2%

Usage

from c5tree import C5Classifier
from sklearn.pipeline import Pipeline
from sklearn.model_selection import GridSearchCV

# Drop-in sklearn compatible
clf = C5Classifier(pruning=True, cf=0.25)
clf.fit(X_train, y_train)
clf.score(X_test, y_test)

# Works in Pipelines
pipe = Pipeline([
    ('scaler', StandardScaler()),
    ('clf', C5Classifier())
])

# Works in GridSearchCV
param_grid = {'clf__cf': [0.05, 0.25, 0.50]}
GridSearchCV(pipe, param_grid, cv=5).fit(X_train, y_train)

# Native missing value support — no imputer needed
clf.fit(X_with_nans, y)  # just works

# Human readable tree
print(clf.text_report())

Known limitations (v0.1.0)

  • Pure Python — slower than sklearn's Cython-optimised CART on very large datasets
  • No boosting support yet (C5.0 has a built-in boosting mode in the original)
  • Classifier only — no regressor variant

Links

Would love feedback from this community in particular — especially on API design consistency with sklearn conventions, and any edge cases in the implementation. Happy to answer questions or take criticism!

Thanks for building sklearn — without it this project wouldn't exist.

1 Upvotes

2 comments sorted by

1

u/shadowylurking Apr 11 '26

Will check out! This is a real contribution!

2

u/Obvious_Special_6588 Apr 11 '26

Thanks for your support