Data Preparation

You can feed lvr.Lvr with:

  1. effects only:

    >>> Lvr([789, 621, 109, 65, 45, 30, 27, 15, 12, 9])
    
  2. effects with causes:

    >>> Lvr(effects=[789, 621, 109, 65, 45, 30, 27, 15, 12, 9],
    ...         causes=[1, 1, 2, 4, 3, 2, 1 , 4, 2, 1])
    
  3. with a list_dict:

    >>> Lvr(list_dict=[{'index': 'planet1',
    ...                     'radius': 12, 'mass': 56},
    ...                    {'index': 'planet2',
    ...                     'radius': 20, 'mass': 70}])
    

Create a list-dict

You may want to turn your dict:

>>> {'planet1': {'radius': 12, 'mass': 56},
...  'planet2': {'radius': 20, 'mass': 70}}

into a list-dict:

>>> [{'index': 'planet1', 'radius': 12, 'mass': 56},
...  {'index': 'planet2', 'radius': 20, 'mass': 70}]

with list_dict().

But first, let’s consider the surface of each planet as our effect:

>>> from math import pi
>>> from lvr.data import exoplanets
>>> from lvr.helpers import list_dict
>>> from lvr import Lvr
>>> eplanets = {planet: dict(surface=4*pi*values['radius']**2,
...                          mass=values['mass'])
...             for planet, values in exoplanets().items()}

Now we turn our dict into a list-dict:

>>> prepped = list_dict(eplanets, cause='mass', effect='surface')

which we finally feed Lvr with:

>>> eps = Lvr(list_dict=prepped)
>>> eps
0.2 => 0.8 [PARETO PRESENT 0.98]