Seaborn이 특정 기능(타이타닉 데이터 세트)에 대한 히트맵을 플롯하지 못함

독일 브루니니

저는 일부 신경망으로 작업하고 있으며 seaborn을 사용하여 타이타닉 데이터 세트에 대한 상관 히트맵을 플로팅하는 데 어려움을 겪고 있습니다. 요약하자면 플로팅 중에 'n_siblings_spouses' 기능에 문제가 있는 것 같습니다. 문제가 기능 자체(간격, 아마도?) 때문인지 아니면 seaborn에 본질적인 문제가 있는지 모르겠습니다.

데이터 세트에서 기능을 제거하지 않고도 문제를 해결할 수 있습니까?

다음은 MWE입니다. 그리고 미리 감사드립니다!

from __future__ import absolute_import,division,print_function,unicode_literals
import numpy as np 
import pandas as pd
import matplotlib
import matplotlib.pyplot as plt
from matplotlib import rc, font_manager
%matplotlib inline

from IPython.display import clear_output
from six.moves import urllib
import tensorflow.compat.v2.feature_column as fc 
import tensorflow as tf 
import seaborn as sns

rc('text', usetex=True)
matplotlib.rcParams['text.latex.preamble'] = [r'\usepackage{amsmath}']

# only if needed
#!apt install texlive-fonts-recommended texlive-fonts-extra cm-super dvipng
plt.rc('font', family='serif')

# URL address of data
TRAIN_DATA_URL = "https://storage.googleapis.com/tf-datasets/titanic/train.csv"

# Downloading data
train_file_path = tf.keras.utils.get_file("train.csv", TRAIN_DATA_URL)

# Setting numpy default values.
np.set_printoptions(precision=3, suppress=True)

# Reading data
data_train = pd.read_csv(train_file_path)

print("\n TRAIN DATA SET")
print(data_train.head(),"\n")

def heatMap(df):
    #Create Correlation df
    corr = df.corr()
    #Plot figsize
    fig, ax = plt.subplots(figsize=(10, 10))
    #Generate Color Map
    colormap = sns.diverging_palette(220, 10, as_cmap=True)
    #Generate Heat Map, allow annotations and place floats in map
    sns.heatmap(corr, cmap=colormap, annot=True, fmt=".2f")
    #Apply xticks
    plt.xticks(range(len(corr.columns)), corr.columns);
    #Apply yticks
    plt.yticks(range(len(corr.columns)), corr.columns)
    #show plot
    plt.show()

heatMap(data_train)

다음은 heatMap 기능을 실행하려고 할 때 발생하는 문제입니다(저는 Colab에서 일하고 있습니다. 그러나 이것은 콘솔에서도 발생합니다).

---------------------------------------------------------------------------
CalledProcessError                        Traceback (most recent call last)
/usr/local/lib/python3.7/dist-packages/matplotlib/texmanager.py in _run_checked_subprocess(self, command, tex)
    305                                              cwd=self.texcache,
--> 306                                              stderr=subprocess.STDOUT)
    307         except FileNotFoundError as exc:

22 frames
CalledProcessError: Command '['latex', '-interaction=nonstopmode', '--halt-on-error', '/root/.cache/matplotlib/tex.cache/bf616eae1512bede263889c8e1d8fb21.tex']' returned non-zero exit status 1.

The above exception was the direct cause of the following exception:

RuntimeError                              Traceback (most recent call last)
/usr/local/lib/python3.7/dist-packages/matplotlib/texmanager.py in _run_checked_subprocess(self, command, tex)
    317                     prog=command[0],
    318                     tex=tex.encode('unicode_escape'),
--> 319                     exc=exc.output.decode('utf-8'))) from exc
    320         _log.debug(report)
    321         return report

RuntimeError: latex was not able to process the following string:
b'n_siblings_spouses'

Here is the full report generated by latex:
This is pdfTeX, Version 3.14159265-2.6-1.40.18 (TeX Live 2017/Debian) (preloaded format=latex)
 restricted \write18 enabled.
