Skip to main content

Implements the Computational Hypergraph Discovery algorithm

Project description

Computational Hypergraph Discovery: A Gaussian process framework for connecting the dots

License: Apache 2.0 Python 3.11.4 GitHub Repo

This is the source code for the paper "Codiscovering graphical structure and functional relationships within data: A Gaussian Process framework for connecting the dots".

Please see the companion blog post for a gentle introduction to the method and the code. See the repo here for full documentation and examples.

Installation

The code is written in Python 3 and requires the following packages:

  • matplotlib
  • NumPy
  • scipy
  • JAX
  • networkx

Using pip

The code is available on PyPI and can be installed using pip:

pip install ComputationalHypergraphDiscovery

Quick start

Graph discovery takes very little time. The following code runs the method on the example dataset provided in the repo. The dataset is a 2D array of shape (n_samples, n_features) where each row is a sample and each column is a feature. After fitting the model, the graph is stored in the GraphDiscovery object, specifically its graph G attribute. The graph is a networkx object, which can be easily plotted using .plot_graph().

You can find the Sachs dataset in the repo, at this link.

import ComputationalHypergraphDiscovery as CHD
import pandas as pd
df=pd.read_csv('https://github.com/TheoBourdais/ComputationalHypergraphDiscovery/blob/8c3fed6dfe58a01cb73e469579ff7703b0681f7e/examples/Sachs/SachsData.csv?raw=true')
df=df.sample(n=500,random_state=1) #subsample to run example quickly
kernels=[CHD.Modes.LinearMode(),CHD.Modes.QuadraticMode()]
graph_discovery = CHD.GraphDiscovery.from_dataframe(df,kernels=kernels)
graph_discovery.fit()
graph_discovery.plot_graph()

Available modifications of the base algorithm

The code gives an easy-to-use interface to manipulate the graph discovery method. It is designed to be modular and flexible. The main changes you can make are

  • Kernels and modes: You can decide what type of function will be used to link the nodes. The code provides a set of kernels, but you can easily add your own. The interface is designed to resemble the scikit-learn API, and you can use any kernel from scikit-learn.
  • Decision logics: In order to identify the edges of the graph, we need to decide whether certain connections are significant. The code provides indicators (like the level of noise), and the user specifies how to interpret them. The code provides a set of decision logic, but you can define your own.
  • Clustering: If a set of nodes is highly dependent, it is possible to merge them into a cluster of nodes. This gives greater readability and prevents the graph discovery method from missing other connections.
  • Possible edges: If you know that specific nodes cannot be connected, you can specify it to the algorithm. By default, all edges are possible.

Full documentation is available here.

Acknowledgements

Copyright 2023 by the California Institute of Technology. ALL RIGHTS RESERVED. United States Government Sponsorship acknowledged. This software may be subject to U.S. export control laws. By accepting this software, the user agrees to comply with all applicable U.S. export laws and regulations. User has the responsibility to obtain export licenses, or other export authority as may be required before exporting such information to foreign countries or providing access to foreign persons.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

computationalhypergraphdiscovery-2.1.0.tar.gz (29.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file computationalhypergraphdiscovery-2.1.0.tar.gz.

File metadata

File hashes

Hashes for computationalhypergraphdiscovery-2.1.0.tar.gz
Algorithm Hash digest
SHA256 90d95e645550269dcc5b7cfd69717902d421a9ef67511148d1ccaab2fa531a77
MD5 cf063a816ddae0b68b49045239f2b9c0
BLAKE2b-256 1d9817ac3d5080ba772587fbd68e698eb99c8e869eac51a812a5bf7849d2c1db

See more details on using hashes here.

File details

Details for the file ComputationalHypergraphDiscovery-2.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for ComputationalHypergraphDiscovery-2.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 13df0e3516d75d7948fe253c4a9e252608ec719b83553101ccee3cfbe7967ba9
MD5 695a590153fa49e5bd727fbd637f6495
BLAKE2b-256 dc7bd6d88a18b7859935b96e82cefbbd550b1257815d5717250904032bac3ca5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page