nemos.glm.PopulationGLM.initialize_state#

PopulationGLM.initialize_state(X, y, init_params)#

Initialize the solver by instantiating its init_state, update and, run methods.

This method also prepares the solver’s state by using the initialized model parameters and data. This setup is ready to be used for running the solver’s optimization routines.

Parameters:
  • X (Union[Array, FeaturePytree]) – The predictors used in the model fitting process. This can include feature matrices or other structures compatible with the model’s design.

  • y (Array) – The response variables or outputs corresponding to the predictors. Used to initialize parameters when they are not provided.

  • init_params – Initial parameters for the model.

Returns:

The initialized solver state

Return type:

NamedTuple

Examples

>>> import numpy as np
>>> import nemos as nmo
>>> X, y = np.random.normal(size=(10, 2)), np.random.poisson(size=10)
>>> model = nmo.glm.GLM()
>>> params = model.initialize_params(X, y)
>>> opt_state = model.initialize_state(X, y, params)
>>> # Now ready to run optimization or update steps