Skip to main content

Fits Linear and Logistic Regression Models using MCMC.

Project description

# BayesianLinearRegression

This project was for me to gain a better understanding of the Metropolis-Hastings algorithm and work on my object-oriented programming skills. If you need to do any Bayesian modeling in Python, I recommend using PyMC3 (https://docs.pymc.io/).

#### – Project Status: [Completed]

## Project Intro/Objective

The purpose of this project was for me to work with the Metropolis-Hastings algorithm and get comfortable with object-oriented programming.

### Methods Used

  • Generalized Linear Models

  • Bayesian Statistics

  • Metropolis-Hastings Markov Chain Monte Carlo

  • Object-Oriented Programming

### Technologies

  • Python (NumPy, SciPy, tqdm)

## Project Description

I created a class called MetropolisHastingsLinearModel, which is the parent class of the GaussianModel, LaplacianModel, and LogisticModel classes. It has methods to calculate the log-prior (assuming normal priors for the distributions of the coefficients in the model), the log-posterior, fit the model/simulate the posteriors of the coefficients, burn the first x% the simulated distribution, set credible intervals, and predict for new data. For the GaussianModel and LaplacianModel classes, I only needed to add a log-likelihood method corresponding to those distributions. For the LogisticModel class, I added a method implementing the inverse-logit transformation for use in calculating the log-likelihood of the coefficients given the data and for predicting the probabilities of new observations. In addition to the method for predicting probabilities, I implemented a method for predicting the classes of new observations.

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

BayesianLinearRegression-0.1.2.tar.gz (6.1 kB view details)

Uploaded Source

File details

Details for the file BayesianLinearRegression-0.1.2.tar.gz.

File metadata

  • Download URL: BayesianLinearRegression-0.1.2.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.20.1 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.6.5

File hashes

Hashes for BayesianLinearRegression-0.1.2.tar.gz
Algorithm Hash digest
SHA256 687084713cad48a0ccca4f644a48fb1250bfc8a22499c1c376df4b1f0841d3e4
MD5 83f22f1e854936f7630131074c7036e9
BLAKE2b-256 95b97e4eed62ddca5530dc2412cd2afb44dc4e1e65b6c8f4b2dec1e56ca63215

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page