简体   繁体   中英

Unable to plot pairplot using Seaborn==0.9.0

The following is my pip list when using it with pycharm: It's not working with pycharm

I used only 1 command : pip install seaborn which install all the libraries below:

appnope==0.1.0
attrs==19.1.0
backcall==0.1.0
bleach==3.1.0
cycler==0.10.0
decorator==4.4.0
defusedxml==0.5.0
entrypoints==0.3
ipykernel==5.1.0
ipython==7.4.0
ipython-genutils==0.2.0
ipywidgets==7.4.2
jedi==0.13.3
Jinja2==2.10.1
jsonschema==3.0.1
jupyter==1.0.0
jupyter-client==5.2.4
jupyter-console==6.0.0
jupyter-core==4.4.0
kiwisolver==1.0.1
MarkupSafe==1.1.1
matplotlib==3.0.3
mistune==0.8.4
nbconvert==5.4.1
nbformat==4.4.0
notebook==5.7.8
numpy==1.16.2
pandas==0.24.2
pandocfilters==1.4.2
parso==0.4.0
pexpect==4.6.0
pickleshare==0.7.5
prometheus-client==0.6.0
prompt-toolkit==2.0.9
ptyprocess==0.6.0
Pygments==2.3.1
pyparsing==2.3.1
pyrsistent==0.14.11
python-dateutil==2.8.0
pytz==2018.9
pyzmq==18.0.1
qtconsole==4.4.3
scipy==1.2.1
seaborn==0.9.0
Send2Trash==1.5.0
six==1.12.0
terminado==0.8.2
testpath==0.4.2
tornado==6.0.2
traitlets==4.3.2
wcwidth==0.1.7
webencodings==0.5.1
widgetsnbextension==3.4.2

requirements.txt

jupyter==1.0.0
seaborn==0.9.0
plotly==3.6.1

It gives me an error when i try to plot it as Pairplot

Code:

df= pd.read_csv('https://gist.github.com/ktisha/c21e73a1bd1700294ef790c56c8aec1f')    
df.rename(columns={'Class variable (0 or 1)':'Target'}, inplace=True)
sns.pairplot(df,hue='Target')

Error:

LinAlgError: singular matrix

The same code works on google collab and on anaconda base environment but not on any other virtual env. Also, the code works if I install seaborn=0.7.1

WHY is this happening? Please someone help me resolve this issue!

Thank You.

conda list -e > requirements.txt gives me this:

# This file may be used to create an environment using:
# $ conda create --name <env> --file <this file>
# platform: osx-64
appnope=0.1.0=py37_0
asn1crypto=0.24.0=py37_0
attrs=19.1.0=py37_1
backcall=0.1.0=py37_0
blas=1.0=mkl
bleach=3.1.0=py37_0
ca-certificates=2019.1.23=0
certifi=2019.3.9=py37_0
cffi=1.12.2=py37hb5b8e2f_1
chardet=3.0.4=py37_1
cryptography=2.6.1=py37ha12b0ac_0
cycler=0.10.0=py37_0
dbus=1.13.6=h90a0687_0
decorator=4.4.0=py37_1
defusedxml=0.5.0=py37_1
entrypoints=0.3=py37_0
expat=2.2.6=h0a44026_0
freetype=2.9.1=hb4e5f40_0
gettext=0.19.8.1=h15daf44_3
glib=2.56.2=hd9629dc_0
icu=58.2=h4b95b61_1
idna=2.8=py37_0
intel-openmp=2019.3=199
ipykernel=5.1.0=py37h39e3cac_0
ipython=7.4.0=py37h39e3cac_0
ipython_genutils=0.2.0=py37_0
ipywidgets=7.4.2=py37_0
jedi=0.13.3=py37_0
jinja2=2.10=py37_0
jpeg=9b=he5867d9_2
jsonschema=3.0.1=py37_0
jupyter=1.0.0=py37_7
jupyter_client=5.2.4=py37_0
jupyter_console=6.0.0=py37_0
jupyter_core=4.4.0=py37_0
kiwisolver=1.0.1=py37h0a44026_0
libcxx=4.0.1=hcfea43d_1
libcxxabi=4.0.1=hcfea43d_1
libedit=3.1.20181209=hb402a30_0
libffi=3.2.1=h475c297_4
libgfortran=3.0.1=h93005f0_2
libiconv=1.15=hdd342a3_7
libpng=1.6.36=ha441bb4_0
libsodium=1.0.16=h3efe00b_0
markupsafe=1.1.1=py37h1de35cc_0
matplotlib=3.0.3=py37h54f8f79_0
mistune=0.8.4=py37h1de35cc_0
mkl=2019.3=199
mkl_fft=1.0.10=py37h5e564d8_0
mkl_random=1.0.2=py37h27c97d8_0
nbconvert=5.4.1=py37_3
nbformat=4.4.0=py37_0
ncurses=6.1=h0a44026_1
notebook=5.7.8=py37_0
numpy=1.16.2=py37hacdab7b_0
numpy-base=1.16.2=py37h6575580_0
openssl=1.1.1b=h1de35cc_1
pandas=0.24.2=py37h0a44026_0
pandoc=2.2.3.2=0
pandocfilters=1.4.2=py37_1
parso=0.3.4=py37_0
patsy=0.5.1=py37_0
pcre=8.43=h0a44026_0
pexpect=4.6.0=py37_0
pickleshare=0.7.5=py37_0
pip=19.0.3=py37_0
plotly=3.7.0=py_0
prometheus_client=0.6.0=py37_0
prompt_toolkit=2.0.9=py37_0
ptyprocess=0.6.0=py37_0
pycparser=2.19=py37_0
pygments=2.3.1=py37_0
pyopenssl=19.0.0=py37_0
pyparsing=2.3.1=py37_0
pyqt=5.9.2=py37h655552a_2
pyrsistent=0.14.11=py37h1de35cc_0
pysocks=1.6.8=py37_0
python=3.7.3=h359304d_0
python-dateutil=2.8.0=py37_0
pytz=2018.9=py37_0
pyzmq=18.0.0=py37h0a44026_0
qt=5.9.7=h468cd18_1
qtconsole=4.4.3=py37_0
readline=7.0=h1de35cc_5
requests=2.21.0=py37_0
retrying=1.3.3=py37_2
scipy=1.2.1=py37h1410ff5_0
seaborn=0.9.0=py37_0
send2trash=1.5.0=py37_0
setuptools=40.8.0=py37_0
sip=4.19.8=py37h0a44026_0
six=1.12.0=py37_0
sqlite=3.27.2=ha441bb4_0
statsmodels=0.9.0=py37h1d22016_0
terminado=0.8.1=py37_1
testpath=0.4.2=py37_0
tk=8.6.8=ha441bb4_0
tornado=6.0.2=py37h1de35cc_0
traitlets=4.3.2=py37_0
urllib3=1.24.1=py37_0
wcwidth=0.1.7=py37_0
webencodings=0.5.1=py37_1
wheel=0.33.1=py37_0
widgetsnbextension=3.4.2=py37_0
xz=5.2.4=h1de35cc_4
zeromq=4.3.1=h0a44026_3
zlib=1.2.11=h1de35cc_3

