Path: blob/master/notebooks/book2/15/logreg_iris_bayes_2d.ipynb
1193 views
Kernel: Python 3.7.13 ('py3713')
Bayesian Binary logistic regression in 2d for iris flowers
Code is based on: https://github.com/aloctavodia/BAP/blob/master/code/Chp4/04_Generalizing_linear_models.ipynb
author: @karm-patel
In [78]:
In [79]:
Out[79]:
/home/patel_karm/sendbox/probml-utils/probml_utils/plotting.py:26: UserWarning: LATEXIFY environment variable not set, not latexifying
warnings.warn("LATEXIFY environment variable not set, not latexifying")
In [80]:
Out[80]:
Balanced Dataset
In [81]:
Out[81]:
In [82]:
Out[82]:
(50, 2)
In [83]:
Out[83]:
array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1], dtype=int8)
In [84]:
In [85]:
In [86]:
In [87]:
In [88]:
Out[88]:
CPU times: user 8.38 s, sys: 115 ms, total: 8.49 s
Wall time: 8.42 s
In [89]:
Out[89]:
In [90]:
Out[90]:
In [91]:
In [92]:
Out[92]:
(50, 3600)
In [93]:
Out[93]:
/home/patel_karm/arviz/arviz/plots/hdiplot.py:157: FutureWarning: hdi currently interprets 2d data as (draw, shape) but this will change in a future release to (chain, draw) for coherence with other functions
hdi_data = hdi(y, hdi_prob=hdi_prob, circular=circular, multimodal=False, **hdi_kwargs)
/home/patel_karm/sendbox/probml-utils/probml_utils/plotting.py:80: UserWarning: set FIG_DIR environment variable to save figures
warnings.warn("set FIG_DIR environment variable to save figures")
Unbalanced Dataset
Now we will use unbalanced dataset where we have only 5 samples of setosa and 45 samples of versicolor
In [94]:
Out[94]:
In [95]:
Out[95]:
(50, 2)
In [96]:
Out[96]:
array([0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1], dtype=int8)
In [105]:
In [106]:
In [107]:
Out[107]:
CPU times: user 8.7 s, sys: 103 ms, total: 8.8 s
Wall time: 8.73 s
In [108]:
Out[108]:
In [109]:
Out[109]:
In [110]:
In [111]:
Out[111]:
(50, 3600)
In [112]:
Out[112]:
/home/patel_karm/arviz/arviz/plots/hdiplot.py:157: FutureWarning: hdi currently interprets 2d data as (draw, shape) but this will change in a future release to (chain, draw) for coherence with other functions
hdi_data = hdi(y, hdi_prob=hdi_prob, circular=circular, multimodal=False, **hdi_kwargs)
/home/patel_karm/sendbox/probml-utils/probml_utils/plotting.py:80: UserWarning: set FIG_DIR environment variable to save figures
warnings.warn("set FIG_DIR environment variable to save figures")
In [ ]: