---

title: M3 dataset


keywords: fastai
sidebar: home_sidebar

summary: "Download the M3 dataset."
description: "Download the M3 dataset."
nb_path: "nbs/data_datasets__m3.ipynb"
---
<!--

#################################################
### THIS FILE WAS AUTOGENERATED! DO NOT EDIT! ###
#################################################
# file to edit: nbs/data_datasets__m3.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>
    {% endraw %}

<div class="cell border-box-sizing text_cell rendered"><div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<p>M3 meta information</p>

</div>
</div>
</div>
    {% 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 ">
<h2 id="Yearly" class="doc_header"><code>class</code> <code>Yearly</code><a href="https://github.com/Nixtla/nixtlats/tree/master/nixtlats/data/datasets/m3.py#L17" class="source_link" style="float:right">[source]</a></h2><blockquote><p><code>Yearly</code>(<strong><code>seasonality</code></strong>:<code>int</code>=<em><code>1</code></em>, <strong><code>horizon</code></strong>:<code>int</code>=<em><code>6</code></em>, <strong><code>freq</code></strong>:<code>str</code>=<em><code>'Y'</code></em>, <strong><code>sheet_name</code></strong>:<code>str</code>=<em><code>'M3Year'</code></em>, <strong><code>name</code></strong>:<code>str</code>=<em><code>'Yearly'</code></em>, <strong><code>n_ts</code></strong>:<code>int</code>=<em><code>645</code></em>)</p>
</blockquote>
<p>Yearly(seasonality: int = 1, horizon: int = 6, freq: str = 'Y', sheet_name: str = 'M3Year', name: str = 'Yearly', n_ts: int = 645)</p>

</div>

</div>

</div>
</div>

</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 ">
<h2 id="Quarterly" class="doc_header"><code>class</code> <code>Quarterly</code><a href="https://github.com/Nixtla/nixtlats/tree/master/nixtlats/data/datasets/m3.py#L26" class="source_link" style="float:right">[source]</a></h2><blockquote><p><code>Quarterly</code>(<strong><code>seasonality</code></strong>:<code>int</code>=<em><code>4</code></em>, <strong><code>horizon</code></strong>:<code>int</code>=<em><code>8</code></em>, <strong><code>freq</code></strong>:<code>str</code>=<em><code>'Q'</code></em>, <strong><code>sheet_name</code></strong>:<code>str</code>=<em><code>'M3Quart'</code></em>, <strong><code>name</code></strong>:<code>str</code>=<em><code>'Quarterly'</code></em>, <strong><code>n_ts</code></strong>:<code>int</code>=<em><code>756</code></em>)</p>
</blockquote>
<p>Quarterly(seasonality: int = 4, horizon: int = 8, freq: str = 'Q', sheet_name: str = 'M3Quart', name: str = 'Quarterly', n_ts: int = 756)</p>

</div>

</div>

</div>
</div>

</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 ">
<h2 id="Monthly" class="doc_header"><code>class</code> <code>Monthly</code><a href="https://github.com/Nixtla/nixtlats/tree/master/nixtlats/data/datasets/m3.py#L35" class="source_link" style="float:right">[source]</a></h2><blockquote><p><code>Monthly</code>(<strong><code>seasonality</code></strong>:<code>int</code>=<em><code>12</code></em>, <strong><code>horizon</code></strong>:<code>int</code>=<em><code>18</code></em>, <strong><code>freq</code></strong>:<code>str</code>=<em><code>'M'</code></em>, <strong><code>sheet_name</code></strong>:<code>str</code>=<em><code>'M3Month'</code></em>, <strong><code>name</code></strong>:<code>str</code>=<em><code>'Monthly'</code></em>, <strong><code>n_ts</code></strong>:<code>int</code>=<em><code>1428</code></em>)</p>
</blockquote>
<p>Monthly(seasonality: int = 12, horizon: int = 18, freq: str = 'M', sheet_name: str = 'M3Month', name: str = 'Monthly', n_ts: int = 1428)</p>

</div>

</div>

</div>
</div>

</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 ">
<h2 id="Other" class="doc_header"><code>class</code> <code>Other</code><a href="https://github.com/Nixtla/nixtlats/tree/master/nixtlats/data/datasets/m3.py#L44" class="source_link" style="float:right">[source]</a></h2><blockquote><p><code>Other</code>(<strong><code>seasonality</code></strong>:<code>int</code>=<em><code>1</code></em>, <strong><code>horizon</code></strong>:<code>int</code>=<em><code>8</code></em>, <strong><code>freq</code></strong>:<code>str</code>=<em><code>'D'</code></em>, <strong><code>sheet_name</code></strong>:<code>str</code>=<em><code>'M3Other'</code></em>, <strong><code>name</code></strong>:<code>str</code>=<em><code>'Other'</code></em>, <strong><code>n_ts</code></strong>:<code>int</code>=<em><code>174</code></em>)</p>
</blockquote>
<p>Other(seasonality: int = 1, horizon: int = 8, freq: str = 'D', sheet_name: str = 'M3Other', name: str = 'Other', n_ts: int = 174)</p>

</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>
    {% 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 ">
<h2 id="M3" class="doc_header"><code>class</code> <code>M3</code><a href="https://github.com/Nixtla/nixtlats/tree/master/nixtlats/data/datasets/m3.py#L65" class="source_link" style="float:right">[source]</a></h2><blockquote><p><code>M3</code>(<strong><code>S</code></strong>:<code>DataFrame</code>, <strong><code>X</code></strong>:<code>DataFrame</code>, <strong><code>Y</code></strong>:<code>DataFrame</code>, <strong><code>idx_categorical_static</code></strong>:<code>Optional</code>[<code>List</code>[<code>T</code>]]=<em><code>None</code></em>, <strong><code>group</code></strong>:<code>Union</code>[<code>str</code>, <code>List</code>[<code>str</code>]]=<em><code>None</code></em>) :: <a href="/nixtlats/data_datasets__utils.html#TimeSeriesDataclass"><code>TimeSeriesDataclass</code></a></p>
</blockquote>
<p>M3(S: pandas.core.frame.DataFrame, X: pandas.core.frame.DataFrame, Y: pandas.core.frame.DataFrame, idx_categorical_static: Union[List, NoneType] = None, group: Union[str, List[str]] = None)</p>

</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="input">

<div class="inner_cell">
    <div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="k">for</span> <span class="n">group</span><span class="p">,</span> <span class="n">meta</span> <span class="ow">in</span> <span class="n">M3Info</span><span class="p">:</span>
    <span class="n">data</span><span class="p">,</span> <span class="o">*</span><span class="n">_</span> <span class="o">=</span> <span class="n">M3</span><span class="o">.</span><span class="n">load</span><span class="p">(</span><span class="n">directory</span><span class="o">=</span><span class="s1">&#39;data&#39;</span><span class="p">,</span> <span class="n">group</span><span class="o">=</span><span class="n">group</span><span class="p">)</span>
    <span class="n">unique_elements</span> <span class="o">=</span> <span class="n">data</span><span class="o">.</span><span class="n">groupby</span><span class="p">([</span><span class="s1">&#39;unique_id&#39;</span><span class="p">,</span> <span class="s1">&#39;ds&#39;</span><span class="p">])</span><span class="o">.</span><span class="n">size</span><span class="p">()</span>
    <span class="n">unique_ts</span> <span class="o">=</span> <span class="n">data</span><span class="o">.</span><span class="n">groupby</span><span class="p">(</span><span class="s1">&#39;unique_id&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">size</span><span class="p">()</span>

    <span class="k">assert</span> <span class="p">(</span><span class="n">unique_elements</span> <span class="o">!=</span> <span class="mi">1</span><span class="p">)</span><span class="o">.</span><span class="n">sum</span><span class="p">()</span> <span class="o">==</span> <span class="mi">0</span><span class="p">,</span> <span class="sa">f</span><span class="s1">&#39;Duplicated records found: </span><span class="si">{</span><span class="n">group</span><span class="si">}</span><span class="s1">&#39;</span>
    <span class="k">assert</span> <span class="n">unique_ts</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="n">meta</span><span class="o">.</span><span class="n">n_ts</span><span class="p">,</span> <span class="sa">f</span><span class="s1">&#39;Number of time series not match: </span><span class="si">{</span><span class="n">group</span><span class="si">}</span><span class="s1">&#39;</span>
</pre></div>

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

</div>
    {% endraw %}

</div>
 

