Skip to content

v0.8.0

Latest

Choose a tag to compare

@cgrtml cgrtml released this 01 Oct 21:39
· 78 commits to main since this release

A minor release rather than a patch: the ONNX export, the regressor's growth and exports, and the rebuilt playground are new surface, not fixes.

Added

  • explain(..., feature_bounds=(lower, upper)) keeps a counterfactual inside the values a feature can take, so a one-hot column is never "set to 2.2". The clipped candidate is still verified by re-predicting.
  • cases/german-credit/: the first auditable model package. One script measures a soft tree against logistic regression, CART, random forest, XGBoost and LightGBM on identical folds with the dataset's cost matrix, writes calibration, rules, three explained decisions with reachable counterfactuals, slices by age, sex and residency, refit stability, the JSON and ONNX model files with an agreement check, and a model document generated from the numbers.
  • SoftDecisionTreeRegressor gains what the classifier had and it lacked:
    growth ("incremental", "per_leaf") with growth_init,
    growth_jitter and growth_budget, deciding on held-out squared error
    and splitting along the leaf's residual; to_numpy(), a NumpySoftTree
    of kind "regressor" that predicts in target units and round-trips
    through JSON; and to_hard_tree(), a new HardRegressionTree that
    prints one value per leaf and scores R^2. The module's docstring no
    longer lists these as missing; explain() still is.
  • to_onnx() and save_onnx() on SoftDecisionTree,
    SoftDecisionTreeRegressor and NumpySoftTree: the fitted tree as an
    ONNX graph of standard operators, with feature names and class labels as
    metadata, predicting the same probabilities as the torch model to
    float32 precision. Optional extra neural-trees[onnx]; the file runs in
    any ONNX runtime without torch or this library. Measured single-row
    latency 11 microseconds in ONNX Runtime against 90 for the torch
    estimator, 33 for the numpy copy; the "Performance" page has the table
    and benchmarks/latency.py produces it.

Playground

  • The model page draws the structure each model ended up with: for the
    soft tree the gates with their heaviest features and the share of the
    data reaching each, the branch probabilities and the leaves, three
    levels deep with deeper subtrees folded into one box; the oblique cuts
    of the multivariate tree; the split type chosen at each node of the
    omnivariate tree; the routing tree of the mixture of experts with the
    share each expert receives; the layer the GAL network grew to. Start
    here gains an at-a-glance table of the ten models. Explanation.to_text()
    prints plain class values rather than numpy scalars.
  • Free-text columns on the "Try it on your data" page: a string column
    whose values are sentences becomes its 500 most frequent words and word
    pairs (TF-IDF, fitted inside each fold), so the soft tree's rules and
    counterfactuals name words ("if message did not contain gun"). Measured
    on four newsgroups (1 500 posts, body text only): the soft tree 0.855,
    a random forest 0.855, naive Bayes 0.828, CART 0.605; a tuned text
    model or an LLM will do better on nuanced text, which the page does not
    claim otherwise. The hard rule tree prints plain class values rather
    than numpy scalars.
  • A "Try it on your data" page in the playground: upload a CSV, pick the
    column to predict, and run the same comparison on it, with imputation,
    scaling and one-hot encoding fitted inside every fold. It reports the
    majority-class floor next to the models, prints the soft tree's rules,
    explains any row with its counterfactual, and hands back a model.json
    that predicts with numpy alone plus the Python that reproduces the run.
    Tables are used in the session only; the hosted app caps at 5 000 rows.
  • The Streamlit playground is rebuilt as pages around the questions a
    visitor asks. Start here shows the boundary every model learns on the
    same 2D data; Compare trains the chosen models on the same folds and
    says who is highest, who is within fold noise and who is behind, with the
    5x2cv F test on any pair; How a model works explains one model, puts its
    knobs on a live boundary and shows what it learned (rules, an explained
    prediction, split types, growth and pruning, routing); What was fixed and
    verified
    and Against the field carry the library's own contribution and
    the 24-dataset benchmark. The model registry and every cached fit live in
    playground/, the pages in views/; the contract test parses all of
    them. The hosted app installs the released package.
  • The Streamlit playground opens on a comparison table: every selected
    model's accuracy, its gap to the best and whether that gap is within fold
    noise (paired t-test over the folds), with a plain-language summary and a
    panel on what the library changed and how that was checked. Sidebar
    buttons select all models, the library's only, or the default four.
  • Two more tabs in the playground. "Explain a prediction" runs
    SoftDecisionTree.explain() on any sample of the chosen dataset: the leaf
    it reached, every gate on the path with the deciding features, the
    contribution chart and the verified single-feature counterfactual.
    "Against the field" reads benchmarks/rakipler-sonuc.json and shows the
    nine-model, 24-dataset comparison with a subset switch (all, small, large,
    binary, multi-class) and the same caveats as the documentation page. The
    hosted app installs the released package.