entering extended mode
(/root/.cache/matplotlib/tex.cache/bf616eae1512bede263889c8e1d8fb21.tex
LaTeX2e <2017-04-15>
Babel <3.18> and hyphenation patterns for 3 language(s) loaded.
(/usr/share/texlive/texmf-dist/tex/latex/base/article.cls
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
(/usr/share/texlive/texmf-dist/tex/latex/base/size10.clo))
(/usr/share/texlive/texmf-dist/tex/latex/type1cm/type1cm.sty)
(/usr/share/texmf/tex/latex/cm-super/type1ec.sty
(/usr/share/texlive/texmf-dist/tex/latex/base/t1cmr.fd))
(/usr/share/texlive/texmf-dist/tex/latex/base/textcomp.sty
(/usr/share/texlive/texmf-dist/tex/latex/base/ts1enc.def))
(/usr/share/texlive/texmf-dist/tex/latex/base/inputenc.sty
(/usr/share/texlive/texmf-dist/tex/latex/base/utf8.def
(/usr/share/texlive/texmf-dist/tex/latex/base/t1enc.dfu)
(/usr/share/texlive/texmf-dist/tex/latex/base/ot1enc.dfu)
(/usr/share/texlive/texmf-dist/tex/latex/base/omsenc.dfu)
(/usr/share/texlive/texmf-dist/tex/latex/base/ts1enc.dfu)))
(/usr/share/texlive/texmf-dist/tex/latex/geometry/geometry.sty
(/usr/share/texlive/texmf-dist/tex/latex/graphics/keyval.sty)
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifpdf.sty)
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifvtex.sty)
(/usr/share/texlive/texmf-dist/tex/generic/ifxetex/ifxetex.sty)

Package geometry Warning: Over-specification in `h'-direction.
    `width' (5058.9pt) is ignored.


Package geometry Warning: Over-specification in `v'-direction.
    `height' (5058.9pt) is ignored.

) (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsmath.sty
For additional information on amsmath, use the `?' option.
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amstext.sty
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsgen.sty))
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsbsy.sty)
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsopn.sty))
(./bf616eae1512bede263889c8e1d8fb21.aux)
(/usr/share/texlive/texmf-dist/tex/latex/base/ts1cmr.fd)
*geometry* driver: auto-detecting
*geometry* detected driver: dvips
! Missing $ inserted.
<inserted text> 
                $
l.19 {\rmfamily n_
                  siblings_spouses}
No pages of output.
Transcript written on bf616eae1512bede263889c8e1d8fb21.log.


---------------------------------------------------------------------------
CalledProcessError                        Traceback (most recent call last)
/usr/local/lib/python3.7/dist-packages/matplotlib/texmanager.py in _run_checked_subprocess(self, command, tex)
    305                                              cwd=self.texcache,
--> 306                                              stderr=subprocess.STDOUT)
    307         except FileNotFoundError as exc:

21 frames
CalledProcessError: Command '['latex', '-interaction=nonstopmode', '--halt-on-error', '/root/.cache/matplotlib/tex.cache/bf616eae1512bede263889c8e1d8fb21.tex']' returned non-zero exit status 1.

The above exception was the direct cause of the following exception:

RuntimeError                              Traceback (most recent call last)
/usr/local/lib/python3.7/dist-packages/matplotlib/texmanager.py in _run_checked_subprocess(self, command, tex)
    317                     prog=command[0],
    318                     tex=tex.encode('unicode_escape'),
--> 319                     exc=exc.output.decode('utf-8'))) from exc
    320         _log.debug(report)
    321         return report

RuntimeError: latex was not able to process the following string:
b'n_siblings_spouses'

Here is the full report generated by latex:
This is pdfTeX, Version 3.14159265-2.6-1.40.18 (TeX Live 2017/Debian) (preloaded format=latex)
 restricted \write18 enabled.
entering extended mode
(/root/.cache/matplotlib/tex.cache/bf616eae1512bede263889c8e1d8fb21.tex
LaTeX2e <2017-04-15>
Babel <3.18> and hyphenation patterns for 3 language(s) loaded.
(/usr/share/texlive/texmf-dist/tex/latex/base/article.cls
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
(/usr/share/texlive/texmf-dist/tex/latex/base/size10.clo))
(/usr/share/texlive/texmf-dist/tex/latex/type1cm/type1cm.sty)
(/usr/share/texmf/tex/latex/cm-super/type1ec.sty
(/usr/share/texlive/texmf-dist/tex/latex/base/t1cmr.fd))
(/usr/share/texlive/texmf-dist/tex/latex/base/textcomp.sty
(/usr/share/texlive/texmf-dist/tex/latex/base/ts1enc.def))
(/usr/share/texlive/texmf-dist/tex/latex/base/inputenc.sty
(/usr/share/texlive/texmf-dist/tex/latex/base/utf8.def
(/usr/share/texlive/texmf-dist/tex/latex/base/t1enc.dfu)
(/usr/share/texlive/texmf-dist/tex/latex/base/ot1enc.dfu)
(/usr/share/texlive/texmf-dist/tex/latex/base/omsenc.dfu)
(/usr/share/texlive/texmf-dist/tex/latex/base/ts1enc.dfu)))
(/usr/share/texlive/texmf-dist/tex/latex/geometry/geometry.sty
(/usr/share/texlive/texmf-dist/tex/latex/graphics/keyval.sty)
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifpdf.sty)
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifvtex.sty)
(/usr/share/texlive/texmf-dist/tex/generic/ifxetex/ifxetex.sty)

Package geometry Warning: Over-specification in `h'-direction.
    `width' (5058.9pt) is ignored.


Package geometry Warning: Over-specification in `v'-direction.
    `height' (5058.9pt) is ignored.

) (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsmath.sty
For additional information on amsmath, use the `?' option.
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amstext.sty
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsgen.sty))
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsbsy.sty)
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsopn.sty))
(./bf616eae1512bede263889c8e1d8fb21.aux)
(/usr/share/texlive/texmf-dist/tex/latex/base/ts1cmr.fd)
*geometry* driver: auto-detecting
*geometry* detected driver: dvips
! Missing $ inserted.
<inserted text> 
                $
l.19 {\rmfamily n_
                  siblings_spouses}
No pages of output.
Transcript written on bf616eae1512bede263889c8e1d8fb21.log.


<Figure size 720x720 with 2 Axes>
초심자

이 문제를 해결하기 위해 Colab에 Tex 관련 모듈이 필요하다는 정보 를 접했습니다. SO 에 대한 훌륭한 답변도 있었습니다 .

다음을 설치해야 합니다.

  • ! sudo apt-get 설치 texlive-latex-recommended
  • ! sudo apt-get install dvipng texlive-fonts-recommended
  • ! wget http://mirrors.ctan.org/macros/latex/contrib/type1cm.zip
  • ! 압축 해제 type1cm.zip -d /tmp/type1cm
  • ! cd /tmp/type1cm/type1cm/ && sudo 라텍스 type1cm.ins
  • ! sudo mkdir /usr/share/texmf/tex/라텍스/type1cm
  • ! sudo cp /tmp/type1cm/type1cm/type1cm.sty /usr/share/texmf/tex/라텍스/type1cm
  • ! sudo texash
  • ! sudo apt install cm-super
from __future__ import absolute_import,division,print_function,unicode_literals
import numpy as np 
import pandas as pd
import matplotlib
import matplotlib.pyplot as plt
# from matplotlib import rc, font_manager
%matplotlib inline

from IPython.display import clear_output
from six.moves import urllib
import tensorflow.compat.v2.feature_column as fc 
import tensorflow as tf 
import seaborn as sns

# rc('text', usetex=True)
# matplotlib.rcParams['text.latex.preamble'] = [r'\usepackage{amsmath}']

# only if needed
#!apt install texlive-fonts-recommended texlive-fonts-extra cm-super dvipng
# plt.rc('font', family='serif')

# URL address of data
TRAIN_DATA_URL = "https://storage.googleapis.com/tf-datasets/titanic/train.csv"

# Downloading data
train_file_path = tf.keras.utils.get_file("/content/sample_data/train.csv", TRAIN_DATA_URL)

# Setting numpy default values.
np.set_printoptions(precision=3, suppress=True)

# Reading data
data_train = pd.read_csv(train_file_path)

print("\n TRAIN DATA SET")
print(data_train.head(),"\n")

def heatMap(df):
    #Create Correlation df
    corr = df.corr()
    print(corr)
    #Plot figsize
    fig, ax = plt.subplots(figsize=(10, 10))
    #Generate Color Map
    colormap = sns.diverging_palette(220, 10, as_cmap=True)
    #Generate Heat Map, allow annotations and place floats in map
    sns.heatmap(corr, cmap=colormap, annot=True, fmt=".2f")
    #Apply xticks
    plt.xticks(range(len(corr.columns)), corr.columns);
    #Apply yticks
    plt.yticks(range(len(corr.columns)), corr.columns)
    #show plot
    plt.show()

heatMap(data_train)

여기에 이미지 설명 입력

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

팬더 데이터 프레임을 사용한 seaborn 히트 맵

프리 플라이트 요청에 대한 응답이 액세스 제어 확인을 통과하지 못함

특정 값이 지정된 Seaborn 히트 맵 xticks 주문

