Giter VIP home page Giter VIP logo

ciots's Introduction

CIoTS python version CircleCI

This repository implements an approach for Causal Inference on Time Series. It is heavily based on a paper by Chen, "A time series causal model".
It also contains the base implementation of Chen's algorithm and a simple time series data generator.

Installation

pip install -U -r requirements.txt

How to use

To start, first generate a causally dependent time series.
Params:

  • dimensions (required) - the number of time series to generate
  • max_p (required) - the max time lag of any causal effects, i.e. for a point in time t there is at most a causal relationship X<sub>t-p</sub> --> Y<sub>t</sub>
  • data_length - the number of data points to generate
  • incoming_edges - the number of causal relationships per time series
from CIoTS import CausalTSGenerator

generator = CausalTSGenerator(dimensions=3, max_p=4, data_length=10000, incoming_edges=2)
data = generator.generate()

To visualize based on what model the dataset has been generated, we can visualize the partial time graph.

plt.title('Original graph')
generator.draw_graph()

Original graph

To estimate the graph, we run Chen's algorithm and render the result as graph.

from CIoTS import pc_chen, partial_corr_test, draw_graph

predicted_graph = pc_chen(partial_corr_test, data, p=4, alpha=0.05)

plt.title('Estimated graph')
draw_graph(predicted_graph, dimensions=3, max_p=4)

Estimated graph

We can also print metrics of the algorithm's accuracy.

from CIoTS import evaluate_edges

pd.DataFrame(evaluate_edges(generator.graph, predicted_graph), index=[0])

Metrics

Our research

The above tutorial runs Chen's base algorithm. Our research will focus on estimating max_p automatically and estimating the graph iteratively. This is still work in progress.

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.