Bayesian Neural Networks methods for radiocarbon (14C) calibration
Project description
Bayesian Neural Network For Radiocarbon Calibration
Welcome to the GitHub repository of the bnn_for_14C_calibration Python library.
Overview
This library implements algorithms based on Bayesian Neural Networks (BNN) for radiocarbon (14C) calibration.
Among available functionalities, we can find : the independent calibration of a conventional radiocarbon age (individual calibration), the joint calibration of several conventional radiocarbon ages (simultaneous calibration), the independent calibration using the IntCal20 curve for comparisons with BNN methods results or the plotting of calibration results and curves.
Installation
Python version and installation
This library requires Python 3.9.13 version to work.
If you do not have Python installed on your computer, you can install the Anaconda distribution (or Miniconda for a lightweight distribution).
Once the installation is complete, open a terminal (on Linux or macOS) or Anaconda Prompt (on Windows) and create a conda environment with the required Python version (3.9.13) and pip (the Python package manager) as follows:
conda create --name myenv python=3.9.13 pip
myenv is the name of of your environment.The command above creates an environement called myenv in which it installs pip and Python 3.9.13.
To learn more about managing Python environments with conda, please visit this page.
Installing bnn_for_14C_calibration
Before installing bnn_for_14C_calibration, you need to activate your conda environment as follows:
conda activate myenv
Then, the library can be installed using pip as follows:
pip install bnn_for_14C_calibration
If you wish, you can also install jupyter-notebook in your environment (myenv) to test the library:
pip install jupyter
You can then launch the notebook using the jupyter-notebook command in the terminal and conduct your experiments there.
Quick Start
Example usage :
import bnn_for_14C_calibration as bnn
import numpy as np
######## plotting calibration curves ########
# the global BNN curve
bnn.plot_bnn_calibration_curve()
# the global BNN curve estimated using covariates
# in addition, reset extra margins
bnn.plot_bnn_calibration_curve(covariables = True, reset_margins=True)
# only a portion of the global BNN curve estimated using covariates
bnn.plot_bnn_calibration_curve(
covariables = True,
Max_x=12400,
Min_x=12200,
Max_y=260,
Min_y=180
)
# only the recent part of the BNN curve
bnn.plot_individual_calibration_curve_part_1()
# only the older part of the BNN curve
bnn.plot_individual_calibration_curve_part_2()
# IntCal20 curve
bnn.plot_IntCal20_curve(reset_margins=True)
######## individual calibration ########
# radiocarbon data
c14age = 10400
c14sig = 18
# independent calibration using BNN curve
individual_calib_results = bnn.individual_calibration(
c14age, c14sig,
sample_size=10000,
compute_calage_posterior_mean_and_std=True
)
print(individual_calib_results)
# independent calibration using the BNN curve trained with covariates
individual_calib_results_with_covariables = bnn.individual_calibration(
c14age, c14sig,
sample_size=10000,
covariables=True,
compute_calage_posterior_mean_and_std=True
)
print(individual_calib_results_with_covariables)
# independent calibration using IntCal20 curve
IntCal20_calib_results = bnn.IntCal20_calibration(
c14age, c14sig,
sample_size=10000,
compute_calage_posterior_mean_and_std=True
)
print(IntCal20_calib_results)
# plotting result for independent calibration
cm = 1/2.54 # cm in inches
figsize=(17*cm, 17*cm)
bnn.plot_calib_results(
figsize=figsize,
calibration_results=individual_calib_results
)
bnn.plot_calib_results(
figsize=figsize,
add_grid=True,
color_cal_date='green',
eps=-1,
calibration_results=individual_calib_results_with_covariables
)
# same function for plotting IntCal20 calibration results
bnn.plot_calib_results(
figsize=figsize,
calibration_results=IntCal20_calib_results
)
######## joint calibration ########
c14ages=np.array([4000, 10483])
c14sigs=np.array([10, 18])
joint_calib_results = bnn.joint_calibration(
c14ages = c14ages,
c14sigs = c14sigs,
compute_calage_posterior_mode=True,
chaine_length=10000
)
print(joint_calib_results)
######## local cache management ########
# test of cache downloading
bnn.download_cache_lib_data()
# force cache downloading
bnn.download_cache_lib_data(overwrite = True)
# clear cache
bnn.clear_cache()
Reference
Refer to the pages on Calibration functions, Plotting functions and Local cache management in the User Guide of the documentation for detailed information on the inputs, outputs, and behaviour of each function.
For internal functions and more details on the implementation of all library functions, please refer to the Developer's Guide section of the documentation.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bnn_for_14c_calibration-0.2.0.tar.gz.
File metadata
- Download URL: bnn_for_14c_calibration-0.2.0.tar.gz
- Upload date:
- Size: 379.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d7bdbd8eccaadd3ebad22cd54cdb761f85414a00c8d6cce6f0e62ef43e86a4af
|
|
| MD5 |
12243febd15c275300c64272a814407b
|
|
| BLAKE2b-256 |
4a74d55c71a50aea988c965625eb41af8880e3424991fe9f3db34f646b7aa337
|
File details
Details for the file bnn_for_14c_calibration-0.2.0-py3-none-any.whl.
File metadata
- Download URL: bnn_for_14c_calibration-0.2.0-py3-none-any.whl
- Upload date:
- Size: 366.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b8f7132d54c725aff710733dd870c4448118ce2d1ee8bab46d1785fa13f2d092
|
|
| MD5 |
cd1d11c1c39b3f2f0f0d7620288877fa
|
|
| BLAKE2b-256 |
83ae33c411261ff9cbb50db23e68c5b72e3c922fd234c48f50a8b11efec26311
|