Hi guys, I am still not done with this project. All my code seemed to be in order on the jupyter notebook, however, I am getting three errors on Repl.it. These are the errors I am getting:
Fail 1: FAIL: test_line_plot_labels (test_module.CatPlotTestCase)
AssertionError: 1 != 13 : Expected a different number of bars chart.
Fail 2: FAIL: test_heat_map_values
Traceback (most recent call last):
File “/home/runner/DevotedTanSearchengine/test_module.py”, line 15, in test_line_plot_labels
self.assertEqual(actual, expected, “Expected line plot xlabel to be ‘variable’”)
AssertionError: ‘’ != ‘variable’
- variable : Expected line plot xlabel to be ‘variable’
Fail 3: Traceback (most recent call last):
File “/home/runner/DevotedTanSearchengine/test_module.py”, line 47, in test_heat_map_values
self.assertEqual(actual, expected, “Expected differnt values in heat map.”)
AssertionError: Lists differ: [‘0.0[14 chars]0’, ‘-0.0’, ‘-0.1’, ‘0.5’, ‘-0.0’, ‘0.1’, ‘0.2[594 chars]0.2’] != [‘0.0[14 chars]0’, ‘0.0’, ‘-0.1’, ‘0.5’, ‘0.0’, ‘0.1’, ‘0.1’,[605 chars], ‘’]
First differing element 3:
‘-0.0’
‘0.0’
Second list contains 3 additional elements.
First extra element 91:
‘’
Diff is 1285 characters long. Set self.maxDiff to None to see it. : Expected differnt values in heat map.
*This is my original code from Jupyter.
Adding overweight to the DF.
BMI = (df[‘weight’] / np.power((df[‘height’]/100),2))
df[‘overweight’] = np.where(BMI > 25, 1, 0)
Normalizing values for cholesterol and gluc.
df[‘cholesterol’] = np.where(df[‘cholesterol’] > 1, 1, 0)
df[‘gluc’] = np.where(df[‘gluc’] > 1, 1, 0)
Convert the data into long format and create a chart that shows the value counts of the categorical features using seaborn’s catplot(). The dataset should be split by ‘Cardio’ so there is one chart for each ‘cardio’ value
df1 = pd.melt(df, id_vars=[‘cardio’], value_vars=[‘active’, ‘alco’, ‘cholesterol’, ‘gluc’, ‘overweight’, ‘smoke’])
g = sns.catplot(data=df1, kind= ‘count’, x= ‘variable’, hue=‘value’, col=‘cardio’)
Cleaning the data to create the heat map.
df = df[df[‘ap_lo’] <= df[‘ap_hi’]]
df = df[df[‘height’] >= df[‘height’].quantile(0.025)]
df = df[df[‘height’] <= df[‘height’].quantile(0.975)]
df = df[df[‘weight’] >= df[‘weight’].quantile(0.025)]
df = df[df[‘weight’] <= df[‘weight’].quantile(0.975)]
Creating the correlation
df_corr = df.corr()
Lastly, creating the heatmap
mask = np.zeros_like(df_corr)
mask[np.triu_indices_from(mask)] = True
with sns.axes_style(‘white’):
f, ax = plt.subplots(figsize=(16, 12))
ax = sns.heatmap(df_corr, mask=mask, square=True, annot = True, annot_kws={“size”: 8}, vmax= .24, fmt=‘0.1f’, cmap= ‘YlGnBu’)
Any suggestions as to identify and fix the errors?
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36
.
Challenge: Medical Data Visualizer
Link to the challenge: