pyspi.calculator.Calculator
class pyspi.calculator.Calculator(dataset=None, name=None, labels=None, fast=False, sonnet=False, configfile=None, detrend=False, normalise=True)
Compute all pairwise interactions.
The calculator takes in a multivariate time-series dataset (MTS), 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
dataset (
Data
, array_like, optional) – The multivariate time series of M processes and T observations, default=Nonename (str, optional) – The name of the calculator. Mainly used for printing the results but can be useful if you have multiple instances, default=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, default=None.
subset (str, optional) - A pre-configured subset of SPIs to use. Options are "all", "fast", "sonnet", "octaveless", or "fabfour", default="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'
detrend (bool, optional) - Detrend the dataset along the time axis before normalising (if enabled), default=False.
normalise (bool, optional) - Z-score normalise the dataset along the time axis before computing SPIs, default=True..
__init__
(dataset=None, name=None, labels=None, subset=None, configfile=None, detrend = False, normalise=True)
Methods
__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
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