pyspi: Statistics for Pairwise Interactions
pyspi GitHub
  • Welcome to pyspi
    • Citing pyspi
  • Installing and using pyspi
    • Installation
      • Alternative Installation Options
      • Troubleshooting
    • Usage
      • Walkthrough Tutorials
        • Getting Started: A Simple Demonstration
        • Neuroimaging: fMRI Time Series
        • Finance: Stock Price Time Series
        • Distributing Calculations
      • Advanced Usage
        • Creating a reduced SPI set
        • Distributing calculations on a cluster
      • FAQ
  • Information about pyspi
    • SPIs
      • Glossary of Terms
      • Table of SPIs
      • SPI Descriptions
        • Basic Statistics
        • Distance Similarity
        • Causal Inference
        • Information Theory
        • Spectral
        • Miscellaneous
      • SPI Subsets
    • API Reference
      • pyspi.calculator.CorrelationFrame
      • pyspi.calculator.Calculator
      • pyspi.data.Data
      • pyspi.calculator.CalculatorFrame
      • pyspi.utils.filter_spis
    • Publications using pyspi
    • Related Packages
  • Development
    • Development
      • Incorporating new SPIs
      • Contributing to pyspi
      • Code of Conduct
    • License
Powered by GitBook

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.

On this page
  • Example
  • Methods
  • Attributes
  1. Information about pyspi
  2. API Reference

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
Parameters
Description

  • 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.

  • 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

Method
Description

__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_correlation_df(with_labels=False, rmin=False)

Generates a DataFrame showing correlations between SPIs.

Attributes

Attribute
Description

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).

Previouspyspi.calculator.CorrelationFrameNextpyspi.data.Data

Last updated 1 month ago

dataset (, array_like, optional) – The multivariate time series of M processes and T observations, default=None

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

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

configfile (, optional) – The location of the YAML configuration file. See , defaults to '</path/to/pyspi>/pyspi/config.yaml'

Get the for each SPI.

Data
str
str
str
Using a reduced SPI set
keywords