0% found this document useful (0 votes)
2 views6 pages

Machine Learning Visualization Part 6

The document presents various visualizations using seaborn and matplotlib to analyze different datasets, including cholesterol distribution by sex, housing sale price distribution, Titanic survival data, and wine characteristics. It includes plots such as KDE plots, histograms, box plots, and scatter plots to illustrate relationships and distributions within the data. The visualizations aim to provide insights into the datasets and highlight key statistics like mean and median values.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views6 pages

Machine Learning Visualization Part 6

The document presents various visualizations using seaborn and matplotlib to analyze different datasets, including cholesterol distribution by sex, housing sale price distribution, Titanic survival data, and wine characteristics. It includes plots such as KDE plots, histograms, box plots, and scatter plots to illustrate relationships and distributions within the data. The visualizations aim to provide insights into the datasets and highlight key statistics like mean and median values.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Machine Learning Visualization: Part 6

[Link](figsize=(10, 5))
sns.set_context("paper")

kdeplt = [Link](
data=heart_dft_chol_n0,
x="Cholesterol",
hue="Sex",
palette=sex_color,
alpha=0.7,
lw=2,
)
kdeplt.set_title("Cholesterol values distribution\n Male VS Female", fontsize=12)
kdeplt.set_xlabel("Cholesterol", fontsize=12)
[Link](x=Chol_mean_f, color="#c90076", ls="--", lw=1.3)
[Link](x=Chol_mean_m, color="#2986cc", ls="--", lw=1.3)
[Link](108, 0.00612, "Mean Cholesterol / Male", fontsize=10, color="#2986cc")
[Link](260, 0.006, "Mean Cholesterol / Female", fontsize=10, color="#c90076")
[Link]()

Syed Afroz Ali


heart_df_fg = [Link](
data=heart_dft_chol_n0,
col="Sex",
hue="Sex",
row="HeartDisease",
height=4,
aspect=1.3,
palette=sex_color,
col_order=["Male", "Female"],
)
heart_df_fg.map_dataframe([Link], "Age", "MaxHR")
[Link]()

Syed Afroz Ali


mean_SalePrice = usa_housing_df[["SalePrice"]].mean().squeeze()
median_SalePrice = usa_housing_df[["SalePrice"]].median().squeeze()

[Link](figsize=(10, 5))
sns.set_context("paper")

histplt = [Link](
data=usa_housing_df,
x="SalePrice",
color="#4f758f",
bins=60,
alpha=0.5,
lw=2,
)
histplt.set_title("SalePrice Distribution", fontsize=12)
histplt.set_xlabel("SalePrice", fontsize=12)

[Link](x=mean_SalePrice, color="#14967f", ls="--", lw=1.5)


[Link](x=median_SalePrice, color="#9b0f33", ls="--", lw=1.5)
[Link](mean_SalePrice + 5000, 175, "Mean SalePrice", fontsize=9,
color="#14967f")
[Link](
median_SalePrice - 115000, 175, "Median SalePrice", fontsize=9,
color="#9b0f33"
)
[Link].set_major_formatter([Link]())
[Link](0, 200)
[Link]()

Syed Afroz Ali


df2 = titanic[['Survived','Pclass','Sex','Embarked','SibSp','Parch',"Age"]]

fig, axes = [Link](1, 2)


fig.set_figheight(10)
fig.set_figwidth(20)
for i,col in enumerate(df2.select_dtypes('object')):
[Link](x="Age", y=col, data=df2,
whis=[0, 100], width=.6,ax=axes[i])

df2 = titanic[['Survived','Pclass','Sex','Embarked','SibSp','Parch',"Age"]]
#create the subplots
f, (ax_box, ax_hist) = [Link](2, sharex=True,
gridspec_kw={"height_ratios": (.15, .85)})
#title
ax_box.title.set_text('Price countplot and Boxplot')
# assigning a graph to each ax
[Link](df2["Age"], orient="h" ,ax=ax_box)
[Link](data=df2, x="Age", ax=ax_hist)
# Remove x axis name for the boxplot
ax_box.set(xlabel='')
[Link]()

Syed Afroz Ali


NUMERICAL = wine[['fixed acidity', 'volatile acidity', 'citric acid', 'residual sugar',
'chlorides', 'free sulfur dioxide', 'total sulfur dioxide', 'density',
'pH', 'sulphates', 'alcohol']]
fig, axes = [Link](2, 4)
fig.set_figheight(12)
fig.set_figwidth(16)
for i,col in enumerate(NUMERICAL):
[Link](wine[col],ax=axes[(i // 4) -1 ,(i % 4)], kde = True)
axes[(i // 4) -1 ,(i % 4)].axvline(wine[col].mean(), color='k', linestyle='dashed',
linewidth=1)

fig, axes = [Link](1, 3)


fig.set_figheight(7)
fig.set_figwidth(20)
[Link](data=titanic, x="Age", y="Fare", hue="Survived", size="Survived",
ax=axes[0])
[Link](data=titanic, x="Age", y="Fare", hue="Pclass", size="Pclass",
ax=axes[1])
[Link](data=titanic, x="Age", y="Fare", hue="SibSp", size="SibSp",
ax=axes[2]);

Syed Afroz Ali


color = list([Link](12, 'grey'))
color[2], color[10] = 'orange', 'orange'
[Link]('month').mean().active_power.plot(kind='bar', title='Average of Active
Power of each Months', color=color, rot=0)
[Link]('Active Power [kW]');

[Link]('Actual Power vs Theoretical Power')


[Link](df.theor_power, df.active_power, 'o', markersize= 1)
[Link]('both')
[Link]('Theoretcial Power (kW)')
[Link]('Actual Power (kW)')
[Link]([0,3650], [0,3650], '-', c= 'k')
[Link]()

group_hours = df_demand['load'].groupby([Link](freq='D', how='mean'))


fig, axs = [Link](1,1, figsize=(12,5))
year_demands = [Link]()
for name, group in group_hours:
year_demands[[Link]] = [Link]([Link])
year_demands.plot(ax=axs)
axs.set_xlabel('Hour of the day')
axs.set_ylabel('Energy Demanded MWh')
axs.set_title('Mean yearly energy demand by hour of the day ');

Syed Afroz Ali

You might also like