---

title: MovieLens Dataset


keywords: fastai
sidebar: home_sidebar

summary: "Implementation of MovieLens datasets."
description: "Implementation of MovieLens datasets."
nb_path: "nbs/datasets/movielens.ipynb"
---
<!--

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

    {% 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="ML1MDataset" class="doc_header"><code>class</code> <code>ML1MDataset</code><a href="https://github.com/RecoHut-Projects/recohut/tree/master/recohut/datasets/movielens.py#L31" class="source_link" style="float:right">[source]</a></h2><blockquote><p><code>ML1MDataset</code>(<strong><code>args</code></strong>)</p>
</blockquote>

</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">class</span> <span class="nc">Args</span><span class="p">:</span>
    <span class="n">min_rating</span> <span class="o">=</span> <span class="mi">0</span>
    <span class="n">min_uc</span> <span class="o">=</span> <span class="mi">5</span>
    <span class="n">min_sc</span> <span class="o">=</span> <span class="mi">5</span>
    <span class="n">split</span> <span class="o">=</span> <span class="s1">&#39;leave_one_out&#39;</span>
    <span class="n">data_raw_path</span> <span class="o">=</span> <span class="s1">&#39;data/bronze&#39;</span>
    <span class="n">data_save_path</span> <span class="o">=</span> <span class="s1">&#39;data/silver&#39;</span>

<span class="n">args</span> <span class="o">=</span> <span class="n">Args</span><span class="p">()</span>

<span class="n">os</span><span class="o">.</span><span class="n">makedirs</span><span class="p">(</span><span class="n">args</span><span class="o">.</span><span class="n">data_raw_path</span><span class="p">,</span> <span class="n">exist_ok</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="n">os</span><span class="o">.</span><span class="n">makedirs</span><span class="p">(</span><span class="n">args</span><span class="o">.</span><span class="n">data_save_path</span><span class="p">,</span> <span class="n">exist_ok</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>

<span class="n">dataset</span> <span class="o">=</span> <span class="n">ML1MDataset</span><span class="p">(</span><span class="n">args</span><span class="p">)</span>
<span class="n">dataset</span><span class="o">.</span><span class="n">preprocess</span><span class="p">()</span>
</pre></div>

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

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

<div class="output_area">

<div class="output_subarea output_stream output_stdout output_text">
<pre>Raw file doesn&#39;t exist. Downloading...

Turning into implicit ratings
Filtering triplets
Densifying index
Splitting
</pre>
</div>
</div>

<div class="output_area">

<div class="output_subarea output_stream output_stderr output_text">
<pre>100%|██████████| 6040/6040 [00:02&lt;00:00, 2707.83it/s]
</pre>
</div>
</div>

</div>
</div>

</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>tree --du -h -C ./data
</pre></div>

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

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

<div class="output_area">

<div class="output_subarea output_stream output_stdout output_text">
<pre><span class="ansi-blue-intense-fg ansi-bold">./data</span>
├── [ 24M]  <span class="ansi-blue-intense-fg ansi-bold">bronze</span>
│   └── [ 24M]  <span class="ansi-blue-intense-fg ansi-bold">ml-1m</span>
│       ├── [167K]  movies.dat
│       ├── [ 23M]  ratings.dat
│       ├── [5.4K]  README
│       └── [131K]  users.dat
└── [3.0M]  <span class="ansi-blue-intense-fg ansi-bold">silver</span>
    └── [3.0M]  <span class="ansi-blue-intense-fg ansi-bold">ml-1m_min_rating0-min_uc5-min_sc5-splitleave_one_out</span>
        └── [3.0M]  dataset.pkl

  27M used in 4 directories, 5 files
</pre>
</div>
</div>

</div>
</div>

</div>
    {% endraw %}

</div>
 

