Skip to content

Instantly share code, notes, and snippets.

@aniruddha27
Last active July 13, 2020 09:13
Show Gist options
  • Save aniruddha27/b05d3d25a5f9c955316bfa6fa1ae9117 to your computer and use it in GitHub Desktop.
Save aniruddha27/b05d3d25a5f9c955316bfa6fa1ae9117 to your computer and use it in GitHub Desktop.
# Top features and SalePrice
numeric_cols = ['GrLivArea','GarageArea','TotalBsmtSF','1stFlrSF','YearBuilt']
nominal_cols = ['OverallQual','GarageCars','FullBath','TotRmsAbvGrd']
fig,ax=plt.subplots(nrows=9,ncols=1,figsize=(6,30))
for i in range(len(top_features)):
ax[i].scatter(x=train[top_features[i]], y=train['SalePrice'])
ax[i].set_xlabel('%s'%(top_features[i]))
ax[i].set_ylabel('SalePrice')
plt.tight_layout()
plt.savefig('./Top_featuresvsSalePrice.jpg',dpi=300,bbox_inches='tight')
plt.show();
@altamashkhn
Copy link

Hi,

I am getting this error while running this code.
KeyError: 0.7909816005838047

and if I replace 5th line of code to this <ax[i].scatter(x=top_features[i], y=train['SalePrice'])> getting error of ValueError: x and y must be the same size

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment