tlo.methods.labour_lm module

Module contains functions to be passed to LinearModel.custom function

The following template can be used for implementing:

def predict_for_individual(self, df, rng=None, **externals):

# this is a single row dataframe. get the individual record. person = df.iloc[0] params = self.parameters result = 0.0 # or other intercept value # …implement model here, adjusting result… # caller expects a series to be returned return pd.Series(data=[result], index=df.index)


def predict_for_dataframe(self, df, rng=None, **externals):

params = self.parameters result = pd.Series(data=params[‘some_intercept’], index=df.index) # result series has same index as dataframe, update as required # e.g. result[df.age == 5.0] += params[‘some_value’] return result