modeldekom module

Module for making attribution analysis of a model.

The main function is attribution

Created on Wed May 31 08:50:51 2017

@author: hanseni

modeldekom.attribution(model, experiments, start='', end='', save='', maxexp=10000, showtime=False, summaryvar=['*'], silent=False, msilent=True, type='level')[source]

Calculates an attribution analysis on a model accepts a dictionary with experiments. the key is experiment name, the value is a list of variables which has to be reset to the values in the baseline dataframe.

modeldekom.attribution_new(model, experiments, start='', end='', save='', maxexp=10000, showtime=False, summaryvar=['*'], silent=False, msilent=True, type='level')[source]

Calculates an attribution analysis on a model accepts a dictionary with experiments. the key is experiment name, the value is a list of variables which has to be reset to the values in the baseline dataframe.

modeldekom.ilist(df, pat)[source]

returns a list of variable in the model matching the pattern, the pattern can be a list of patterns of a sting with patterns seperated by blanks

This function operates on the index names of a dataframe. Relevant for attribution analysis

modeldekom.GetSumImpact(impact, pat='PD__*')[source]

Gets the accumulated differences attributet to each impact group

modeldekom.GetLastImpact(impact, pat='RCET1__*')[source]

Gets the last differences attributet to each impact group

modeldekom.GetAllImpact(impact, pat='RCET1__*')[source]

Gets the last differences attributet to each impact group

modeldekom.GetOneImpact(impact, pat='RCET1__*', per='')[source]

Gets differences attributet to each impact group in period:per

modeldekom.AggImpact(impact)[source]

Calculates the sum of impacts and place in the last column

This function is applied to the result iof a Get* function

class modeldekom.totdif(model, summaryvar='*', desdic={}, experiments=None)[source]

Bases: object

Class to make modelvide attribution analysis

explain_last(pat='', top=0.9, title='', use='level', threshold=0.0, ysize=5)[source]

Explains last period

Parameters:
  • pat (TYPE, optional) – DESCRIPTION. Defaults to ‘’.

  • top (TYPE, optional) – DESCRIPTION. Defaults to 0.9.

  • title (TYPE, optional) – DESCRIPTION. Defaults to ‘’.

  • use (TYPE, optional) – DESCRIPTION. Defaults to ‘level’.

  • threshold (TYPE, optional) – DESCRIPTION. Defaults to 0.0.

  • ysize (TYPE, optional) – DESCRIPTION. Defaults to 5.

Returns:

DESCRIPTION.

Return type:

fig (TYPE)

explain_sum(pat='', top=0.9, title='', use='level', threshold=0.0, ysize=5)[source]

Explains the sum

Parameters:
  • pat (TYPE, optional) – DESCRIPTION. Defaults to ‘’.

  • top (TYPE, optional) – DESCRIPTION. Defaults to 0.9.

  • title (TYPE, optional) – DESCRIPTION. Defaults to ‘’.

  • use (TYPE, optional) – DESCRIPTION. Defaults to ‘level’.

  • threshold (TYPE, optional) – DESCRIPTION. Defaults to 0.0.

  • ysize (TYPE, optional) – DESCRIPTION. Defaults to 5.

Returns:

DESCRIPTION.

Return type:

fig (TYPE)

explain_per(pat='', per='', top=0.9, title='', use='level', threshold=0.0, ysize=5)[source]

Explains a periode

Parameters:
  • pat (TYPE, optional) – DESCRIPTION. Defaults to ‘’.

  • per (TYPE, optional) – DESCRIPTION. Defaults to ‘’.

  • top (TYPE, optional) – DESCRIPTION. Defaults to 0.9.

  • title (TYPE, optional) – DESCRIPTION. Defaults to ‘’.

  • use (TYPE, optional) – DESCRIPTION. Defaults to ‘level’.

  • threshold (TYPE, optional) – DESCRIPTION. Defaults to 0.0.

  • ysize (TYPE, optional) – DESCRIPTION. Defaults to 5.

Returns:

DESCRIPTION.

Return type:

fig (TYPE)

explain_allold(pat='', stacked=True, kind='bar', top=0.9, title='', use='level', threshold=0.0, resample='', axvline=None)[source]
explain_all(pat='', stacked=True, kind='bar', top=0.9, title='', use='level', threshold=0.0, resample='', axvline=None)[source]

Explains all

Parameters:
  • pat (TYPE, optional) – DESCRIPTION. Defaults to ‘’.

  • stacked (TYPE, optional) – DESCRIPTION. Defaults to True.

  • kind (TYPE, optional) – DESCRIPTION. Defaults to ‘bar’.

  • top (TYPE, optional) – DESCRIPTION. Defaults to 0.9.

  • title (TYPE, optional) – DESCRIPTION. Defaults to ‘’.

  • use (TYPE, optional) – DESCRIPTION. Defaults to ‘level’.

  • threshold (TYPE, optional) – DESCRIPTION. Defaults to 0.0.

  • resample (TYPE, optional) – DESCRIPTION. Defaults to ‘’.

  • axvline (TYPE, optional) – DESCRIPTION. Defaults to None.

Returns:

None.

totexplain(pat='*', vtype='all', stacked=True, kind='bar', per='', top=0.9, title='', use='level', threshold=0.0, ysize=10, **kwargs)[source]
Wrapper for different explanations
Parameters:
  • pat (TYPE, optional) – DESCRIPTION. Defaults to ‘*’.

  • vtype (per|all|last|sum, optional) – what data to attribute. Defaults to ‘all’.

  • stacked (TYPE, optional) – DESCRIPTION. Defaults to True.

  • kind (TYPE, optional) – DESCRIPTION. Defaults to ‘bar’.

  • per (TYPE, optional) – DESCRIPTION. Defaults to ‘’.

  • top (TYPE, optional) – DESCRIPTION. Defaults to 0.9.

  • title (TYPE, optional) – DESCRIPTION. Defaults to ‘’.

  • use (TYPE, optional) – DESCRIPTION. Defaults to ‘level’.

  • threshold (TYPE, optional) – DESCRIPTION. Defaults to 0.0.

  • ysize (TYPE, optional) – DESCRIPTION. Defaults to 10.

  • **kwargs (TYPE) – DESCRIPTION.

Returns:

DESCRIPTION.

Return type:

fig (TYPE)