x = np.argwhere((y == y_i) == b)
    ct = x[idx[:, 0]].sum(0) + 1
    tot = ((y == y_i) == b).sum() + 1
    return ct / tot</code></pre>
</details>
</dd>
<dt id="ktrain.text.models.calc_r"><code class="name flex">
<span>def <span class="ident">calc_r</span></span>(<span>y_i, x, y)</span>
</code></dt>
<dd>
<div class="desc"></div>
<details class="source">
<summary>
<span>Expand source code</span>
</summary>
<pre><code class="python">def calc_r(y_i, x, y):
    return np.log(calc_pr(y_i, x, y, True) / calc_pr(