ggplot 히트 맵이 타일을 채우지 못함

2D 포인트 세트에 대한 특정 쿼리를 지원하는 데이터 구조

ChartJS에서 특정 데이터 세트에 대한 툴팁을 비활성화하는 방법

Seaborn 조인트 플롯을 다른 데이터 세트의 "한계"(분포 히스토그램)로 오버레이하는 방법

특정 데이터 세트에서 이상한 y 축을 생성하는 matplotlib?

MS COCO 스타일 데이터 세트에 대한 일반 로더 기능

데이터 세트의 각 변수에 대한 seaborn.boxplot

문자열 구걸이 특정 값에 대한 데이터 세트에 두 번 이상 나타나지 않는 경우에만 문자열 행 유지

각 행에 대해 전체 데이터 세트의 특정 값 개수를 포함하는 열

CDO를 사용하여 특정 지역에 대한 데이터 세트 만 추출

Seaborn으로 히트 맵 플롯을 생성 할 때 데이터 프레임 피벗 문제

Karate-csv 파일의 특정 데이터 세트에 대해 테스트를 실행하는 기능

Vega-Lite-여러 데이터 세트에 대한 하나의 플롯

R : 대규모 데이터 세트의 특정 문자를 포함하는 열에 대한 비 NA 값의 수를 합산하는 함수 또는 유사

마우스 클릭 데이터에 대한 히트 맵과 같은 플롯

대규모 데이터 세트에 대한 플롯 라인 서식 지정

코어 플롯-방대한 데이터 세트를 플롯하기 위해 플롯 영역의 픽셀 크기 결정

한 데이터 세트의 특정 값 범위가 다른 데이터 세트에 있는지 확인

특정 세부 데이터 세트에 대한 세부 정보 계산

대용량 데이터가 포함 된 지리 히트 맵 (Google)

트리의 특정 위치에 대한 새 데이터 포함

타이타닉 데이터 세트에서 나이에 대한 Nan 값 예측

Seaborn Facetgrid의 히트 맵에서 이동하는 플롯

타이타닉 데이터 세트 가져 오기

lubridate 및 dyplr을 사용하여 특정 날짜에 대한 데이터 세트 필터링

Seaborn 히트맵, 데이터 프레임에서 x, y 축을 지정하는 방법

TOP 리스트

  1. 1

    JSoup javax.net.ssl.SSLHandshakeException : <url>과 일치하는 주체 대체 DNS 이름이 없습니다.

  2. 2

    상황에 맞는 메뉴 색상

  3. 3

    java.lang.UnsatisfiedLinkError : 지정된 모듈을 찾을 수 없습니다

  4. 4

    SMTPException : 전송 연결에서 데이터를 읽을 수 없음 : net_io_connectionclosed

  5. 5

    std :: regex의 일관성없는 동작

  6. 6

    Ionic 2 로더가 적시에 표시되지 않음

  7. 7

    JNDI를 사용하여 Spring Boot에서 다중 데이터 소스 구성

  8. 8

    정점 셰이더에서 카메라에서 개체까지의 XY 거리

  9. 9

    Xcode10 유효성 검사 : 이미지에 투명성이 없지만 여전히 수락되지 않습니까?

  10. 10

    Android Kotlin은 다른 활동에서 함수를 호출합니다.

  11. 11

    SQL Server-현명한 데이터 문제 받기

  12. 12

    Windows cmd를 통해 Anaconda 환경에서 Python 스크립트 실행

  13. 13

    rclone으로 원격 디렉토리의 모든 파일을 삭제하는 방법은 무엇입니까?

  14. 14

    내 페이지 번호의 서식을 어떻게 지정합니까?

  15. 15

    Cassandra에서 버전이 지정된 계층의 효율적인 모델링

  16. 16

    Quickly 프로그램과 함께 작동하도록 Eclipse를 어떻게 설정할 수 있습니까?

  17. 17

    인코더없이 Azure 미디어 서비스 비디오 트림

  18. 18

    WSL 및 Ubuntu, 초기화 파일 이동 방법

  19. 19

    OpenCV에서. C ++ 컴파일러는 간단한 테스트 프로그램을 컴파일 할 수 없습니다. Clang ++ 사용

  20. 20

    마우스 휠 JQuery 이벤트 핸들러에 대한 방향 가져 오기

  21. 21

    ViewModel에서 UI 요소를 비동 시적으로 업데이트하는 방법

뜨겁다태그

보관