mlair.model_modules.linear_model

Calculate ordinary least squared model.

Module Contents

Classes

OrdinaryLeastSquaredModel

Implementation of an ordinary least squared model (OLS).

Attributes

__author__

__date__

mlair.model_modules.linear_model.__author__ = Felix Kleinert, Lukas Leufen
mlair.model_modules.linear_model.__date__ = 2019-12-11
class mlair.model_modules.linear_model.OrdinaryLeastSquaredModel(generator)

Implementation of an ordinary least squared model (OLS).

Inputs and outputs are retrieved from a generator. This generator needs to return in xarray format and has to be iterable. OLS is calculated on initialisation using statsmodels package. Train your personal OLS using:

# next(train_data) should be return (x, y)
my_ols_model = OrdinaryLeastSquaredModel(train_data)

After calculation, use your OLS model with

# input_data needs to be structured like train data
result_ols = my_ols_model.predict(input_data)
Parameters

generator – generator object returning a tuple containing inputs and outputs as xarrays

_train_ols_model_from_generator(self)
_set_x_y_from_generator(self)
_concatenate(self, new, old)
predict(self, data)

Apply OLS model on data.

static flatten(data)
static reshape_xarray_to_numpy(data)

Reshape xarray data to numpy data and flatten.

static ordinary_least_squared_model(x, y)

Calculate ols model using statsmodels.