but pip freeze > requirements.txt:

appnope==0.1.0
asn1crypto==0.24.0
attrs==19.1.0
backcall==0.1.0
bleach==3.1.0
certifi==2019.3.9
cffi==1.12.2
chardet==3.0.4
cryptography==2.6.1
cycler==0.10.0
decorator==4.4.0
defusedxml==0.5.0
entrypoints==0.3
idna==2.8
ipykernel==5.1.0
ipython==7.4.0
ipython-genutils==0.2.0
ipywidgets==7.4.2
jedi==0.13.3
Jinja2==2.10
jsonschema==3.0.1
jupyter==1.0.0
jupyter-client==5.2.4
jupyter-console==6.0.0
jupyter-core==4.4.0
kiwisolver==1.0.1
MarkupSafe==1.1.1
matplotlib==3.0.3
mistune==0.8.4
mkl-fft==1.0.10
mkl-random==1.0.2
nbconvert==5.4.1
nbformat==4.4.0
notebook==5.7.8
numpy==1.16.2
pandas==0.24.2
pandocfilters==1.4.2
parso==0.3.4
patsy==0.5.1
pexpect==4.6.0
pickleshare==0.7.5
plotly==3.7.0
prometheus-client==0.6.0
prompt-toolkit==2.0.9
ptyprocess==0.6.0
pycparser==2.19
Pygments==2.3.1
pyOpenSSL==19.0.0
pyparsing==2.3.1
pyrsistent==0.14.11
PySocks==1.6.8
python-dateutil==2.8.0
pytz==2018.9
pyzmq==18.0.0
qtconsole==4.4.3
requests==2.21.0
retrying==1.3.3
scipy==1.2.1
seaborn==0.9.0
Send2Trash==1.5.0
six==1.12.0
statsmodels==0.9.0
terminado==0.8.1
testpath==0.4.2
tornado==6.0.2
traitlets==4.3.2
urllib3==1.24.1
wcwidth==0.1.7
webencodings==0.5.1
widgetsnbextension==3.4.2

I cannot reproduce the error. There is a different one though, which is due to the link not working correctly. The following works correctly for me.

import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns

n = "https://gist.githubusercontent.com/ktisha/c21e73a1bd1700294ef790c56c8aec1f/raw/819b69b5736821ccee93d05b51de0510bea00294/pima-indians-diabetes.csv"
df= pd.read_csv(n, comment='#', header=None, sep=",")    
df.columns=list("ABCDEFGHI")

print(df.head())
sns.pairplot(df, hue='I', vars=df.columns[:-1])
plt.show()

在此处输入图片说明

使用 PairGrid 而不是 fairplot g = sns.PairGrid(df , hue = 'TARGET CLASS') g = g.map(sns.scatterplot)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM