Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on Attributes #2

Open
harshilt04 opened this issue Feb 14, 2025 · 0 comments
Open

Error on Attributes #2

harshilt04 opened this issue Feb 14, 2025 · 0 comments

Comments

@harshilt04
Copy link

harshilt04 commented Feb 14, 2025

  1. Configure the Plot Style:
    Set the background style using Seaborn.
    sns.set(style="white")

2)Calculate the Correlation Matrix:
Compute the correlation values between features in data2.
corr = data2.corr()

3)Create an Upper Triangle Mask:
Initialize a matrix of zeros with the same shape as corr.
Convert it into a boolean type.
Set the upper triangle to True to mask it in the heatmap.
mask = np.zeros_like(corr, dtype=np.bool)
mask[np.triu_indices_from(mask)] = True

4)Set Up the Plot and Color Palette:
Create a figure with specified dimensions.
Define a diverging colormap for the heatmap.
f, ax = plt.subplots(figsize= (18, 15))
cmap = sns.diverging_palette(220, 10, as_cmap=True)

5)Generate the Heatmap:
Plot the heatmap with the correlation matrix.
Apply the mask to hide the upper triangle.
Use the diverging colormap, center it at 0, and set annotations, linewidths, and color bar properties.
sns.heatmap(corr, mask=mask, cmap=cmap, vmax=.3, center=0,
square=True, annot=True, linewidths=.5, cbar_kws= {"shrink": .5})

The error occurs because np.bool is deprecated in newer versions of NumPy. Instead, bool (the built-in Python type) should be used. The corrected line should be:
mask = np.zeros_like(corr, dtype=bool)
This change prevents the Attribute Error, ensuring compatibility with the latest NumPy versions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant