Skip to content

Conversation

@ablaom
Copy link
Member

@ablaom ablaom commented Oct 20, 2025

Merge conflicts will be best managed if this PR is merged after:

  • Forthcoming update to bump the compat for CategoricalArrays to 1.0 (WIP of @ablaom)

Density estimators

This PR adds evaluate support for density estimators. According to the API docs such a
model is viewed as Probabilistic <: Supervised but provided X = nothing as
features. The target y are the samples to be fitted, and yhat = predict(model, nothing)
outputs a single pdf, the density being sought. A typical workflow using such a model might look like this:

y = <samples>
mach = machine(model, nothing, y) # `nothing` instead of features
fit!(mach)
yhat = predict(mach, nothing) # single pdf
log_loss(fill(yhat, length(y)), y)  # get an aggregate of the loss based on multiple samples, so need `fill` here

At present evaluate is unsupported because it tries to pair the single yhat with
multiple ground truth values y. The mitigation provided in this PR is to replace yhat with
FillArrays.Fill(yhat, nrows(y)) (a lazy version of fill(yhat, nrows(y))) in the case
that X == nothing. So then the following works:

evaluate(model, nothing, y, measure=log_loss)

After this PR is merged:

  • Update [this link] so that it points to the example at the end of test/resampling.jl
    instead (some testing has been moved over in this PR).

cc @LucasMatSP

@ablaom ablaom marked this pull request as draft October 20, 2025 23:53
ytest = y[test]
yhat = predict(mach, nothing) # single UnivariateFinite distribution

# Estmiate out-of-sample loss. Notice we have to make duplicate versions `yhat`, to

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small typo Estmiate

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.

3 participants