Code Monkey home page Code Monkey logo

prayags / seriation-in-paleontological-data-using-mcmc Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 2.0 5.17 MB

Python implementation of the research paper with the same title published in the PLOS Computational Biology journal. Link to the paper: https://doi.org/10.1371/journal.pcbi.0020006

Python 48.89% C 51.11%
paleontology paleontological-analisys seriation mcmc probabilistic-programming data-science scientific-computing implementation-of-research-paper

seriation-in-paleontological-data-using-mcmc's Introduction

Seriation in Paleontological data using MCMC

Table of Contents

Abstract

Given a collection of fossil sites with data about the taxa that occur in each site, the task in biochronology is to find good estimates for the ages or ordering of sites. We describe a full probabilistic model for fossil data. The parameters of the model are natural: the ordering of the sites, the origination and extinction times for each taxon, and the probabilities of different types of errors. We show that the posterior distributions of these parameters can be estimated reliably by using Markov chain Monte Carlo techniques. The posterior distributions of the model parameters can be used to answer many different questions about the data, including seriation (finding the best ordering of the sites) and outlier detection. We demonstrate the usefulness of the model and estimation method on synthetic data and on real data on large late Cenozoic mammals. As an example, for the sites with large number of occurrences of common genera, our methods give orderings, whose correlation with geochronologic ages is 0.95.

Source: the paper (more info here)

Implementation details

The details of MCMC implementation and the sampling procedures for each parameter of the model can be found in our report or in the paper. Our implementation in pure Python ended up being too slow for actual practice and hence, we used Cython to introduce types in the code and also to directly call the native C/C++ numpy functions. That ended up increasing the performance but for demonstration purposes where time is key, we still suggest using the original implementation written in C by the authors of the paper. The prepackaged binary found in our repo was also compiled from the C source code. For testing purposes, you can build the Cython code. Instructions are given below.

Since MCMC is very sensitive to the initialization step, 100 MCMC chains are ran each having its unique starting data point. We use Python's multiprocessing module to run multiple chains (the actual number varies with the system its being ran on) in parallel. Each chain goes through a burn-in period of 10000 samples to converge towards the area of high density. After that, each chain saves 1000 samples out of the 10000 samples it iterates over (this is done to overcome the problem of autocorrelation among the adjacent samples).

From the 100 chains, 8 chains are selected whose expected negative log-likelihood is within one sigma of the best chain. Using the data from these chains, the final seriation and various other plots are generated.

Dataset

The dataset and the original C source code can be found at the authors' website. The dataset contains the values of parameters for European late Cenozoic large land mammals. It was derived from the NOW database on 17 July, 2003.

Results

The detailed results along with their inferences can be found in our report. All the code used to generate the correlation coefficients and the plots can be found in script.py.

Usage

  • To generate the required plots and the correlation coefficients, just run script.py. You might want to edit line no. 60 to change the number of parallel processes to be equal to the number of threads in your machine.

  • To compile the Cython code:

    $ cd Cython_Implementation
    $ python setup.py build_ext --inplace

    This will take the .cyx files and generate their counterpart C files. Those generated files will be compiled by gcc to generate binaries that can be run on your machine.

Acknowledgements

License and copyright notices for all the sources referred can be found here.

seriation-in-paleontological-data-using-mcmc's People

Contributors

prayags avatar vidishjoshi avatar yashildepani avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

vidishjoshi

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.