Files
mlessentials/Lab03/Exercise3.05/Exercise3_05.ipynb
T
fenago f3b24b4b7f added
2021-02-07 15:16:01 +05:00

141 lines
2.9 KiB
Plaintext

{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {},
"colab_type": "code",
"id": "8UMFqsCD0xyF"
},
"outputs": [],
"source": [
"# Importing necessary packages\n",
"import pandas as pd"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {},
"colab_type": "code",
"id": "HSXgY0ze09cY"
},
"outputs": [],
"source": [
"file_url = '../bank-full.csv'\n",
"bankData = pd.read_csv(file_url, sep=\";\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {},
"colab_type": "code",
"id": "NiRh58PlaJoZ"
},
"outputs": [],
"source": [
"from pandas import set_option"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {},
"colab_type": "code",
"id": "9wn-4MiPabSL"
},
"outputs": [],
"source": [
"bankNumeric = bankData[['age','balance','day','duration','campaign','pdays','previous']]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 266
},
"colab_type": "code",
"executionInfo": {
"elapsed": 973,
"status": "ok",
"timestamp": 1573001855052,
"user": {
"displayName": "Anthony So",
"photoUrl": "https://lh3.googleusercontent.com/a-/AAuE7mCYY-iGjUIqBSnlLoszfZTN7rU7FRNg05Rdt9Ii3A=s64",
"userId": "11809607246124237079"
},
"user_tz": -660
},
"id": "deI0ALoiaL3i",
"outputId": "ab50a776-ba9a-42ad-af0e-cce93cb3ac14"
},
"outputs": [],
"source": [
"set_option('display.width',150)\n",
"set_option('precision',3)\n",
"bankCorr = bankNumeric.corr(method = 'pearson')\n",
"bankCorr"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 271
},
"colab_type": "code",
"id": "F8JT-MtWb6eY",
"outputId": "8ab75e85-e755-4273-eff7-4910a92aa352"
},
"outputs": [],
"source": [
"# Plotting the correlation matrix\n",
"\n",
"from matplotlib import pyplot\n",
"\n",
"corFig = pyplot.figure()\n",
"figAxis = corFig.add_subplot(111)\n",
"corAx = figAxis.matshow(bankCorr,vmin=-1,vmax=1)\n",
"corFig.colorbar(corAx)\n",
"pyplot.show()"
]
}
],
"metadata": {
"colab": {
"collapsed_sections": [],
"name": "Exercise3.05_updated.ipynb",
"provenance": []
},
"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.8.6"
}
},
"nbformat": 4,
"nbformat_minor": 1
}