I am stuck in something I am not sure I can fix.
When running the code I have a fail in:
"FAIL: test_heat_map_values (test_module.HeatMapTestCase)
Traceback (most recent call last):
File “/home/runner/boilerplate-medical-data-visualizer/test_module.py”, line 47, in test_heat_map_values
self.assertEqual(actual, expected, “Expected different values in heat map.”)
AssertionError: Lists differ: != [‘0.0’, ‘0.0’, ‘-0.0’, ‘0.0’, ‘-0.1’, ‘0.5[616 chars]0.1’]
Second list contains 91 additional elements.
First extra element 0:
‘0.0’
Diff is 941 characters long. Set self.maxDiff to None to see it. : Expected different values in heat map."
For start, it appears the ‘actual’ list is empty? (‘Lists differ: != [‘0.0’, ‘0.0’, ‘-0.0’, ‘0.0’, ‘-0.1’, ‘0.5[616 chars]0.1’]’)
This cannot be as the correlation is performed and sns.heatmap creates the heatmap with values every time.
In any case, comparing the value of the correlation (executed in visual studio) to the “expected” values, I see they differ (for instance at the last value I have 0.2, rounded up by heatmap from corr=0.150, and it is expected 0.1, in position 10th I have 0.2, rounded down by heatmap from corr=0.240, and it is expected 0.3,…)
I am blocked as I don’t see how I could fix the issue.
Thank you in advance for any light that could be shared
I include the code for the function “draw_heatmap”
Your code so far
def draw_heat_map():
# Clean the data
print(df.shape)
df_heat = df.loc[(df[‘ap_lo’]<=df[‘ap_hi’])(df[‘height’]>=df[‘height’].quantile(0.025))(df[‘height’]<df[‘height’].quantile(0.975))(df[‘weight’]>=df[‘weight’].quantile(0.025))(df[‘weight’]<df[‘weight’].quantile(0.975))]
#print(df_heat.shape)
# Calculate the correlation matrix
corr = df_heat.corr()
# Generate a mask for the upper triangle
mask = np.triu(np.ones_like(corr).astype(bool))
# Set up the matplotlib figure
ax = sns.heatmap(data=corr, mask=mask, fmt=‘.1f’, annot=True)
fig= ax.get_figure()
# Draw the heatmap with 'sns.heatmap()'
# Do not modify the next two lines
fig.savefig(‘heatmap.png’)
return fig
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36
Challenge: Data Analysis with Python Projects - Medical Data Visualizer
Link to the challenge: