Closed Evizero closed 7 years ago
This is some really interesting stuff! I have a couple questions.
ObsDim
as opposed to using an Int
?Micro
and Macro
?WeightedSum
and WeightedAverage
AvgMode
s?Do we need new types for ObsDim as opposed to using an Int?
Mhm, here in losses I don't really make use of it for dispatch (I do however in MLDataUtils and MLLabelUtils). Well, for one one would have to specify explicitly the number of dimensions if it is the last dimension that specifies the obs, but I guess that would be manageable. Though I get the appeal of using numbers, I do like the consistency of using it throughout JuliaML.
The main thing I would have to think about how to do it nicely without the type would be O
k = prod(@ntuple($N, n -> n == $O ? 1 : size(output,n)))
but I guess I could. In the other packages I allow the obsdim
to be specified using a kw argument, where one can specify it in a number of ways, such as obsdim = 1
, obsdim =:last
, etc, but since loss functions are an inner loop kinda deal I focus much more on performance and would prefer compile time decisions
What is Micro and Macro?
Not really relevant for losses. I mainly need it for MLMetrics where there is a decision to be made for computing the micro or macro averages (example: http://www.cnts.ua.ac.be/~vincent/pdf/microaverage.pdf).
I am unsure how to handle this. I think it would be nice to use the same kind of specification in both packages, but it also is kinda weird to specify "Micro" or "Macro" when "Mean" would be more descriptive. I am open to ideas
How about having both WeightedSum and WeightedAverage AvgModes?
That I can answer with a clear: Yes we can. I'll add one
here in losses I don't really make use of it for dispatch (I do however in MLDataUtils and MLLabelUtils)
That's enough of a reason for me. I'd rather have the consistency too. Also, thanks for the micro/macro link.
Concerning weighted sum, what behaviour would you expect from using a weight vector [1,2,3]
for three obs. Would you expect their values be multiplied by [1,2,3]
or by a normed version [1.66,3.33,.5]
?
Edit: I'll make a parameter to WeightedMean
and WeightedSum
called normalize
so a user can choose
Arg, damit. I need to reduce the tests. They now take so long that travis thinks it crashed
I am combining the initial broadcast @ahwillia implemented with the concept of an
AverageMode
, which I originally planned for MLMetrics. Introducing it here instead will allow for some synergy and a more consistent interface, as MLMetrics will depends on LossFunctions. Basically I am planning on deprecatingmeanvalue
andsumvalue
in favour of specifying an additional parameter.For these losses
AvgMode.Micro
andAvgMode.Macro
yield the same result. The distinction between a micro- and a macro average will be more interesting in MLMetrics.The real power comes with matrices or higher dimensional arrays, because this change will allow for multivariate regression problems. Basically I allow the user to choose if he/she would like to sum/average over all observations or just over individual observations. The concept of
ObsDim
allows choosing which dimension of the array denotes the observations and is also used in MLDataUtils and MLLabelUtils.I have not implemented any tests yet, but I thought this would be a good time to allow for opinions and criticism