ABC random forests for model choice and parameter estimation, python wrapper
Project description
ABC random forests for model choice and parameters estimation
Random forests methodologies for :
- ABC model choice (Pudlo et al. 2015)
- ABC Bayesian parameter inference (Raynal et al. 2018)
Libraries we use :
- Ranger (Wright and Ziegler 2015) : we use our own fork and have tuned forests to do “online”[^1] computations (Growing trees AND making predictions in the same pass, which removes the need of in-memory storage of the whole forest)[^2].
- Eigen3 (Guennebaud, Jacob, et al. 2010)
As a mention, we use our own implementation of LDA and PLS from (Friedman, Hastie, and Tibshirani 2001, 1:81, 114), PLS is optimized for univariate, see 5.1. For linear algebra optimization purposes on large reftables, the Linux version of binaries (standalone and python wheel) are statically linked with Intel’s Math Kernel Library, in order to leverage multicore and SIMD extensions on modern cpus.
There is one set of binaries, which contains a Macos/Linux/Windows (x64 only) binary for each platform. There are available within the “Releases” tab, under “Assets” section (unfold it to see the list).
This is pure command line binary, and they are no prerequisites or library dependencies in order to run it. Just download them and launch them from your terminal software of choice. The usual caveats with command line executable apply there : if you’re not proficient with the command line interface of your platform, please learn some basics or ask someone who might help you in those matters.
The standalone is part of a specialized Population Genetics graphical interface DIYABC-RF, presented in MER (Molecular Ecology Resources, Special Issue), (Collin et al. 2021).
Python
Installation
pip install pyabcranger
Notebooks examples
- On a toy example with , using (Lintusaari et al. 2018) as graph-powered engine.
- Population genetics demo, data from (Collin et al. 2021), available there
Usage
- ABC Random Forest - Model choice or parameter estimation command line options
Usage:
../build/abcranger [OPTION...]
-h, --header arg Header file (default: headerRF.txt)
-r, --reftable arg Reftable file (default: reftableRF.bin)
-b, --statobs arg Statobs file (default: statobsRF.txt)
-o, --output arg Prefix output (modelchoice_out or estimparam_out by
default)
-n, --nref arg Number of samples, 0 means all (default: 0)
-m, --minnodesize arg Minimal node size. 0 means 1 for classification or
5 for regression (default: 0)
-t, --ntree arg Number of trees (default: 500)
-j, --threads arg Number of threads, 0 means all (default: 0)
-s, --seed arg Seed, generated by default (default: 0)
-c, --noisecolumns arg Number of noise columns (default: 5)
--nolinear Disable LDA for model choice or PLS for parameter
estimation
--plsmaxvar arg Percentage of maximum explained Y-variance for
retaining pls axis (default: 0.9)
--chosenscen arg Chosen scenario (mandatory for parameter
estimation)
--noob arg number of oob testing samples (mandatory for
parameter estimation)
--parameter arg name of the parameter of interest (mandatory for
parameter estimation)
-g, --groups arg Groups of models
--help Print help
- If you provide
--chosenscen
,--parameter
and--noob
, parameter estimation mode is selected. - Otherwise by default it’s model choice mode.
- Linear additions are LDA for model choice and PLS for parameter estimation, “–nolinear” options disables them in both case.
Model Choice
Example
Example :
abcranger -t 10000 -j 8
Header, reftable and statobs files should be in the current directory.
Groups
With the option -g
(or --groups
), you may “group” your models in
several groups splitted . For example if you have six models, labeled
from 1 to 6 `-g “1,2,3;4,5,6”
Generated files
Four files are created :
modelchoice_out.ooberror
: OOB Error rate vs number of trees (line number is the number of trees)modelchoice_out.importance
: variables importance (sorted)modelchoice_out.predictions
: votes, prediction and posterior error ratemodelchoice_out.confusion
: OOB Confusion matrix of the classifier
Parameter Estimation
Composite parameters
When specifying the parameter (option --parameter
), one may specify
simple composite parameters as division, addition or multiplication of
two existing parameters. like t/N
or T1+T2
.
A note about PLS heuristic
The --plsmaxvar
option (defaulting at 0.90) fixes the number of
selected pls axes so that we get at least the specified percentage of
maximum explained variance of the output. The explained variance of the
output of the
first
axes is defined by the R-squared of the output:
where is the output scored by the pls for the th component. So, only the first axis are kept, and :
Note that if you specify 0 as --plsmaxvar
, an “elbow” heuristic is
activiated where the following condition is tested for every computed
axis :
If this condition is true for a windows of previous axes, sized to 10% of the total possible axis, then we stop the PLS axis computation.
In practice, we find this close enough to the previous for 99%, but it isn’t guaranteed.
The signification of the noob
parameter
The median global/local statistics and confidence intervals (global)
measures for parameter estimation need a number of OOB samples
(--noob
) to be reliable (typlially 30% of the size of the dataset is
sufficient). Be aware than computing the whole set (i.e. assigning
--noob
the same than for --nref
) for weights predictions (Raynal et
al. 2018) could be very costly, memory and
cpu-wise, if your dataset is large in number of samples, so it could be
adviseable to compute them for only choose a subset of size noob
.
Example (parameter estimation)
Example (working with the dataset in test/data
) :
abcranger -t 1000 -j 8 --parameter ra --chosenscen 1 --noob 50
Header, reftable and statobs files should be in the current directory.
Generated files (parameter estimation)
Five files (or seven if pls activated) are created :
estimparam_out.ooberror
: OOB MSE rate vs number of trees (line number is the number of trees)estimparam_out.importance
: variables importance (sorted)estimparam_out.predictions
: expectation, variance and 0.05, 0.5, 0.95 quantile for predictionestimparam_out.predweights
: csv of the value/weights pairs of the prediction (for density plot)estimparam_out.oobstats
: various statistics on oob (MSE, NMSE, NMAE etc.)
if pls enabled :
estimparam_out.plsvar
: variance explained by number of componentsestimparam_out.plsweights
: variable weight in the first component (sorted by absolute value)
Various
Partial Least Squares algorithm
- For
:
- Normalize to
Comment When there isn’t any missing data, stages and could be replaced by and by
To get so that we compute :
where where
TODO
Input/Output
- Integrate hdf5 (or exdir? msgpack?) routines to save/load reftables/observed stats with associated metadata
- Provide R code to save/load the data
- Provide Python code to save/load the data
C++ standalone
- Merge the two methodologies in a single executable with the (almost) the same options
- (Optional) Possibly move to another options parser (CLI?)
External interfaces
- R package
- Python package
Documentation
- Code documentation
- Document the build
Continuous integration
- Linux CI build with intel/MKL optimizations
- osX CI build
- Windows CI build
Long/Mid term TODO
- methodologies parameters auto-tuning
- auto-discovering the optimal number of trees by monitoring OOB error
- auto-limiting number of threads by available memory
- Streamline the two methodologies (model choice and then parameters estimation)
- Write our own tree/rf implementation with better storage efficiency than ranger
- Make functional tests for the two methodologies
- Possible to use mondrian forests for online batches ? See (Lakshminarayanan, Roy, and Teh 2014)
References
This have been the subject of a proceedings in JOBIM 2020, PDF and video (in french), (Collin et al. 2020).
Collin, François-David, Ghislain Durif, Louis Raynal, Eric Lombaert, Mathieu Gautier, Renaud Vitalis, Jean-Michel Marin, and Arnaud Estoup. 2021. “Extending Approximate Bayesian Computation with Supervised Machine Learning to Infer Demographic History from Genetic Polymorphisms Using DIYABC Random Forest.” Molecular Ecology Resources 21 (8): 2598–2613. https://doi.org/https://doi.org/10.1111/1755-0998.13413.
Collin, François-David, Arnaud Estoup, Jean-Michel Marin, and Louis Raynal. 2020. “Bringing ABC inference to the machine learning realm : AbcRanger, an optimized random forests library for ABC.” In JOBIM 2020, 2020:66. JOBIM. Montpellier, France. https://hal.archives-ouvertes.fr/hal-02910067.
Friedman, Jerome, Trevor Hastie, and Robert Tibshirani. 2001. The Elements of Statistical Learning. Vol. 1. 10. Springer series in statistics New York, NY, USA:
Guennebaud, Gaël, Benoît Jacob, et al. 2010. “Eigen V3.” http://eigen.tuxfamily.org.
Lakshminarayanan, Balaji, Daniel M Roy, and Yee Whye Teh. 2014. “Mondrian Forests: Efficient Online Random Forests.” In Advances in Neural Information Processing Systems, 3140–48.
Lintusaari, Jarno, Henri Vuollekoski, Antti Kangasrääsiö, Kusti Skytén, Marko Järvenpää, Pekka Marttinen, Michael U. Gutmann, Aki Vehtari, Jukka Corander, and Samuel Kaski. 2018. “ELFI: Engine for Likelihood-Free Inference.” Journal of Machine Learning Research 19 (16): 1–7. http://jmlr.org/papers/v19/17-374.html.
Pudlo, Pierre, Jean-Michel Marin, Arnaud Estoup, Jean-Marie Cornuet, Mathieu Gautier, and Christian P Robert. 2015. “Reliable ABC Model Choice via Random Forests.” Bioinformatics 32 (6): 859–66.
Raynal, Louis, Jean-Michel Marin, Pierre Pudlo, Mathieu Ribatet, Christian P Robert, and Arnaud Estoup. 2018. “ABC random forests for Bayesian parameter inference.” Bioinformatics 35 (10): 1720–28. https://doi.org/10.1093/bioinformatics/bty867.
Wright, Marvin N, and Andreas Ziegler. 2015. “Ranger: A Fast Implementation of Random Forests for High Dimensional Data in c++ and r.” arXiv Preprint arXiv:1508.04409.
[^1]: The term “online” there and in the code has not the usual meaning it has, as coined in “online machine learning”. We still need the entire training data set at once. Our implementation is an “online” one not by the sequential order of the input data, but by the sequential order of computation of the trees in random forests, sequentially computed and then discarded.
[^2]: We only use the C++ Core of ranger, which is under MIT License, same as ours.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file pyabcranger-0.0.62.tar.gz
.
File metadata
- Download URL: pyabcranger-0.0.62.tar.gz
- Upload date:
- Size: 56.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e9d145f60b80788aca28807bbb82a4a9736210d298cab42f4be229b56d600163 |
|
MD5 | 77e8c66017d1e8b7bf04766b168af6f7 |
|
BLAKE2b-256 | 680a15d1cb0c3933fba148699b1baedd67ff764d018778ca8dd65f3a1f09c095 |
File details
Details for the file pyabcranger-0.0.62-cp311-cp311-win_amd64.whl
.
File metadata
- Download URL: pyabcranger-0.0.62-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 613.6 kB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ace4e8829ca2318468be2fe39b9442af0f850a1c06c193df2b61b3e4ca483259 |
|
MD5 | e1536cf3845f2970a6b976820a7ac6e0 |
|
BLAKE2b-256 | 30a9e7ac08f97f20e62e8792c7003528da433050495c07aa6b175565b2070918 |
File details
Details for the file pyabcranger-0.0.62-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: pyabcranger-0.0.62-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 3.3 MB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f12d67cc9b8092aea75dd84f8ce400e13688d967fc605ec6e7c79065fffcf4ac |
|
MD5 | cb73accaf66acb0f1be142a622da9f35 |
|
BLAKE2b-256 | 44cc52b244ded811ff09cec2f61f2bd92f4b1b1d617eed8f955a22d160f3d781 |
File details
Details for the file pyabcranger-0.0.62-cp311-cp311-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: pyabcranger-0.0.62-cp311-cp311-macosx_10_9_x86_64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.11, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 209fe499e25e3260b57cc6ade7f8c992b9b70ee5c50a7987514d9e749e3c9e04 |
|
MD5 | fe79c857ab7dd2fd354bc5bd8d224009 |
|
BLAKE2b-256 | 7293a75f06ac297742c3e3375bd21d6d3ad8a3f34c154013008bd80e23da7743 |
File details
Details for the file pyabcranger-0.0.62-cp310-cp310-win_amd64.whl
.
File metadata
- Download URL: pyabcranger-0.0.62-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 613.7 kB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 68610cee09c84ea89498ab26850f113322f460a25ffa81e171c4ab8aafbaea4f |
|
MD5 | d8e6c8614a02d4798137f1132ca9732a |
|
BLAKE2b-256 | 890680d3e92d5c1285baffeba0661a572a6d8f04e900b301baec4507cad7a0e8 |
File details
Details for the file pyabcranger-0.0.62-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: pyabcranger-0.0.62-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 3.3 MB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e647b5993a6c32065ea16c68896e4ebed048eee20ef729d9cf74da16ca0e6ef3 |
|
MD5 | d92511e0587f223b2399eb41764a61a4 |
|
BLAKE2b-256 | ca319bdf10570281f07a93b3b8d12080937c1e87797b1e8a4e1c23608e72bacd |
File details
Details for the file pyabcranger-0.0.62-cp310-cp310-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: pyabcranger-0.0.62-cp310-cp310-macosx_10_9_x86_64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.10, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6732db8bcd366b7c1c1df3df53eafd93d5ad4562a1c31530203aabd022fc61ab |
|
MD5 | 47a9218119a769632671161938b122fe |
|
BLAKE2b-256 | 117bcc276ddf643bf98470f850a488ae8d01713662767a2d40e7c2ea6d2ee604 |
File details
Details for the file pyabcranger-0.0.62-cp39-cp39-win_amd64.whl
.
File metadata
- Download URL: pyabcranger-0.0.62-cp39-cp39-win_amd64.whl
- Upload date:
- Size: 612.0 kB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1806027e398bd1f264e9b51a2ec81144cd2fb14c34859d6241eb963565b3bb87 |
|
MD5 | b07837a26171bf3b68712d96b55ae661 |
|
BLAKE2b-256 | dafbe3a94ff51379bd736ddd779c2e1a9cec361c910bbaa29775bf7689341dc5 |
File details
Details for the file pyabcranger-0.0.62-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: pyabcranger-0.0.62-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 3.3 MB
- Tags: CPython 3.9, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 84a788f06458566295df96882fec23ee72dfb9ba2e2018ccd73ff162dd054044 |
|
MD5 | e3ae0efd22ff84832ca1a2bc20733766 |
|
BLAKE2b-256 | 4bf9a629273df7d74e3cec301d1fb930418569fd2853c8ae2129810a7f31da16 |
File details
Details for the file pyabcranger-0.0.62-cp39-cp39-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: pyabcranger-0.0.62-cp39-cp39-macosx_10_9_x86_64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.9, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d821c63561501d14dd0f3e75126cc3d37ed8e43d12f675786684e1aea71dca92 |
|
MD5 | 0849a7cfe00025eff711fba0c59b78e7 |
|
BLAKE2b-256 | 472384e86d2649cc409e479460ad644d77a320f3046a52b3b64d5a43230e11b2 |
File details
Details for the file pyabcranger-0.0.62-cp38-cp38-win_amd64.whl
.
File metadata
- Download URL: pyabcranger-0.0.62-cp38-cp38-win_amd64.whl
- Upload date:
- Size: 613.7 kB
- Tags: CPython 3.8, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d8d76c456fa3dbb47eb0cd3fd7b1ba01cf536b1016490a10e138405760f27d63 |
|
MD5 | 6a21e882fea146b173e2eb3aa3cefbc5 |
|
BLAKE2b-256 | 157b33cfec9595467095532872c9b7146fd0272b845281121c5deb2657b2f76b |
File details
Details for the file pyabcranger-0.0.62-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: pyabcranger-0.0.62-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 3.3 MB
- Tags: CPython 3.8, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b34caa12b1b923431784cab02de480ac7d071dd4bcb11c3da525e353291a1786 |
|
MD5 | 68fc92663b3bbbb29150cfa431b83c0e |
|
BLAKE2b-256 | 35513b96c4445fb9f4495d7f9be8810fb61c2dbf79047d37e9894b677f4dfe45 |
File details
Details for the file pyabcranger-0.0.62-cp38-cp38-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: pyabcranger-0.0.62-cp38-cp38-macosx_10_9_x86_64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.8, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7231b203f8ac3f60a588ba2b9db49a3b037e7dd8818ea3114b7e93c1f9352bb7 |
|
MD5 | 59ad0230f82426d019ca1b13b0e16ac1 |
|
BLAKE2b-256 | ddfad2b36f95c3740e3d3bcefc90fe1c50f5906d04c48a80ca21844e0002205f |
File details
Details for the file pyabcranger-0.0.62-cp37-cp37m-win_amd64.whl
.
File metadata
- Download URL: pyabcranger-0.0.62-cp37-cp37m-win_amd64.whl
- Upload date:
- Size: 614.2 kB
- Tags: CPython 3.7m, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ae7f6c8c245065501bf27484798680909186608216e00849d07d7d0f2a80e8b3 |
|
MD5 | b666fc68cb842499acf62e43de54e3e5 |
|
BLAKE2b-256 | 8ef222a257a1d416c138d30030468250e3c95364dd890d1f65ff0ebed8e16f28 |
File details
Details for the file pyabcranger-0.0.62-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: pyabcranger-0.0.62-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 3.3 MB
- Tags: CPython 3.7m, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a9c6667098f26a2d0f217204fe06f056faa6765e870641d87a6e52fbe6e650d4 |
|
MD5 | 595fe603b5cc0280f088f2dd2dba81c9 |
|
BLAKE2b-256 | 60008c09c61572785b0d6933861ca8ef19e51854c7d56e3910430a916e786f8b |
File details
Details for the file pyabcranger-0.0.62-cp37-cp37m-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: pyabcranger-0.0.62-cp37-cp37m-macosx_10_9_x86_64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.7m, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 76f2d1cc91f59a89d868b996fd2cdb4f1e630819394d5ff6cf573de107beca6d |
|
MD5 | 9b28172b58243740511cc3a01e6b89f6 |
|
BLAKE2b-256 | b0f30ab79b1baad2297215ffd4b6bddb251df9fa7c684a2202978115e22ea318 |