scoredrulesets
A scikit-learn compatible toolkit for scored rule set classification, regression, and clustering — interpretable models that express predictions as weighted combinations of human-readable IF-THEN rules.
What are Scored Rule Sets?
A scored rule set is a set of rules of the form:
IF condition THEN score vector
Each rule assigns real-valued scores to every class/cluster. At prediction time, the score vectors of all firing rules are aggregated, and the class or value with the highest total score is returned.
Why scored rule sets?
- Full interpretability — every prediction traces back to the rules that fired.
- Single model for multi-class — no one-vs-rest decomposition needed.
- Compact models — typically 5–20 rules capture relevant patterns.
- Supports classification, regression, and clustering — unified interface.
Core Estimators
Classification
| Estimator | Algorithm | Description |
|---|---|---|
RulePLCSClassifier |
Sequential covering + GA | Fast, no external deps; suitable for large datasets |
RuleNSGA2Classifier |
NSGA-II genetic programming | Multi-objective optimization; tunable rule set complexity |
RuleGPClassifier |
logicGP-style evolution | Direct atom/rule/rule-set optimization; domain-aware |
RuleNLNClassifier |
Neural Logic Networks | Neural extraction; requires torch |
ScoredRuleSetClassifier |
Wrapper for scikit-learn learners | Convert CART, HS, RuleKit, ExSTraCS, logicGP to rulesets |
AutoScoredRuleSetClassifier |
Auto-selection via CV | Finds best estimator for your data |
Regression
| Estimator | Algorithm | Description |
|---|---|---|
RuleGPRegressor |
Native genetic programming | Direct evolution on continuous targets with closed-form scores |
RuleNSGA2Regressor |
Multi-objective GP | Optimizes accuracy vs. atom complexity trade-offs |
RulePLCSRegressor |
Sequential covering + GA | Variance-reduction gain and minimum support constraints |
CascadedRuleGPRegressor |
Two-stage residual boosting | Macro-trend discovery followed by localized residual error refinement |
ScoredRuleSetRegressor |
scikit-learn wrapper | Converts any external rule model into scored regression rules |
Subgroup Discovery & Pattern Mining
| Estimator | Description |
|---|---|
RuleNSGA2Subgroup |
Multi-objective subgroup discovery optimizing coverage vs. local mean deviation |
RuleGPSubgroup |
Genetic programming search for exceptional sub-populations |
Clustering & Explanation
| Estimator | Description |
|---|---|
RuleEvoCluster |
Native evolutionary surrogate rules approximating unsupervised cluster assignments |
ScoredRuleSetClusterer |
Cluster-label approximation; explains k-means, hierarchical clustering, etc. |
Installation
pip install scoredrulesets
Optional backends:
# imodels (HS, RIPPER, etc.)
pip install "scoredrulesets[hs]"
# scikit-ExSTraCS (learning classifier systems)
pip install "scoredrulesets[exstracs]"
# RuleKit (requires JDK)
pip install "scoredrulesets[rulekit]"
# All backends
pip install "scoredrulesets[all]"
# Benchmarking utilities (matplotlib, pandas)
pip install "scoredrulesets[benchmark]"
Quick Start
Example 1: RulePLCS Classifier (no dependencies)
from sklearn.datasets import load_iris
from scoredrulesets import RulePLCSClassifier, format_ruleset_table
X, y = load_iris(return_X_y=True)
# Train
clf = RulePLCSClassifier(max_rules=6, random_state=42)
clf.fit(X, y)
# Predict
print(clf.predict(X[:3]))
# View rules
ruleset = clf.to_ruleset()
print(format_ruleset_table(ruleset))
Example 2: Multi-Objective Genetic Programming
from sklearn.datasets import load_iris
from scoredrulesets import RuleNSGA2Classifier
X, y = load_iris(return_X_y=True)
clf = RuleNSGA2Classifier(
max_rules=8,
n_generations=50,
random_state=42
)
clf.fit(X, y)
print(f"Accuracy: {clf.score(X, y):.3f}")
Example 3: Wrapper Backend (HS)
from sklearn.datasets import load_iris
from scoredrulesets import ScoredRuleSetClassifier, dump_ruleset_json
X, y = load_iris(return_X_y=True)
# Requires: pip install scoredrulesets[hs]
clf = ScoredRuleSetClassifier(backend="hs")
clf.fit(X, y)
# Save to JSON
ruleset = clf.to_ruleset()
dump_ruleset_json(ruleset, "iris_rules.json")
Example 4: Regression (PoC)
⚠️ Regression is currently in PoC stage — not yet competitive with specialized methods.
from sklearn.datasets import load_diabetes
from scoredrulesets import ScoredRuleSetRegressor
X, y = load_diabetes(return_X_y=True)
reg = ScoredRuleSetRegressor(backend="cart")
reg.fit(X, y)
print(f"R² score: {reg.score(X, y):.3f}")
Example 5: Load & Reuse
from scoredrulesets import load_ruleset_json, ScoredRuleSetClassifier
# Load previously saved ruleset
ruleset = load_ruleset_json("iris_rules.json")
# Create estimator from it
clf = ScoredRuleSetClassifier.from_ruleset(ruleset)
# Use for predictions
print(clf.predict(X[:3]))
Example 6: Export for Papers
from scoredrulesets import dump_ruleset_markdown, dump_ruleset_latex
ruleset = clf.to_ruleset()
# Export to Markdown (documentation)
dump_ruleset_markdown(ruleset, "rules.md")
# Export to LaTeX (papers)
dump_ruleset_latex(ruleset, "rules.tex")
Rule Set JSON Format
Rule sets are serialized to human-readable JSON:
{
"format": "scoredrulesets",
"version": "0.1",
"class_labels": ["setosa", "versicolor", "virginica"],
"feature_names": ["sepal_length", "sepal_width", "petal_length", "petal_width"],
"aggregation": {"type": "argmax_sum"},
"rules": [
{
"atoms": [{"feature": "petal_length", "op": "<=", "value": 2.45}],
"scores": [1.0, 0.0, 0.0]
},
{
"atoms": [{"feature": "petal_length", "op": ">", "value": 2.45}],
"scores": [0.0, 0.4, 0.6]
}
]
}
Benchmarking & Reproducibility
Run standard benchmarks (see Makefile):
make benchmark # Full suite
make benchmark-standard # Standard datasets
make reports-standard # Regenerate reports
Reproducing Paper Benchmarks
-
ECTA 2026 Suite:
make benchmark-paper python examples/benchmarks/replot_paper_figures.py
-
MDPI AI 2026 Journal Suite (
examples/benchmarks/journal_ai/):# Regenerate Figures 1, 2, 3 and CD diagram from pre-computed results: make benchmark-journal-figures
See
examples/benchmarks/journal_ai/README.mdfor individual scripts (classification, regression, cluster explanation, multi-seed robustness, EBM baselines, subgroup discovery).
Running Tests
# Core tests (no optional deps)
pytest -q
# With HS backend
pytest -q -m hs
# sklearn compliance checks
pytest -q tests/test_estimator_checks.py
Examples
Runnable demos in examples/:
examples/estimators/example_ruleplcs_backend.py— RulePLCS direct useexamples/estimators/example_ruleplcs_wrapper.py— RulePLCS via wrapperexamples/estimators/example_rulenln_backend.py— RuleNLN (neural extraction)examples/estimators/example_rule_shrinking.py— LRC rule compaction
Configuration & Advanced Use
For detailed documentation on feature encoding, atom preselection, fit-time budgets, and plugin mechanisms, see the API documentation.
Contributing
Contributions welcome! Please read CONTRIBUTING.md first.
Citation
If you use scoredrulesets in research, please cite the accompanying paper:
@inproceedings{nunkesser2026scoredrulesets,
title={Scored Rule Sets for Interpretable Machine Learning},
author={Nunkesser, Christoph and others},
year={2026}
}
License
MIT — see LICENSE.
Metadata
Release files for scoredrulesets 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| scoredrulesets-0.2.0.tar.gz | 240.5 kB | With provenance | Details for scoredrulesets-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| scoredrulesets-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for scoredrulesets-0.2.0-py3-none-any.whl |
Total release size: 477.9 kB
Release files / scoredrulesets-0.2.0.tar.gz
| Download URL | scoredrulesets-0.2.0.tar.gz |
|---|---|
| Size | 240.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3480fd6c83bcf8eac0d8accf3a531102cdf5bf93c9501c0be28a84b8794e675e
|
|
BLAKE2b-256 checksum How to use checksums |
c86b9405222b72a5300faa672eaec034430388055e1fd3e76c5407780a1582ea
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Oct 1, 2026.
Transparency logRelease files / scoredrulesets-0.2.0-py3-none-any.whl
| Download URL | scoredrulesets-0.2.0-py3-none-any.whl |
|---|---|
| Size | 237.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f371b87506768538375e6b66001612554f727a70e3f7751e9349cdd7a99803bb
|
|
BLAKE2b-256 checksum How to use checksums |
e4b9cd2cf96d7cc846a1b1ff7b23f5168af6ed4b9cc173443589ac2b39090c9f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Oct 1, 2026.
Transparency logSecurity for scoredrulesets 0.2.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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for scoredrulesets-0.2.0.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 Oct 1, 2026.
Transparency logA 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.