pyspi.calculator.Calculator

class pyspi.calculator.Calculator(dataset=None, name=None, labels=None, fast=False, sonnet=False, configfile=None, normalise=True)

Compute all pairwise interactions.

The calculator takes in a multivariate time-series dataset, computes and stores all pairwise interactions for the dataset. It uses a YAML configuration file that can be modified in order to compute a reduced set of pairwise methods.

Example

import numpy as np

dataset = np.random.randn(5,500)   # create a random multivariate time series (MTS)
calc = Calculator(dataset=dataset) # Instantiate the calculator
calc.compute()                     # Compute all pairwise interactions
ParametersDescription

  • dataset (Data, array_like, optional) – The multivariate time series of M processes and T observations, defaults to None

  • name (str, optional) – The name of the calculator. Mainly used for printing the results but can be useful if you have multiple instances, defaults to None.

  • labels (array_like, optional) – Any set of strings by which you want to label the calculator. This can be useful later for classification purposes, defaults to None.

  • subset (str, optional) - A pre-configured subset of SPIs to use. Options are "all", "fast", "sonnet", "octaveless", or "fabfour", defaults to "all".

  • configfile (str, optional) – The location of the YAML configuration file. See Using a reduced SPI set, defaults to '</path/to/pyspi>/pyspi/config.yaml'

  • normalise (bool, optional) - Normalise the dataset along the time axis before computing SPIs, defaults to True.

__init__(dataset=None, name=None, labels=None, subset=None, configfile=None, normalise=True)

Methods

MethodDescription

__init__([dataset, name, labels, fast, ...])

compute()

Compute the SPIs on the MVTS dataset.

load_dataset(dataset)

Load a new dataset into existing instance.

set_group(classes)

Assigns a numeric value to a Calculator instance based on a list of classes.

_rmin()

Iterate through all SPIs are remove the minimum. Fixes absolute errors when correlating.

get_stat_labels()

Get the keywords for each SPI.

_get_correlation_df(with_labels=False, rmin=False)

Generates a DataFrame showing correlations between SPIs.

Attributes

AttributeDescription

dataset

Dataset as a data object.

group

The numerical group assigned during set_group()

group_name

The group name assigned during set_group().

labels

List of calculator labels.

n_spis

Number of SPIs in the calculator.

name

Name of the calculator.

spis

Dict of SPIs.

table

Results table for all pairwise interactions (each represented as an MPI).

Last updated

All page cover images on this wiki are created with the help of DALL-E, an AI program developed by OpenAI, or stock images from Unsplash.