Created
June 17, 2020 18:38
-
-
Save emondarock/ae7ae217d46896b8d57d83248b2c4b2f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Importing Libraries | |
import pandas as pd | |
import matplotlib.pyplot as plt | |
import numpy as np | |
%matplotlib inline | |
//Import CSV File | |
data_frame = pd.read_csv('pima-data.csv') | |
//Check CSV File | |
data_frame.shape | |
data_frame.head(3) | |
data_frame.tail(4) | |
//Check If Any Data Contains Null | |
print(data_frame.isnull().values.any()) | |
//Correlation HeatMap | |
# Here size means plot-size | |
def corr_heatmap(data_frame, size=11): | |
# Getting correlation using Pandas | |
correlation = data_frame.corr() | |
# Dividing the plot into subplots for increasing size of plots | |
fig, heatmap = plt.subplots(figsize=(size, size)) | |
# Plotting the correlation heatmap | |
heatmap.matshow(correlation) | |
# Adding xticks and yticks | |
plt.xticks(range(len(correlation.columns)), correlation.columns) | |
plt.yticks(range(len(correlation.columns)), correlation.columns) | |
# Displaying the graph | |
plt.show() | |
corr_heatmap(data_frame, 12) | |
//Clean same type data | |
# Deleting 'skin' column completely | |
del data_frame['skin'] | |
# Checking if the action was successful or not | |
data_frame.head() | |
//Mapping bool to int | |
# Mapping the values | |
map_diabetes = {True : 1, False : 0} | |
# Setting the map to the data_frame | |
data_frame['diabetes'] = data_frame['diabetes'].map(map_diabetes) | |
# Let's see what we have done | |
data_frame.head() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment