<commit_before>---
layout: post
title: "Generating Correlation Heat Maps in Seaborn"
---

<img src="/Images/Styles/Abalone/i-dd907cad8c11afeb35cfaa3cde3ecaf5-xkcd.png" class="inline"/><br>
It's Getting Hot In Here. 

## Imports
```Python3
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import matplotlib.pylab as plt
```

## Grab All The Data
```Python3
def getDF(data_url, columns):
    #retrieve data from url, create dataframe, return it
    data = pd.read_csv(data_url, names=columns)
    return data
```

## Seaborn Heat Map

```Python3
def heatMap(df):
    #Create Correlation df
    corr = df.corr()
    #Plot figsize
    fig, ax = plt.subplots(figsize=(10, 10))
    #Generate Color Map
    colormap = sns.diverging_palette(220, 10, as_cmap=True)
    #Generate Heat Map, allow annotations and place floats in map
    sns.heatmap(corr, cmap=colormap, annot=True, fmt=".2f")
    #Apply xticks
    plt.xticks(range(len(corr.columns)), corr.columns);
    #Apply yticks
    plt.yticks(range(len(corr.columns)), corr.columns)
    #show plot
    plt.show()
```

## Visualize It
<img src="/Images/Styles/Abalone/heatMap.png" class="inline"/><br><commit_msg>Update 2018-06-06-Corr.md<commit_after>---
layout: post
title: "Generating Correlation Heat Maps in Seaborn"
---

<img src="/Images/Abalone/i-dd907cad8c11afeb35cfaa3cde3ecaf5-xkcd.png" class="inline"/><br>
It's Getting Hot In Here. 

## Imports
```Python3
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import matplotlib.pylab as plt
```

## Grab All The Data
```Python3
def getDF(data_url, columns):
    #retrieve data from url, create dataframe, return it
    data = pd.read_csv(data_url, names=columns)
    return data
```

## Seaborn Heat Map

```Python3
def heatMap(df):
    #Create Correlation df
    corr = df.corr()
    #Plot figsize
    fig, ax = plt.subplots(figsize=(10, 10))
    #Generate Color Map
    colormap = sns.diverging_palette(220, 10, as_cmap=True)
    #Generate Heat Map, allow annotations and place floats in map
    sns.heatmap(corr, cmap=colormap, annot=True, fmt=".2f")
    #Apply xticks
    plt.xticks(range(len(corr.columns)), corr.columns);
    #Apply yticks
    plt.yticks(range(len(corr.columns)), corr.columns)
    #show plot
    plt.show()
```

## Visualize It
<img src="/Images/Abalone/heatMap.png" class="inline"/><br>
{'fraction_non_alphanumeric': 0.13367174280879865, 'fraction_numerical': 0.023688663282571912, 'mean_word_length': 4.031914893617022, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3187186', 'n_tokens_mistral': 930, 'n_tokens_neox': 849, 'n_words': 222}