Open Nosferican opened 5 years ago
Bump. @Nosferican Any update on this? In particular, I need to be able to do predict(mod::EconometricModel{<:NominalResponse}, newdata::DataFrame)
.
I was going to leave it as a GSOC part of a project but I think I can take a look at it... Shouldn't be too bad to add.
Let's consider the example of NominalResponse
. Once you have your features in the form of the model matrix X
, then getting the probabilities is very straightforward:
function predict(model::EconometricModel{<:NominalResponse}, new_X::AbstractMatrix)
n, p = size(new_X)
probs = hcat(zeros(n), new_X * reshape( m.β, (p, m.estimator.categories - 1) )
for i = 1:n
probs[i, :] .= StatsFuns.softmax(probs[i, :])
end
return probs
end
The problem is: how does Econometrics turn a DataFrame into a Matrix? If I want to call predict(model::EconometricModel{<:NominalResponse}, new_data::AbstractDataFrame)
, then I need to use that exact same process to turn my new_data::AbstractDataFrame
into new_X::AbstractMatrix
.
Aye. I had a talk with @kleinschmidt back in February about various strategies for handling the cases of rank deficient and instrumental variables. I think I will just keep a formula for prediction that does the transformations from original to suitable for prediction. In the case of the ologit, I am envisioning returning a NamedTuple{(:response, :probs), (:Symbol, Matrix{Float64})}
.
Bump.
Implement
predict(mod::EconometricModel, newdata::Any)
. This should help integrate with the MLJ API.