Skip to main content

Fast-TMFG

Fast_TMFG is an ultra-fast implementation of the Triangulated Maximally Fileterd Graph (TMFG). It is based on the work by Guido Previde Massara and is fully implemented by Antonio Briola and Tong Zheng.

The interface is fully scikit-learn compatible. Consequently, it has three main methods:

  • fit(weights, cov, output): Fits the model to the input matrix weights (e.g. a squared correlation matrix) and input matrix cov (e.g. covariance matrix). This method computes the Triangulated Maximal Filtered Graph (TMFG) based on the input weight matrix. The output parameter specifies what is the nature of the desired output:
    • sparse inverse covariance matrix (output = 'logo')
    • sparse unweighted weights matrix (output = 'unweighted_sparse_W_matrix')
    • sparse weighted weights matrix (output = 'weighted_sparse_W_matrix')
  • transform(): Returns the computed cliques and separators set of the model. The method also returns the TMFG adjacency matrix.
  • fit_transform(weights, cov, output): Fits the model to the input matrix weights (e.g. a squared correlation matrix) and input matrix cov (e.g. covariance matrix), and returns the computed cliques and separators set and the TMFG adjacency matrix over the covariance matrix input. The output parameter specifies what is the nature of the desired output:
    • sparse inverse covariance matrix (output = 'logo')
    • sparse unweighted weights matrix (output = 'unweighted_sparse_W_matrix')
    • sparse weighted weights matrix (output = 'weighted_sparse_W_matrix')

We provide a detailed explanation of each function/method. Such an explanation is entirely generated through ChatGPT.

For a full understanding of the TMFG, we refer the interested reader to the following papers:

Installation

Install the latest version of the package using PyPI: pip3 install fast-tmfg

Usage Example

import numpy as np
import pandas as pd

from fast_tmfg import *

def generate_random_df(num_rows, num_columns):
  data = np.random.randint(0, 100, size=(num_rows, num_columns))
  df = pd.DataFrame(data, columns=['col_{}'.format(i) for i in range(num_columns)])
  return df

df = generate_random_df(100, 50)
corr = np.square(df.corr())
cov = df.cov()
model = TMFG()
cliques, seps, adj_matrix = model.fit_transform(corr, cov, output='unweighted_sparse_W_matrix')

How to cite us

If you use TMFG in a scientific publication, we would appreciate citations to the following paper:

@article{briola2022dependency,
  title={Dependency structures in cryptocurrency market from high to low frequency},
  author={Briola, Antonio and Aste, Tomaso},
  journal={arXiv preprint arXiv:2206.03386},
  year={2022}
}

Metadata

Release files for fast-tmfg 0.0.12

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fast-tmfg 0.0.12
File Size Uploaded
fast_tmfg-0.0.12.tar.gz 6.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for fast-tmfg 0.0.12
File Interpreter ABI Platform
fast_tmfg-0.0.12-py3-none-any.whl Python 3 none any Details

Total release size: 12.8 kB

Release files / fast_tmfg-0.0.12.tar.gz

Download URL fast_tmfg-0.0.12.tar.gz
Size 6.2 kB
Tags Source
SHA-256 checksum
How to use checksums
a65ef1c9b457b2526929d2eb09000a439e71fbdc8ab91c65e7c5d5ae43a9482c
BLAKE2b-256 checksum
How to use checksums
d66bbf75d0e44412c1921dc9a13c95cab3d0ede1c1f0c3d4479a94d3a1ac35b3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.12

Release files / fast_tmfg-0.0.12-py3-none-any.whl

Download URL fast_tmfg-0.0.12-py3-none-any.whl
Size 6.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
04a23ba109574553315c8b4307261f9fc62e5719eaeea3520c54e48d4d78fe15
BLAKE2b-256 checksum
How to use checksums
e70e0dda0efa01beb23a3284e45a549b45567ad83cbcb937971cf9902cc5cb0c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.12

Release history Release notifications | RSS feed

This release

0.0.12 This release

2 release files

0.0.11

2 release files

0.0.10

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page