InfinityLoop208_Finance_Aiml_F11#1
Open
InfinityLoop208 wants to merge 1 commit into
Open
Conversation
Implement model saving, loading, and versioning utilities.
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.
Feature Implemented
Model Versioning System — automatically saves trained models with semantic version tags (e.g. v1_base, v2_tuned) and maintains a JSON metadata registry tracking hyperparameters, training date, and accuracy metrics per version.
Changes Made
src/models/model_utils.py — fully implemented with the following functions:
save_model() — saves .pkl file with version tag + writes metadata
load_model() — loads a specific version by tag
list_versions() — prints a formatted table of all saved versions
rollback() — rolls back to any previously saved version
Output Description
Models are saved to models_saved/model_<version_tag>.pkl
A models_saved/metadata.json file is auto-generated and updated on every save, example:
json{
"v1_base": {
"filename": "model_v1_base.pkl",
"training_date": "2026-04-09 14:32:10",
"hyperparameters": {"n_estimators": 100, "random_state": 42},
"metrics": {"accuracy": 0.91, "precision": 0.88, "recall": 0.85}
}
}