I’m working on the heat map portion of the project, and it is failing. The first error is in one of the fields so I don’t have variable issues, but there are 3 or 4 diffs in the actual v. expected output.
Each one is a tenth off and I’m wondering if there is differences in my rounding vs. others’ and I would like to see you rounding code if you have it. Otherwise, I’m wondering if I should just modify the test to put the actual values in the expected because I have completed the ‘spirit’ of the project.
Any help would be greatly appreciated
Diff output
First differing element 9:
‘0.2’
‘0.3’
[‘0.0’,
‘0.0’,
‘-0.0’,
‘0.0’,
‘-0.1’,
‘0.5’,
‘0.0’,
‘0.1’,
‘0.1’,
- ‘0.2’,
? ^
-
‘0.3’,
? ^‘0.0’,
‘0.0’,
‘0.0’,
‘0.0’,
‘0.0’,
‘0.0’,
‘0.2’,
‘0.1’,
‘0.0’,
‘0.2’,
‘0.1’,
‘0.0’,
‘0.1’,
‘-0.0’,
‘-0.1’,
‘0.1’,
‘0.0’,
‘0.2’,
‘0.0’,
‘0.1’,
‘-0.0’,
‘-0.0’,
‘0.1’,
‘0.0’,
‘0.1’,
‘0.4’,
‘-0.0’,
‘-0.0’,
‘0.3’,
‘0.2’,
‘0.1’,
‘-0.0’,
‘0.0’,
‘0.0’,
‘-0.0’,
‘-0.0’,
‘-0.0’,
‘0.2’,
‘0.1’,
‘0.1’,
‘0.0’,
‘0.0’,
‘0.0’,
‘0.0’,
‘0.3’,
‘0.0’,
‘-0.0’,
‘0.0’,
‘-0.0’,
‘-0.0’,
‘-0.0’,
‘0.0’,
‘0.0’,
‘-0.0’,
‘0.0’,
‘0.0’,
‘0.0’,
‘0.2’,
‘0.0’,
‘-0.0’,
‘0.2’,
- ‘0.0’,
? ^
-
‘0.1’,
? ^‘0.3’,
‘0.2’,
‘0.1’,
‘-0.0’,
‘-0.0’,
‘-0.0’,
‘-0.0’,
‘0.1’,
‘-0.1’,
- ‘-0.2’,
? ^
-
‘-0.1’,
? ^‘0.7’,
‘0.0’,
‘0.2’,
‘0.1’,
‘0.1’,
‘-0.0’,
‘0.0’,
‘-0.0’,
‘0.1’] : Expected differnt values in heat map.
Code SPOILER
Clean the data
df_heat = df.loc[df['ap_lo'] <= df['ap_hi']]
df_heat = df_heat.loc[df_heat['height'] >= df_heat['height'].quantile(0.025)]
df_heat = df_heat.loc[df_heat['height'] <= df_heat['height'].quantile(0.975)]
df_heat = df_heat.loc[df_heat['weight'] >= df_heat['weight'].quantile(0.025)]
df_heat = df_heat.loc[df_heat['weight'] <= df_heat['weight'].quantile(0.975)]
print(df_heat.head())
# Calculate the correlation matrix
corr = df_heat.corr()
print(corr)
# Generate a mask for the upper triangle
mask = np.triu(np.ones_like(corr))
# Set up the matplotlib figure
fig, ax = plt.subplots()
# Draw the heatmap with 'sns.heatmap()'
ax = sns.heatmap(corr, vmin=-0.16, vmax=0.32,annot=True, fmt="0.1f", mask=mask, ax=ax)