tensorflow / tensorflow/probability

Bayesian MCMC model and Bayesian regression analysis model

Open
#1,819 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Jupyter Notebook
Stars
4.4k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

I wonder the difference between Bayesian MCMC model and Bayesian regression analysis model.
The tensorflow_probability library is being used. The code has been imported from Excel into the target value and various related values, and we are creating a model that predicts the target value only with related values and sets residuals when comparing actual data and predicted values to examine errors.

  • The libraries used in this process are.

import tensorflow as tf
import tensorflow_probability as tfp
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

tfd = tfp.distributions
tfb = tfp.bijectors

  • Defining the reliability (pre-probability) of the true value
    sensor_accuracy = 0.90
    prior_loc = tf.cast(actual_value, dtype=tf.float32)
    prior_scale = tf.cast((1 - sensor_accuracy) * actual_value, dtype=tf.float32)

  • After defining the model

joint = tfd.JointDistributionCoroutine(model)
num_results = 10000
num_burnin_steps = 500

def target_log_prob_fn(predicted_value):
return joint.log_prob(predicted_value, n)

initial_state = [tf.constant(actual_value, dtype=tf.float32)]

hmc = tfp.mcmc.HamiltonianMonteCarlo(
target_log_prob_fn=target_log_prob_fn,
num_leapfrog_steps=20,
step_size=0.01)

@tf.function
def run_chain():
return tfp.mcmc.sample_chain(
num_results=num_results,
num_burnin_steps=num_burnin_steps,
current_state=initial_state,
kernel=hmc,
trace_fn=lambda current_state, kernel_results: kernel_results)

samples, kernel_results = run_chain()

I started coding for the first time, so I got advice from people around me, and also used chat gpt to construct the code. As a result, I am asking a question because I do not understand clearly whether the concept that made up this model is Bayesian MCMC or Bayesian regression analysis due to the lack of understanding of the code overall.
Thank you for reading. Please give me a lot of advice.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No repository file, test, or entry point is identified. Start with the posted TensorFlow Probability model, especially JointDistributionCoroutine and sample_chain, and clarify whether the issue needs conceptual documentation or a runnable example. Done would require a clearly scoped documentation change that explains the relationship between the two concepts.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
machine-learning
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
15/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.