# Bayesian linear regression

**URL:** <https://discourse.pymc.io/t/bayesian-linear-regression/4048>\
**Category:** Questions\
**Created:** [October 30, 2019, 12:30pm UTC](https://discourse.pymc.io/t/bayesian-linear-regression/4048 "2019-10-30T12:30:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![monika](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/monika/32/2278_2.png) [@monika](https://discourse.pymc.io/u/monika)\
**Post date:** [October 30, 2019, 12:30pm UTC](https://discourse.pymc.io/t/bayesian-linear-regression/4048/1 "2019-10-30T12:30:09Z")

</div>

I have built a bayesian linear regression model using pymc3. On evalation, I found that the MAPE results (mean absolute percentage error) on training set is more the test set. what can be the reason for this as the same variable means are used for test set?

---

<div class="post-metadata">

**Author:** ![Mind-The-Data](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/mind-the-data/32/2241_2.png) [@Mind-The-Data](https://discourse.pymc.io/u/Mind-The-Data)\
**Post date:** [October 30, 2019, 5:11pm UTC](https://discourse.pymc.io/t/bayesian-linear-regression/4048/2 "2019-10-30T17:11:35Z")

</div>

This is hard to answer without more information. Have you tried other error metrics like RMSE, that aren’t scaled as a percentage? Have you tried randomly selecting a new training/test split? If n is small you might of just got lucky and happened to have a test set that was predicted well by the linear model. This isn’t impossible in theory, just unlucky as n --\> larger. If n is large and RMSE also shows better results on training and test and a new random test/training split it might just be model misspecification.

---

<div class="post-metadata">

**Author:** ![monika](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/monika/32/2278_2.png) [@monika](https://discourse.pymc.io/u/monika)\
**Post date:** [October 31, 2019, 6:12am UTC](https://discourse.pymc.io/t/bayesian-linear-regression/4048/3 "2019-10-31T06:12:43Z")

</div>

Thanks. I checked MAE\_train, MAE\_test, which are 0.0523275, 0.0571307 respectively and RMSE\_train and RMSE\_test which are 0.066204, 0.0608991 respectively. The test samples are very less, so I should do cross validation and check the results.

---

<div class="post-metadata">

**Author:** ![Mind-The-Data](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/mind-the-data/32/2241_2.png) [@Mind-The-Data](https://discourse.pymc.io/u/Mind-The-Data)\
**Post date:** [October 31, 2019, 1:11pm UTC](https://discourse.pymc.io/t/bayesian-linear-regression/4048/4 "2019-10-31T13:11:09Z")

</div>

Hmm. I would try another random splitting of train and test. And rerun the model.
