Closed ablaom closed 8 months ago
Regarding option (1): That's actually how the package started out initially, the fit result was standardized as a struct combining a model and scores. I mainly changed it because the report
seemed to be a better fit. It would require some work to revert everything back to this API.
Regarding (2): The library design initially returned a tuple of train and test scores from transform
, thus at the beginning transform
was augmented_transform
and it was one of the main motivations to build this library. augmented_transform
is the most flexible way to combine multiple detection models, you always work with the train and test scores.
In conclusion, I would prefer option (1). Regarding prefit
, I'll have a look when the changes are implemented.
Sounds good. Let me know if and when further guidance from me would be helpful.
Fixed compatibility with adapt api for MLJBase v1 compatibility, no more augmented transform.
A continuation of the discussion at https://github.com/JuliaAI/MLJBase.jl/pull/841#issuecomment-1281941079.
I've started to look a bit more closely at the code here. The current use of
augmented_transform
is making adaption difficult. I feel that the ultimate reason for this is thataugmented_transform
is trying to mimic an MLJ operation, liketransform
orpredict
but is not able to do this faithfully for the following reason. First, all operations in MLJ are defined in the first place on models, and only overloaded for machines later, in a rather generic way. The signature of an operation looks likeop(model, fitresult, X)
, which only includesfitresult
from the output offit(model, ....)
- it does not seereport
. But the way OutlierDetection is currently working, the training scores, whichaugmented_transform
needs, are being placed in thereport
, so it's not possible to defineaugmented_transform
at the level of models. So in the OutlierDetection code, there is outlier-specific overloading ofaugmented_transform
for machines, which is really a hack, it seems to me. One specific problem is that this includes some logic to distinguish the different types of machine (eg, wrapping an ordinary atomic detector, or some kind of composite). This logic is achieved through dispatch on the type ofM
inMachine{M}
. But using the "banana" changes proposed at MLJBase,M
is going to beSymbol
all the time, so that the type we want is unknown.Two possibilities I see - there may well be others - are:
Put training scores of all detectors in
fitresult
instead ofreport
. (By the way, there is a mechanism now to expose internals of a learning network as an item in the exported composite modelfitresult
, as we already had for reports. See Example F in the "banana" doc PR.) Defineaugmented mented_transform
at the level of models, and only extend later for machines in a generic way.Abandon the
augmented_transform
approach altogether and begin afresh. My feeling it ought to be possible to make this work, but I'm not familiar enough with the code base now to know how much work this would be. Maybe I could develop a proof of concept.@davnn I wonder if you have a feeling about which approach might be best, or some other idea?
In answer to some earlier queries:
Yes, only the hard-coded operation can be used here.
I shouldn't think you should have to provide any fallback for
prefit
at all because onlyfit
andupdate
ever callprefit
and these already have fallbacks, ensuring only the oneprefit
ever gets called. But perhaps you are ahead of me on this one and I may be missing something.