gloria.IntermittentEvent#

class gloria.IntermittentEvent(*, name, prior_scale, profile, t_list=[])[source]#

A regressor to model reoccuring events at given times.

The regressor is added to the Gloria model using add_event() and does not need to be handled directly by the user.

Parameters:
  • name (str) – A descriptive, unique name to identify the regressor.

  • prior_scale (float) – Parameter modulating the strength of the regressors. Larger values allow the model to fit a larger impact of the event, smaller values dampen the impact. Must be larger than zero.

  • profile (Profile) – The profile that occurs at t_anchor. Allowed profile types are described in the Profiles section.

  • t_list (list[pandas.Timestamp] | list[str]) – A list of timestamps at which profile occurs. The exact meaning of each timestamp in the list depends on implementation details of the underlying profile, but typically refers to its mode.

Methods

classmethod from_dict(regressor_dict)[source]#

Creates an IntermittentEvent object from a dictionary.

The key-value pairs of the dictionary must correspond to the constructor arguments of the regressor.

Parameters:

regressor_dict (dict[str, Any]) – Dictionary containing all regressor fields

Returns:

IntermittentEvent regressor instance with fields from regressor_dict

Return type:

IntermittentEvent

get_impact(t)[source]#

Calculate fraction of overall profiles occurring within a timerange.

Parameters:
Returns:

impact – Fraction of overall profiles occurring between minimum and maximum date of t.

Return type:

float

make_feature(t, regressor=None)[source]#

Create the feature matrix for the intermittent event regressor.

Parameters:
Returns:

  • X (pandas.DataFrame) – The feature matrix containing the data of the regressor.

  • prior_scales (dict) – A map for feature matrix column nameprior_scale.

Return type:

tuple[DataFrame, dict]

to_dict()[source]#

Converts the intermittent event regressor to a JSON-serializable dictionary.

Returns:

Dictionary containing all regressor fields including an extra regressor_type = "IntermittentEvent" item.

Return type:

dict[str, Any]

Parameters:

self (Self)