---

title: Visualizations Basic Plots


keywords: fastai
sidebar: home_sidebar

summary: "Common utilities for visualizing/plotting recsys data and patterns."
description: "Common utilities for visualizing/plotting recsys data and patterns."
nb_path: "nbs/visualization/basic_plots.ipynb"
---
<!--

#################################################
### THIS FILE WAS AUTOGENERATED! DO NOT EDIT! ###
#################################################
# file to edit: nbs/visualization/basic_plots.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="Visual" class="doc_header"><code>class</code> <code>Visual</code><a href="https://github.com/RecoHut-Projects/recohut/tree/master/recohut/visualization/basic_plots.py#L14" class="source_link" style="float:right">[source]</a></h2><blockquote><p><code>Visual</code>()</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="output_wrapper">
<div class="output">

<div class="output_area">


<div class="output_markdown rendered_html output_subarea ">
<h2 id="BasicVisual" class="doc_header"><code>class</code> <code>BasicVisual</code><a href="https://github.com/RecoHut-Projects/recohut/tree/master/recohut/visualization/basic_plots.py#L19" class="source_link" style="float:right">[source]</a></h2><blockquote><p><code>BasicVisual</code>(<strong><code>figsize</code></strong>=<em><code>(10, 10)</code></em>, <strong><code>show</code></strong>=<em><code>True</code></em>, <strong><code>save</code></strong>=<em><code>False</code></em>, <strong><code>pallete</code></strong>=<em><code>'viridis'</code></em>, <strong><code>style</code></strong>=<em><code>'whitegrid'</code></em>, <strong><code>rot</code></strong>=<em><code>45</code></em>, <strong><code>label_x</code></strong>=<em><code>'label_x'</code></em>, <strong><code>label_y</code></strong>=<em><code>'label_y'</code></em>, <strong><code>title</code></strong>=<em><code>'Basic Plot'</code></em>, <strong><code>nrows</code></strong>=<em><code>1</code></em>, <strong><code>ncols</code></strong>=<em><code>1</code></em>) :: <a href="/recohut/basic_plots.html#Visual"><code>Visual</code></a></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="output_wrapper">
<div class="output">

<div class="output_area">


<div class="output_markdown rendered_html output_subarea ">
<h2 id="CountPlot" class="doc_header"><code>class</code> <code>CountPlot</code><a href="https://github.com/RecoHut-Projects/recohut/tree/master/recohut/visualization/basic_plots.py#L56" class="source_link" style="float:right">[source]</a></h2><blockquote><p><code>CountPlot</code>(<strong><code>data_x</code></strong>, <strong><code>data_y</code></strong>, <strong><code>add_pct</code></strong>=<em><code>True</code></em>, <strong>**<code>kwargs</code></strong>) :: <a href="/recohut/basic_plots.html#BasicVisual"><code>BasicVisual</code></a></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="n">df</span> <span class="o">=</span> <span class="n">pd</span><span class="o">.</span><span class="n">DataFrame</span><span class="o">.</span><span class="n">from_dict</span><span class="p">({</span>
    <span class="s1">&#39;genres&#39;</span><span class="p">:[</span><span class="s1">&#39;Drama&#39;</span><span class="p">,</span><span class="s1">&#39;Comedy&#39;</span><span class="p">],</span>
    <span class="s1">&#39;count&#39;</span><span class="p">:[</span><span class="mi">40</span><span class="p">,</span><span class="mi">20</span><span class="p">],</span>
<span class="p">})</span>

