Skip to content

Instantly share code, notes, and snippets.

@dyerrington
Last active May 19, 2020 00:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dyerrington/5654f724808df25483a9496794f85e18 to your computer and use it in GitHub Desktop.
Save dyerrington/5654f724808df25483a9496794f85e18 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 175,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>alcohol</th>\n",
" <th>alcohol_abs</th>\n",
" <th>correlation</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <td>proline</td>\n",
" <td>0.643720</td>\n",
" <td>0.643720</td>\n",
" <td>+</td>\n",
" </tr>\n",
" <tr>\n",
" <td>color_intensity</td>\n",
" <td>0.546364</td>\n",
" <td>0.546364</td>\n",
" <td>+</td>\n",
" </tr>\n",
" <tr>\n",
" <td>alcalinity_of_ash</td>\n",
" <td>-0.310235</td>\n",
" <td>0.310235</td>\n",
" <td>-</td>\n",
" </tr>\n",
" <tr>\n",
" <td>total_phenols</td>\n",
" <td>0.289101</td>\n",
" <td>0.289101</td>\n",
" <td>+</td>\n",
" </tr>\n",
" <tr>\n",
" <td>magnesium</td>\n",
" <td>0.270798</td>\n",
" <td>0.270798</td>\n",
" <td>+</td>\n",
" </tr>\n",
" <tr>\n",
" <td>flavanoids</td>\n",
" <td>0.236815</td>\n",
" <td>0.236815</td>\n",
" <td>+</td>\n",
" </tr>\n",
" <tr>\n",
" <td>ash</td>\n",
" <td>0.211545</td>\n",
" <td>0.211545</td>\n",
" <td>+</td>\n",
" </tr>\n",
" <tr>\n",
" <td>nonflavanoid_phenols</td>\n",
" <td>-0.155929</td>\n",
" <td>0.155929</td>\n",
" <td>-</td>\n",
" </tr>\n",
" <tr>\n",
" <td>proanthocyanins</td>\n",
" <td>0.136698</td>\n",
" <td>0.136698</td>\n",
" <td>+</td>\n",
" </tr>\n",
" <tr>\n",
" <td>malic_acid</td>\n",
" <td>0.094397</td>\n",
" <td>0.094397</td>\n",
" <td>+</td>\n",
" </tr>\n",
" <tr>\n",
" <td>od280/od315_of_diluted_wines</td>\n",
" <td>0.072343</td>\n",
" <td>0.072343</td>\n",
" <td>+</td>\n",
" </tr>\n",
" <tr>\n",
" <td>hue</td>\n",
" <td>-0.071747</td>\n",
" <td>0.071747</td>\n",
" <td>-</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" alcohol alcohol_abs correlation\n",
"alcohol 1.000000 1.000000 +\n",
"proline 0.643720 0.643720 +\n",
"color_intensity 0.546364 0.546364 +\n",
"alcalinity_of_ash -0.310235 0.310235 -\n",
"total_phenols 0.289101 0.289101 +\n",
"magnesium 0.270798 0.270798 +\n",
"flavanoids 0.236815 0.236815 +\n",
"ash 0.211545 0.211545 +\n",
"nonflavanoid_phenols -0.155929 0.155929 -\n",
"proanthocyanins 0.136698 0.136698 +\n",
"malic_acid 0.094397 0.094397 +\n",
"od280/od315_of_diluted_wines 0.072343 0.072343 +\n",
"hue -0.071747 0.071747 -"
]
},
"execution_count": 175,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"alcohol_corr = df_corr[['alcohol']].copy()\n",
"alcohol_corr['alcohol_abs'] = df_corr['alcohol'].abs()\n",
"alcohol_corr['correlation'] = alcohol_corr['alcohol'].map(\n",
" lambda value: \"+\" if value > 0 else (\"none\" if value == 0 else \"-\")\n",
")\n",
"alcohol_corr.sort_values('alcohol_abs', ascending = False)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.4"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment