GithubHelp home page GithubHelp logo

zelin-zhu / tcdf Goto Github PK

View Code? Open in Web Editor NEW

This project forked from m-nauta/tcdf

0.0 0.0 0.0 4.7 MB

Temporal Causal Discovery Framework (PyTorch): discovering causal relationships between time series

License: GNU General Public License v3.0

Jupyter Notebook 72.03% Python 27.97%

tcdf's Introduction

TCDF: Temporal Causal Discovery Framework

The Temporal Causal Discovery Framework (TCDF) is a deep learning framework implemented in PyTorch. Given multiple time series as input, TCDF discovers causal relationships between these time series and outputs a causal graph. It can also predict one time series based on other time series. TCDF uses Attention-based Convolutional Neural Networks combined with a causal validation step. By interpreting the internal parameters of the convolutional networks, TCDF can also discover the time delay between a cause and its effect.

The learnt temporal causal graphs can include confounders and instantaneous effects. This broadly applicable framework can be used to gain novel insights into the causal dependencies in a complex system, which is important for reliable predictions, knowledge discovery and data-driven decision making.

Corresponding Paper: "Causal Discovery with Attention-Based Convolutional Neural Networks".

Multivariate time series as input, causal graph as output

Functionality

  • Predicts one time series based on other time series and its own historical values using CNNs
  • Discovers causal relationships between time series
  • Discovers time delay between cause and effect
  • Plots temporal causal graph
  • Plots predicted time series

Check out the Jupyter Notebook TCDF Demo to see a demonstration of the functionality.

Prerequisites

General

  • Python >= 3.5
  • PyTorch (tested with PyTorch 0.4.1)
  • Optional: CUDA (tested with CUDA 9.2)

Required Python Packages:

  • numpy
  • pandas
  • random
  • heapq
  • copy
  • os
  • sys
  • matplotlib
  • pylab
  • networkx
  • argparse

Data

Required: Dataset(s) containing multiple continuous time series (such as stock markets).

File format: CSV file (comma separated) with header and a column for each time series.

Data provided

The folder 'data' contains two benchmarks:

  1. Financial benchmark with stock returns, taken from S. Kleinberg (Finance CPT) and preprocessed. Files with 'returns' in the filename are the input datasets, the other files contain the ground truth.
  2. Neuroscientific FMRI benchmark with brain networks, taken from Smith et al. and preprocessed. Files with 'timeseries' in the filename are the input datasets, the other files contain the ground truth.

Furthermore, there is one small dataset for demonstration purposes.

Running

Check out the Jupyter Notebook TCDF Demo to see a demonstration of the functionality.

Run runTCDF.py --data yourdataset.csv to run TCDF on your own dataset(s). TCDF will discover causal relationships between time series in the dataset and their time delay.

If the ground truth is available, the results of TCDF can be compared with the ground truth for evaluation as follows: runTCDF.py --ground_truth yourdataset.csv=yourgroundtruth.csv. Use --help to see all argument options.

To evaluate the predictions made by TCDF, run evaluate_predictions_TCDF. Use --help to see all argument options.

Feel free to improve TCDF. Some closed issues already mention some suggestions.

Paper

Corresponding Paper (peer-reviewed, open access): "Causal Discovery with Attention-Based Convolutional Neural Networks". Please cite this paper when using TCDF:

@article{nauta2019causal,
  title={Causal Discovery with Attention-Based Convolutional Neural Networks},
  author={Nauta, Meike and Bucur, Doina and Seifert, Christin},
  journal={Machine Learning and Knowledge Extraction},
  volume={1},
  number={1},
  pages={312-340},
  year={2019},
  publisher={Multidisciplinary Digital Publishing Institute}
}

tcdf's People

Contributors

m-nauta avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.