Skip to content

Conversation

ablaom
Copy link
Member

@ablaom ablaom commented Aug 24, 2025

In this breaking PR we:

  1. Replace the trait is_static(learner) - which could be true or false, with a new
    trait kind_of(leaner) taking one of three possible values: Discriminative(),
    Generative() and Static(). More on these core patterns below.

  2. Dump the Single <: KindOfProxy abstract type, and all it's sole instances, along the
    lines described in Dump the Single <: KindOfProxy subtypes #53.

  3. Adjust the role of the training data deconstructor, features(learner, data): Whereas
    previously, it needed to be overloaded to return nothing to flag that predict
    consumes no data (which is now is indicated by declaring kind_of(learner) = Generative()) it is now implemented only if kind_of(learner) == Discriminative(), and
    only if it fulfills the old contract (it's output is can be passed as valid data to
    predict or transform)

  4. Remove the fallbacks for all three training data deconstructors, features, target,
    weights.

The main point of change (1) is to make explicit what was already implicit in the design,
but delineated with the awkward use of the features method. It also scaffolds the change
(2).

The main point of (4) is to simplify, unify, and to remove "hidden knowledge" (the
existence and form of the fallbacks).

Note that I've had to comment out the LearnTestAPI part of the docs, because that package is a downstream dependency. (Changes there have already been worked out and tested.) So after this PR is merged and a new release tagged, we'll need to:

  • Reinstate LearnTestAPI docs (including adding LearnTestAPI to docs/Project.toml)

Below is an extract from the new documentation introducing the core patterns discussed in (1). Note that these patterns already existed - they just weren't explicitly named before.


LearnAPI.jl supports three core patterns. The default pattern, known as the
LearnAPI.Descriminative pattern, looks like this:

model = fit(learner, data)
predict(model, newdata)

Here learner specifies hyperparameters, while model stores
learned parameters and any byproducts of algorithm execution.

Transformers ordinarily implement transform instead of predict. For more on
predict versus transform, see Predict or transform?

Two other fit/predict/transform patterns supported by LearnAPI.jl are:
LearnAPI.Generative which has the form:

model = fit(learner, data)
predict(model) # a single distribution, for example

and LearnAPI.Static, which looks like this:

model = fit(learner) # no `data` argument
predict(model, data) # may mutate `model` to record byproducts of computation

Do not read too much into the names for these patterns, which are formalized here. Use may not always correspond to prior associations.

@ablaom ablaom marked this pull request as draft August 24, 2025 09:20
Copy link

codecov bot commented Aug 24, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.59%. Comparing base (03a953b) to head (5e31043).
⚠️ Report is 16 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #54      +/-   ##
==========================================
- Coverage   97.70%   97.59%   -0.12%     
==========================================
  Files           9        8       -1     
  Lines          87       83       -4     
==========================================
- Hits           85       81       -4     
  Misses          2        2              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ablaom ablaom marked this pull request as ready for review August 24, 2025 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant