Skip to content

use ObservationsDims.jl to extend fit and predict to be observation aware #14

@oxinabox

Description

@oxinabox

I suggest the way to do this is that fit and predict should stay as they.
They are a consistent API with observations always a columns.

Further, ObservationDIms does not support a different obs_arrangement for different methods.
Only for different functions.
So can only declare it once for fit and predict, not once per model.

So we have another function e.g:

function smart_fit(template, outputs, inputs, weights=nothing; obsdim=nothing, kwargs...)
    outputs = organise_obs(MatrixColsOfObs(), outputs; obsdim=obsdim)
    inputs = organise_obs(MatrixColsOfObs(), inputs; obsdim=obsdim)
    if weights === nothing
        weights = uweights(size(outputs, 2))
    end
    return @mock fit(template, outputs, inputs, weights; kwargs...)
end

function smart_predict(model, inputs; obsdim=nothing, kwargs...)
    new_inputs = organise_obs(MatrixColsOfObs(), inputs; obsdim=obsdim)
    permute = xor(new_inputs isa PermutedDimsArray, inputs isa PermutedDimsArray)
    outputs = @mock predict(model, new_inputs, weights; kwargs...)
    if permute
        outputs = PermutedDimsArray(outputs, (2, 1))
    end
    return outputs
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions