I’m trying to do this project in the Machine Learning path. I’m running into problems early because I feel it is asking me to do things that weren’t explained in the lesson.
In particular, I’m at checkpoints 2/3. I assumed that when it said to transform the dataset of predictor variables to dummy variables, it meant to one hot encode the predictor variables, which, after some doing, gave me this code:
feature_cols = ['age','capital-gain', 'capital-loss', 'hours-per-week', 'sex','race', 'education'] df_dummies = pd.get_dummies(df, columns = feature_cols) df_dummies = df_dummies.iloc[:, 8:]
However, when I went on to try to make the heatmap of the correlation values:
sns.heatmap(df_dummies.corr(), annot = True) plt.show()
But this did not produce any image. There was also no error.
I did try to see what happened if I didn’t OHE the predictor variables and just made the heatmap off of the original data:
df_dummies = df[feature_cols] sns.heatmap(df_dummies.corr(), annot = True) plt.show()
which DID produce a heatmap, but one that did not include the sex, race, or education variables.
What am I missing?