Skip to content

Add getter methods for model hyperparameters after deserialization #378

Description

@HubertMajewski

I have noticed that when a model is deserialized, access to the hyperparameters that were used to create the model is no longer available.

This makes it difficult to inspect, debug, log, or reproduce a trained model after loading it from serialized storage. In many workflows, the trained model is saved and later loaded in a separate process, notebook, service, or deployment environment. At that point, it would be useful to retrieve the hyperparameters that were originally used to construct or train the model.

Current Behavior

After deserializing a model, the model can be used for prediction, but there does not appear to be a public getter or accessor for the hyperparameters used during model creation or training.

For example, if a model was created with parameters such as max_depth, n_trees, criterion, learning_rate, alpha, or similar algorithm-specific settings, those values are not easily accessible from the deserialized model instance.

Expected Behavior

Models should expose a getter function or equivalent public accessor that returns the hyperparameters used to create/train the model.

For example:

let params = model.parameters();

or:

let params = model.get_parameters();

The returned value could be the same parameter struct used when creating the model, or an equivalent read-only representation.

Why This Would Be Useful

Adding access to model hyperparameters after deserialization would help with:

Model reproducibility
Debugging production models
Experiment tracking
Auditability
Comparing serialized models
Logging model configuration after loading
Validating that a loaded model matches expected training settings
Suggested Change

Store the model’s hyperparameters as part of the trained model struct and expose them through a public getter method.

Ideally, this should work consistently across supported models where hyperparameters are passed during training.

Additional Context

Thought to generate this ticket with gpt, my use case falls more under "Experiment Tracking" as it would be helpful to reference the latest hyperparameters used and maybe associated error metrics. I would believe error metrics can be reproduced if a seed is always provided in any case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions