# Dealing with Unbalanced Data with Minibatches

**URL:** <https://discourse.pymc.io/t/dealing-with-unbalanced-data-with-minibatches/1309>\
**Category:** Questions\
**Created:** [June 1, 2018, 8:37am UTC](https://discourse.pymc.io/t/dealing-with-unbalanced-data-with-minibatches/1309 "2018-06-01T08:37:25Z")\
**Posts on this page:** 1\
**Showing post:** 17

<div class="post-metadata">

**Author:** ![tomkov](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/tomkov/32/2300_2.png) [@tomkov](https://discourse.pymc.io/u/tomkov)\
**Post date:** [February 4, 2020, 1:41pm UTC](https://discourse.pymc.io/t/dealing-with-unbalanced-data-with-minibatches/1309/17 "2020-02-04T13:41:44Z")

</div>

I found something that looks like class weighting here:

> [@How to model/deal with weighted binary outcomes](https://discourse.pymc.io/t/how-to-model-deal-with-weighted-binary-outcomes/1274/10):
>
> Updated solution after this topic [How to perform weighted inference](https://discourse.pymc.io/t/how-to-perform-weighted-inference/1825/5) import numpy as np import pymc3 as pm import theano.tensor as T N = 1000 P = 0.2 data = np.zeros(N) data[:int(N \* P)] = 1.0 weights = np.ones(N) weights[:int(N \* P)] = 4.0 with pm.Model() as model: p\_ = pm.Normal('p\_', mu=0.0, sd=1000.0) p = pm.Deterministic('p', pm.math.invlogit(p\_)) pm.Potential('weights', weights \* pm.Bernoulli.dist(p=p).logp(dat…

I’m still testing it.

---

_[View the full topic](https://discourse.pymc.io/t/dealing-with-unbalanced-data-with-minibatches/1309)._
