Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
oxinabox opened this issue May 5, 2020 · 0 comments

Comments

@oxinabox
Copy link
Member

oxinabox commented May 5, 2020

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
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

No branches or pull requests

1 participant