add serialization features to be able to robustly load and save models - #102
Closed
ericphanson wants to merge 7 commits into
Closed
add serialization features to be able to robustly load and save models#102ericphanson wants to merge 7 commits into
ericphanson wants to merge 7 commits into
Conversation
>In the case where one wants to use an extension (without worrying about the feature of the extension being available on older Julia versions) while still supporting older Julia versions without workspace support, the packages under [weakdeps] should be duplicated into [extras]. This is an unfortunate duplication, but without doing this the project verifier under older Julia versions will throw an error if it finds packages under [compat] that is not listed in [extras].
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #102 +/- ##
==========================================
+ Coverage 86.94% 92.10% +5.15%
==========================================
Files 8 10 +2
Lines 1218 1203 -15
==========================================
+ Hits 1059 1108 +49
+ Misses 159 95 -64 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Collaborator
|
Thanks for this.
|
Contributor
Author
|
Yeah, this isn't really specific to Lasso.jl at all, and I don't think GLM has it. But I will just use this code internally in my project. It is here if someone wants to adopt it. (test failure was unrelated I believe) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
to use Lasso.jl for my use cases, I need to be able to persist trained models and run inference later with them.
This PR adds:
InferenceModel: a struct that stores only the essential information needed to predict from a modelInferenceModelinto aDictin a stable way, for serializationand a package extension for JSON.jl, so if the user also loads JSON.jl, then they can use
write_json, andread_jsonto simply load/save models.I have seen various ways model serialization can go wrong in the past and have tried to make a simple and robust system for it to work here.
For example:
Dict/Vector/etc types that are robust.nameofor printed representation of Julia objects (show,print, etc), because that may change in non-breaking package or julia versionsto_dictandInferenceModel(d::Dict)because those bits can be modified to preserve compatibility as needed. I.e. if we add a field or remove a field inInferenceModel, we can modifyInferenceModel(d::Dict)andto_dictat the same time to preserve compatibility, because we have this extra bit of indirection.I have not added a
serialization_formatkey to the dictionary or similar. If we do need to support multiple formats, we can add that later, and the absence of the key can be interpreted as v1. I think for now it is unnecessary complexity and probably we won't need multiple incompatible formats anyway.cowritten with claude sonnet 5