Callbacks

class pygam.callbacks.CallBack(name=None)

Bases: pygam.core.Core

CallBack class

class pygam.callbacks.Accuracy

Bases: pygam.callbacks.CallBack

on_loop_start(y, mu)

runs the method at start of each optimization loop

Parameters:
  • y (array-like of length n) – target data
  • mu (array-like of length n) – expected value data
Returns:

accuracy

Return type:

np.array of length n

class pygam.callbacks.Coef

Bases: pygam.callbacks.CallBack

on_loop_start(gam)

runs the method at start of each optimization loop

Parameters:gam (float) –
Returns:coef_
Return type:list of floats
class pygam.callbacks.Deviance

Bases: pygam.callbacks.CallBack

Deviance CallBack class

on_loop_start(gam, y, mu)

runs the method at loop start

Parameters:
  • gam (GAM instance) –
  • y (array-like of length n) – target data
  • mu (array-like of length n) – expected value data
Returns:

deviance

Return type:

np.array of length n

class pygam.callbacks.Diffs

Bases: pygam.callbacks.CallBack

on_loop_end(diff)

runs the method at end of each optimization loop

Parameters:diff (float) –
Returns:diff
Return type:float
pygam.callbacks.validate_callback(callback)

validates a callback’s on_loop_start and on_loop_end methods

Parameters:callback (Callback object) –
Returns:
Return type:validated callback
pygam.callbacks.validate_callback_data(method)

wraps a callback’s method to pull the desired arguments from the vars dict also checks to ensure the method’s arguments are in the vars dict

Parameters:method (callable) –
Returns:
Return type:validated callable