Address some predict/transform type instabilities #969
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
(edited) This PR addresses a type instability for operations (
predict
,transform
, etc) acting on machines, as identified in #959 (although this PR does not resolve the particular issue there).I admit it is not clear to me that the performance gains here are likely to significantly benefit many use cases. But having done the work to identify these instabilities, I don't see harm in addressing them.
The type instability is not difficult to address in the case of machines attached to ordinary models, by annotating a currently abstract type in the
Machine
struct. However, in the special case of a machine attached to a symbolic model (which appear exclusively in learning networks), the type instability remains (and looks difficult to remove).Benchmarks
In 69 regression models, we compared the "high level"
predict(::Machine, ...)
method with the "low level"predict(::Model, ...)
method (edit plusreformat(::Model, ...)
) implemented by third party model providers. The benchmark code is hidden below:In the tables below:
Only models with
slow_down > 1.75
orbloat > 2
are reported.Before this PR
After this PR:
Note that machines serialised using #master cannot be deserialised after this PR. But I don't consider this triggers a breaking release.
To do: