---

title: Metrics

keywords: fastai
sidebar: home_sidebar

summary: "Metrics should follow the scikit-learn pattern of accepting two arguments: "
description: "Metrics should follow the scikit-learn pattern of accepting two arguments: "
---
<!--

#################################################
### THIS FILE WAS AUTOGENERATED! DO NOT EDIT! ###
#################################################
# file to edit: notebooks/03_metrics.ipynb
# command to build the docs after a change: nbdev_build_docs

-->

<div class="container" id="notebook-container">
        
    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">

</div>
    {% endraw %}

    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">
<div class="input">

<div class="inner_cell">
    <div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="o">%</span><span class="k">load_ext</span> autoreload
<span class="o">%</span><span class="k">autoreload</span> 2
<span class="o">%</span><span class="k">matplotlib</span> inline
</pre></div>

    </div>
</div>
</div>

</div>
    {% endraw %}

    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">

</div>
    {% endraw %}

    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">

<div class="output_wrapper">
<div class="output">

<div class="output_area">


<div class="output_markdown rendered_html output_subarea ">
<h4 id="percent_positive" class="doc_header"><code>percent_positive</code><a href="https://github.com/hdmamin/incendio/tree/master/incendio/metrics.py#L7" class="source_link" style="float:right">[source]</a></h4><blockquote><p><code>percent_positive</code>(<strong><code>y_true</code></strong>, <strong><code>y_pred</code></strong>)</p>
</blockquote>

<pre><code>Compute the percent of predictions that are positive. This
can help us identify when a model is predicting all ones or zeros.</code></pre>

</div>

</div>

</div>
</div>

</div>
    {% endraw %}

    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">

</div>
    {% endraw %}

    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">

<div class="output_wrapper">
<div class="output">

<div class="output_area">


<div class="output_markdown rendered_html output_subarea ">
<h4 id="mean_soft_prediction" class="doc_header"><code>mean_soft_prediction</code><a href="https://github.com/hdmamin/incendio/tree/master/incendio/metrics.py#L15" class="source_link" style="float:right">[source]</a></h4><blockquote><p><code>mean_soft_prediction</code>(<strong><code>y_true</code></strong>, <strong><code>y_score</code></strong>)</p>
</blockquote>

<pre><code>Compute the mean predicted probability.</code></pre>

</div>

</div>

</div>
</div>

</div>
    {% endraw %}

    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">

</div>
    {% endraw %}

    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">

<div class="output_wrapper">
<div class="output">

<div class="output_area">


<div class="output_markdown rendered_html output_subarea ">
<h4 id="std_soft_prediction" class="doc_header"><code>std_soft_prediction</code><a href="https://github.com/hdmamin/incendio/tree/master/incendio/metrics.py#L21" class="source_link" style="float:right">[source]</a></h4><blockquote><p><code>std_soft_prediction</code>(<strong><code>y_true</code></strong>, <strong><code>y_score</code></strong>)</p>
</blockquote>

<pre><code>Compute the standard deviation of the predicted
probabilities. This helps us identify if the model is
always predicting roughly the same probability.</code></pre>

</div>

</div>

</div>
</div>

</div>
    {% endraw %}

    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">

</div>
    {% endraw %}

    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">

<div class="output_wrapper">
<div class="output">

<div class="output_area">


<div class="output_markdown rendered_html output_subarea ">
<h4 id="batch_size" class="doc_header"><code>batch_size</code><a href="https://github.com/hdmamin/incendio/tree/master/incendio/metrics.py#L30" class="source_link" style="float:right">[source]</a></h4><blockquote><p><code>batch_size</code>(<strong><code>y_true</code></strong>, <strong><code>y_pred</code></strong>)</p>
</blockquote>

<pre><code>Count the number of items in the current batch.</code></pre>

</div>

</div>

</div>
</div>

</div>
    {% endraw %}

</div>
 

