Bayesian Linear Regression with Hamiltonian Monte Carlo (HMC)
This repository contains code for performing Bayesian Linear Regression using Hamiltonian Monte Carlo (HMC) sampling. Bayesian Linear Regression is a probabilistic approach to regression modeling that provides uncertainty estimates for the model parameters. HMC is a Markov Chain Monte Carlo (MCMC) method that uses Hamiltonian dynamics to generate samples from the posterior distribution.
Overview
Bayesian Linear Regression with HMC combines the flexibility of Bayesian modeling with the efficiency of HMC sampling to estimate the posterior distribution of regression coefficients. This allows for principled uncertainty quantification and robust inference in regression tasks.
How to Use
To use Bayesian Linear Regression with HMC, follow these steps:
-
Prepare Your Data: Ensure your input features
Xand target variableyare in the appropriate format.Xshould be a 2D numpy array where each row represents a sample and each column represents a feature.yshould be a 1D numpy array containing the corresponding target values. -
Instantiate the Model: Create an instance of the
BayesianLinearRegressionclass. -
Perform Regression: Call the
hamiltonian_monte_carlomethod of the model instance, passing your data and desired parameters such as the number of samples (num_samples) and leapfrog steps (L). -
Analyze Results: Analyze the posterior samples obtained from the regression to make predictions, compute metrics, and assess uncertainty.
Theoretical Details
-
Bayesian Linear Regression: Bayesian Linear Regression is a probabilistic approach to regression modeling that treats the regression coefficients as random variables and estimates their posterior distribution using Bayes' theorem.
-
Hamiltonian Monte Carlo (HMC): HMC is a Markov Chain Monte Carlo (MCMC) method that simulates Hamiltonian dynamics to sample from complex probability distributions. It employs a "Hamiltonian" function that combines the potential energy (negative log-posterior) and kinetic energy to guide the exploration of the parameter space.
Requirements
- Python 3.x
- NumPy
- SciPy
References
- Neal, R. M. (2011). MCMC using Hamiltonian dynamics. Handbook of Markov Chain Monte Carlo, 2(11), 2.
- Gelman, A., Carlin, J. B., Stern, H. S., Dunson, D. B., Vehtari, A., & Rubin, D. B. (2013). Bayesian Data Analysis (3rd ed.). Chapman and Hall/CRC.
License
This project is licensed under the MIT License - see the LICENSE.md file for details.
Metadata
Release files for cortexflow 2.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| cortexflow-2.0.1.tar.gz | 3.6 kB | Without provenance | Details |
Release files / cortexflow-2.0.1.tar.gz
| Download URL | cortexflow-2.0.1.tar.gz |
|---|---|
| Size | 3.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b33563796539b3015f1e9f3e93637ad31315db0d9266921fc1b50dfd5223cac4
|
|
BLAKE2b-256 checksum How to use checksums |
c5fd2afc4ca0a301d9a6a4b96f091a9e230be3a81e434c7c22cc422087693021
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.12
|
Security for cortexflow 2.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.