<span class="n">kwargs</span> <span class="o">=</span> <span class="p">{</span><span class="s1">&#39;label_x&#39;</span><span class="p">:</span><span class="s1">&#39;genres&#39;</span><span class="p">,</span> <span class="s1">&#39;label_y&#39;</span><span class="p">:</span><span class="s1">&#39;count of genre&#39;</span><span class="p">,</span> <span class="s1">&#39;figsize&#39;</span><span class="p">:(</span><span class="mi">7</span><span class="p">,</span><span class="mi">4</span><span class="p">)}</span>

<span class="n">cp</span> <span class="o">=</span> <span class="n">CountPlot</span><span class="p">(</span><span class="n">data_x</span> <span class="o">=</span> <span class="n">df</span><span class="o">.</span><span class="n">genres</span><span class="o">.</span><span class="n">values</span><span class="p">,</span>
               <span class="n">data_y</span> <span class="o">=</span> <span class="n">df</span><span class="p">[</span><span class="s1">&#39;count&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">values</span><span class="p">,</span>
               <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>

<span class="n">cp</span><span class="o">.</span><span class="n">plot</span><span class="p">()</span>
</pre></div>

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

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

<div class="output_area">



<div class="output_png output_subarea ">
<img src="data:image/png;base64,[encoded data, 14908 characters]
"
>
</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="LongTailPlot" class="doc_header"><code>class</code> <code>LongTailPlot</code><a href="https://github.com/RecoHut-Projects/recohut/tree/master/recohut/visualization/basic_plots.py#L80" class="source_link" style="float:right">[source]</a></h2><blockquote><p><code>LongTailPlot</code>(<strong><code>item_ids</code></strong>, <strong><code>user_ids</code></strong>, <strong>**<code>kwargs</code></strong>) :: <a href="/recohut/basic_plots.html#BasicVisual"><code>BasicVisual</code></a></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="n">df</span> <span class="o">=</span> <span class="n">pd</span><span class="o">.</span><span class="n">DataFrame</span><span class="o">.</span><span class="n">from_dict</span><span class="p">({</span>
    <span class="s1">&#39;item_id&#39;</span><span class="p">:[</span><span class="mi">1</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">,</span><span class="mi">4</span><span class="p">,</span><span class="mi">4</span><span class="p">],</span>
    <span class="s1">&#39;user_id&#39;</span><span class="p">:[</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">,</span><span class="mi">3</span><span class="p">,</span><span class="mi">4</span><span class="p">,</span><span class="mi">4</span><span class="p">,</span><span class="mi">4</span><span class="p">],</span>
<span class="p">})</span>

<span class="n">kwargs</span> <span class="o">=</span> <span class="p">{</span><span class="s1">&#39;figsize&#39;</span><span class="p">:(</span><span class="mi">14</span><span class="p">,</span><span class="mi">5</span><span class="p">)}</span>

<span class="n">LongTailPlot</span><span class="p">(</span><span class="n">item_ids</span><span class="o">=</span><span class="n">df</span><span class="o">.</span><span class="n">item_id</span><span class="o">.</span><span class="n">values</span><span class="p">,</span> <span class="n">user_ids</span><span class="o">=</span><span class="n">df</span><span class="o">.</span><span class="n">user_id</span><span class="o">.</span><span class="n">values</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
</pre></div>

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

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

<div class="output_area">



<div class="output_png output_subarea ">
<img src="data:image/png;base64,[encoded data, 28820 characters]
"
>
</div>

</div>

<div class="output_area">



<div class="output_text output_subarea output_execute_result">
<pre>&lt;__main__.LongTailPlot at 0x7f20c9976f10&gt;</pre>
</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="LongTailPlotv2" class="doc_header"><code>class</code> <code>LongTailPlotv2</code><a href="https://github.com/RecoHut-Projects/recohut/tree/master/recohut/visualization/basic_plots.py#L103" class="source_link" style="float:right">[source]</a></h2><blockquote><p><code>LongTailPlotv2</code>(<strong><code>item_ids</code></strong>, <strong><code>percentage</code></strong>=<em><code>None</code></em>, <strong><code>x_labels</code></strong>=<em><code>True</code></em>, <strong>**<code>kwargs</code></strong>) :: <a href="/recohut/basic_plots.html#BasicVisual"><code>BasicVisual</code></a></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="n">item_ids</span> <span class="o">=</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">,</span><span class="mi">4</span><span class="p">,</span><span class="mi">4</span><span class="p">]</span>

<span class="n">kwargs</span> <span class="o">=</span> <span class="p">{</span><span class="s1">&#39;figsize&#39;</span><span class="p">:(</span><span class="mi">9</span><span class="p">,</span><span class="mi">5</span><span class="p">)}</span>

<span class="n">LongTailPlotv2</span><span class="p">(</span><span class="n">item_ids</span><span class="o">=</span><span class="n">df</span><span class="o">.</span><span class="n">item_id</span><span class="o">.</span><span class="n">values</span><span class="p">,</span> <span class="n">percentage</span><span class="o">=</span><span class="mf">0.5</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
</pre></div>

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

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

<div class="output_area">



<div class="output_png output_subarea ">
<img src="data:image/png;base64,[encoded data, 25060 characters]
"
>
</div>

</div>

<div class="output_area">



<div class="output_text output_subarea output_execute_result">
<pre>&lt;__main__.LongTailPlotv2 at 0x7f20bdbcb710&gt;</pre>
</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="MatrixPlot" class="doc_header"><code>class</code> <code>MatrixPlot</code><a href="https://github.com/RecoHut-Projects/recohut/tree/master/recohut/visualization/basic_plots.py#L176" class="source_link" style="float:right">[source]</a></h2><blockquote><p><code>MatrixPlot</code>(<strong><code>rating_matrix</code></strong>, <strong><code>interpolation</code></strong>=<em><code>None</code></em>, <strong><code>vmax</code></strong>=<em><code>1</code></em>, <strong><code>vmin</code></strong>=<em><code>0</code></em>, <strong>**<code>kwargs</code></strong>) :: <a href="/recohut/basic_plots.html#BasicVisual"><code>BasicVisual</code></a></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="n">rating_matrix</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">vstack</span><span class="p">((</span><span class="n">np</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">randint</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span> <span class="n">size</span><span class="o">=</span><span class="p">(</span><span class="mi">1000</span><span class="p">,</span><span class="mi">1000</span><span class="p">)),</span>
                             <span class="n">np</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">randint</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="mi">5</span><span class="p">,</span> <span class="n">size</span><span class="o">=</span><span class="p">(</span><span class="mi">500</span><span class="p">,</span><span class="mi">1000</span><span class="p">))))</span>
<span class="n">rating_matrix_binary</span> <span class="o">=</span> <span class="n">rating_matrix</span> <span class="o">&gt;</span> <span class="mi">0</span>
<span class="n">np</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">shuffle</span><span class="p">(</span><span class="n">rating_matrix_binary</span><span class="p">)</span>
<span class="n">MatrixPlot</span><span class="p">(</span><span class="n">rating_matrix_binary</span><span class="p">)</span>
</pre></div>

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

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

<div class="output_area">



<div class="output_png output_subarea ">
<img src="data:image/png;base64,[encoded data, 566444 characters]
"
>
</div>

</div>

<div class="output_area">



<div class="output_text output_subarea output_execute_result">
<pre>&lt;__main__.MatrixPlot at 0x7f20c7c594d0&gt;</pre>
</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="ConfusionMatrix" class="doc_header"><code>class</code> <code>ConfusionMatrix</code><a href="https://github.com/RecoHut-Projects/recohut/tree/master/recohut/visualization/basic_plots.py#L189" class="source_link" style="float:right">[source]</a></h2><blockquote><p><code>ConfusionMatrix</code>(<strong><code>y</code></strong>, <strong><code>yhat</code></strong>, <strong>**<code>kwargs</code></strong>) :: <a href="/recohut/basic_plots.html#BasicVisual"><code>BasicVisual</code></a></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="n">kwargs</span> <span class="o">=</span> <span class="p">{</span><span class="s1">&#39;figsize&#39;</span><span class="p">:(</span><span class="mi">5</span><span class="p">,</span><span class="mi">4</span><span class="p">)}</span>

<span class="n">ConfusionMatrix</span><span class="p">(</span><span class="n">y</span><span class="o">=</span><span class="p">[</span><span class="mi">1</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="mi">1</span><span class="p">],</span> <span class="n">yhat</span><span class="o">=</span><span class="p">[</span><span class="mi">1</span><span class="p">,</span><span class="mi">1</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">,</span><span class="mi">1</span><span class="p">],</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
</pre></div>

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

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

<div class="output_area">



<div class="output_png output_subarea ">
<img src="data:image/png;base64,[encoded data, 15368 characters]
"
>
</div>

</div>

<div class="output_area">



<div class="output_text output_subarea output_execute_result">
<pre>&lt;__main__.ConfusionMatrix at 0x7f20c659e1d0&gt;</pre>
</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="EmbeddingPlot" class="doc_header"><code>class</code> <code>EmbeddingPlot</code><a href="https://github.com/RecoHut-Projects/recohut/tree/master/recohut/visualization/basic_plots.py#L220" class="source_link" style="float:right">[source]</a></h2><blockquote><p><code>EmbeddingPlot</code>(<strong><code>vectors</code></strong>, <strong><code>labels</code></strong>=<em><code>None</code></em>, <strong>**<code>kwargs</code></strong>) :: <a href="/recohut/basic_plots.html#BasicVisual"><code>BasicVisual</code></a></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="n">kwargs</span> <span class="o">=</span> <span class="p">{</span><span class="s1">&#39;rot&#39;</span><span class="p">:</span><span class="mi">0</span><span class="p">,</span> <span class="s1">&#39;pallete&#39;</span><span class="p">:</span><span class="s1">&#39;RdBu&#39;</span><span class="p">}</span>
<span class="n">EmbeddingPlot</span><span class="p">(</span><span class="n">vectors</span><span class="o">=</span><span class="n">np</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">randint</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="n">size</span><span class="o">=</span><span class="p">(</span><span class="mi">5</span><span class="p">,</span><span class="mi">100</span><span class="p">)),</span> <span class="n">labels</span><span class="o">=</span><span class="p">[</span><span class="s1">&#39;king&#39;</span><span class="p">,</span> <span class="s1">&#39;water&#39;</span><span class="p">,</span> <span class="s1">&#39;god&#39;</span><span class="p">,</span> <span class="s1">&#39;love&#39;</span><span class="p">,</span> <span class="s1">&#39;star&#39;</span><span class="p">],</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
</pre></div>

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

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

<div class="output_area">



<div class="output_png output_subarea ">
<img src="data:image/png;base64,[encoded data, 22352 characters]
"
>
</div>

</div>

<div class="output_area">



<div class="output_text output_subarea output_execute_result">
<pre>&lt;__main__.EmbeddingPlot at 0x7f717d962b90&gt;</pre>
</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="ClusterPlot" class="doc_header"><code>class</code> <code>ClusterPlot</code><a href="https://github.com/RecoHut-Projects/recohut/tree/master/recohut/visualization/basic_plots.py#L245" class="source_link" style="float:right">[source]</a></h2><blockquote><p><code>ClusterPlot</code>(<strong><code>labels</code></strong>, <strong><code>embedding_clusters</code></strong>, <strong><code>word_clusters</code></strong>, <strong>**<code>kwargs</code></strong>) :: <a href="/recohut/basic_plots.html#BasicVisual"><code>BasicVisual</code></a></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="n">embedding_clusters</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">vstack</span><span class="p">((</span><span class="n">np</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">random</span><span class="p">(</span><span class="n">size</span><span class="o">=</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span><span class="mi">5</span><span class="p">,</span><span class="mi">5</span><span class="p">))</span><span class="o">*</span><span class="mi">2</span><span class="p">,</span>
                                <span class="n">np</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">random</span><span class="p">(</span><span class="n">size</span><span class="o">=</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span><span class="mi">5</span><span class="p">,</span><span class="mi">5</span><span class="p">))</span><span class="o">*-</span><span class="mi">2</span><span class="p">))</span>
<span class="n">word_clusters</span> <span class="o">=</span> <span class="p">[[</span><span class="s1">&#39;apple&#39;</span><span class="p">,</span> <span class="s1">&#39;banana&#39;</span><span class="p">,</span> <span class="s1">&#39;mango&#39;</span><span class="p">,</span> <span class="s1">&#39;pineapple&#39;</span><span class="p">,</span> <span class="s1">&#39;orange&#39;</span><span class="p">],</span> <span class="p">[</span><span class="s1">&#39;red&#39;</span><span class="p">,</span> <span class="s1">&#39;green&#39;</span><span class="p">,</span> <span class="s1">&#39;orange&#39;</span><span class="p">,</span> <span class="s1">&#39;magenta&#39;</span><span class="p">,</span> <span class="s1">&#39;cyan&#39;</span><span class="p">]]</span>
<span class="n">labels</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;fruits&#39;</span><span class="p">,</span> <span class="s1">&#39;animals&#39;</span><span class="p">]</span>

<span class="n">ClusterPlot</span><span class="p">(</span><span class="n">labels</span><span class="p">,</span> <span class="n">embedding_clusters</span><span class="p">,</span> <span class="n">word_clusters</span><span class="p">)</span>
</pre></div>

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

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

<div class="output_area">



<div class="output_png output_subarea ">
<img src="data:image/png;base64,[encoded data, 26212 characters]
"
>
</div>

</div>

<div class="output_area">



<div class="output_text output_subarea output_execute_result">
<pre>&lt;__main__.ClusterPlot at 0x7f717ca4bc90&gt;</pre>
</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="TimelinePlot" class="doc_header"><code>class</code> <code>TimelinePlot</code><a href="https://github.com/RecoHut-Projects/recohut/tree/master/recohut/visualization/basic_plots.py#L263" class="source_link" style="float:right">[source]</a></h2><blockquote><p><code>TimelinePlot</code>(<strong><code>data</code></strong>, <strong><code>xticks_type</code></strong>=<em><code>'Month'</code></em>, <strong><code>xticks_interval</code></strong>=<em><code>3</code></em>, <strong>**<code>kwargs</code></strong>) :: <a href="/recohut/basic_plots.html#BasicVisual"><code>BasicVisual</code></a></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="n">likes_data</span> <span class="o">=</span> <span class="n">pd</span><span class="o">.</span><span class="n">DataFrame</span><span class="p">({</span><span class="s1">&#39;type&#39;</span><span class="p">:</span><span class="s1">&#39;Like&#39;</span><span class="p">,</span> 
                        <span class="s1">&#39;date&#39;</span><span class="p">:[</span><span class="s1">&#39;Jun 2016&#39;</span><span class="p">,</span> <span class="s1">&#39;Jun 2016&#39;</span><span class="p">,</span> <span class="s1">&#39;Sept 2016&#39;</span><span class="p">],</span>
                        <span class="s1">&#39;color&#39;</span><span class="p">:</span><span class="s1">&#39;green&#39;</span><span class="p">})</span>
<span class="n">likes_data</span><span class="p">[</span><span class="s1">&#39;date&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">pd</span><span class="o">.</span><span class="n">to_datetime</span><span class="p">(</span><span class="n">likes_data</span><span class="p">[</span><span class="s1">&#39;date&#39;</span><span class="p">])</span>

<span class="c1"># professional registration</span>
<span class="n">comments_data</span> <span class="o">=</span> <span class="n">pd</span><span class="o">.</span><span class="n">DataFrame</span><span class="p">({</span><span class="s1">&#39;type&#39;</span><span class="p">:</span><span class="s1">&#39;Comment&#39;</span><span class="p">,</span> 
                        <span class="s1">&#39;date&#39;</span><span class="p">:[</span><span class="s1">&#39;Jul 2016&#39;</span><span class="p">,</span> <span class="s1">&#39;Aug 2016&#39;</span><span class="p">,</span> <span class="s1">&#39;Sept 2016&#39;</span><span class="p">,</span> <span class="s1">&#39;Sept 2016&#39;</span><span class="p">],</span>
                        <span class="s1">&#39;color&#39;</span><span class="p">:</span><span class="s1">&#39;blue&#39;</span><span class="p">})</span>
<span class="n">comments_data</span><span class="p">[</span><span class="s1">&#39;date&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">pd</span><span class="o">.</span><span class="n">to_datetime</span><span class="p">(</span><span class="n">comments_data</span><span class="p">[</span><span class="s1">&#39;date&#39;</span><span class="p">])</span>

<span class="n">combined_data</span> <span class="o">=</span> <span class="n">pd</span><span class="o">.</span><span class="n">concat</span><span class="p">([</span><span class="n">likes_data</span><span class="p">,</span> <span class="n">comments_data</span><span class="p">])</span>

<span class="n">kwargs</span> <span class="o">=</span> <span class="p">{</span><span class="s1">&#39;figsize&#39;</span><span class="p">:(</span><span class="mi">12</span><span class="p">,</span><span class="mi">5</span><span class="p">)}</span>

<span class="n">TimelinePlot</span><span class="p">(</span><span class="n">combined_data</span><span class="p">,</span> <span class="n">xticks_type</span><span class="o">=</span><span class="s1">&#39;Day&#39;</span><span class="p">,</span> <span class="n">xticks_interval</span><span class="o">=</span><span class="mi">7</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
</pre></div>

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

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

<div class="output_area">



<div class="output_png output_subarea ">
<img src="data:image/png;base64,[encoded data, 26984 characters]
"
>
</div>

</div>

<div class="output_area">



<div class="output_text output_subarea output_execute_result">
<pre>&lt;__main__.TimelinePlot at 0x7f717b03ca90&gt;</pre>
</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="ImageGridPlot" class="doc_header"><code>class</code> <code>ImageGridPlot</code><a href="https://github.com/RecoHut-Projects/recohut/tree/master/recohut/visualization/basic_plots.py#L325" class="source_link" style="float:right">[source]</a></h2><blockquote><p><code>ImageGridPlot</code>(<strong><code>paths</code></strong>, <strong><code>labels</code></strong>, <strong><code>columns</code></strong>=<em><code>5</code></em>, <strong>**<code>kwargs</code></strong>) :: <a href="/recohut/basic_plots.html#BasicVisual"><code>BasicVisual</code></a></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="o">!</span>wget -q --show-progress -O cat1.png <span class="s2">&quot;https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcT7nrOEKnuu0ek-bvr3MOq5JqL6-bm6-0-DyA&amp;usqp=CAU&quot;</span>
<span class="o">!</span>wget -q --show-progress -O cat2.png <span class="s2">&quot;https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTvTSWBQeuHSGP2wLQTNsPOTHp0ok7CVQ2bGQ&amp;usqp=CAU&quot;</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>cat1.png            100%[===================&gt;]   4.93K  --.-KB/s    in 0s      
cat2.png            100%[===================&gt;]   5.87K  --.-KB/s    in 0s      
</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="n">df</span> <span class="o">=</span> <span class="n">pd</span><span class="o">.</span><span class="n">DataFrame</span><span class="o">.</span><span class="n">from_dict</span><span class="p">({</span>
    <span class="s1">&#39;Path&#39;</span><span class="p">:[</span><span class="s1">&#39;cat1.png&#39;</span><span class="p">,</span> <span class="s1">&#39;cat2.png&#39;</span><span class="p">],</span>
    <span class="s1">&#39;Label&#39;</span><span class="p">:[</span><span class="s1">&#39;A&#39;</span><span class="p">,</span><span class="s1">&#39;B&#39;</span><span class="p">]</span>
<span class="p">})</span>

<span class="n">df</span> <span class="o">=</span> <span class="n">df</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="n">df</span><span class="p">]</span><span class="o">*</span><span class="mi">5</span><span class="p">,</span><span class="n">ignore_index</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>

<span class="n">ImageGridPlot</span><span class="p">(</span><span class="n">paths</span><span class="o">=</span><span class="n">df</span><span class="o">.</span><span class="n">Path</span><span class="o">.</span><span class="n">values</span><span class="p">,</span>
              <span class="n">labels</span><span class="o">=</span><span class="n">df</span><span class="o">.</span><span class="n">Label</span><span class="o">.</span><span class="n">values</span><span class="p">)</span>
</pre></div>

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

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

<div class="output_area">



<div class="output_png output_subarea ">
<img src="data:image/png;base64,[encoded data, 330672 characters]
"
>
</div>

</div>

<div class="output_area">



<div class="output_text output_subarea output_execute_result">
<pre>&lt;__main__.ImageGridPlot at 0x7f7177949a90&gt;</pre>
</div>

</div>

</div>
</div>

</div>
    {% endraw %}

</div>
 

