USE pandas FOR READING CSV FILE
USE seaborn FOR DENSITY CHART PLOTTING
EXAMPLE
import pandas as pd
import seaborn as sns;
# Sample CSV Data
# Pregnancies Glucose BloodPressure SkinThickness Insulin BMI DiabetesPedigreeFunction Age Outcome
# 6,148,72,35,0,33.6,0.627,50,1
# 1,85,66,29,0,26.6,0.351,31,0
# Read CSV Data
diabetics = pd.read_csv('diabetes.csv')
print(diabetics.keys())
# Create Data frame
my_data_frame = pd.DataFrame(diabetics)
# Print Top-5 (Head) from dataset
print(my_data_frame.head())
# Extract 2 sub dataset based on conditions
positive = diabetics.loc[diabetics.Outcome==1]
negative = diabetics.loc[diabetics.Outcome==0]
# Plot the chart using specific columns of datasets and given colors
ax = sns.kdeplot(positive.Pregnancies, positive.Glucose,
cmap="Greens", shade=True, shade_lowest=False)
ax = sns.kdeplot(negative.Pregnancies, negative.Glucose,
cmap="Reds", shade=True, shade_lowest=False)
No comments:
Post a Comment
Note: only a member of this blog may post a comment.