JuliaAI / MLJLinearModels.jl

Generalized Linear Regressions Models (penalized regressions, robust regressions, ...)
MIT License
80 stars 13 forks source link

Use AverageLoss #110

Open tlienart opened 2 years ago

tlienart commented 2 years ago

By the way, when I started working on this PR I considered for a moment an alternative implementation with a wrapper

struct AverageLoss{L} <: Loss
    loss::L
end

(al::AverageLoss)(x::AVR, y::AVR) = al.loss(x, y)/length(y)

I found this pretty neat, but it would have required some major refactoring, mostly because of the parametric dispatch on glr for _solver, _fit etc. Are all these type restrictions really needed? Or could one get rid of them, maybe with a few traits?

But I am also fine with the current implementation. Please feel free to merge whenever you feel this PR is ready.

Originally posted by @jbrea in https://github.com/JuliaAI/MLJLinearModels.jl/issues/109#issuecomment-1004035779