Computer >> 컴퓨터 >  >> 프로그램 작성 >> Python

Matplotlib에서 sns.clustermap에 미리 계산된 거리 행렬을 제공하는 방법은 무엇입니까?

<시간/>

sn.clustermap을 제공하려면 데이터 세트에 대해 다음 단계를 수행할 수 있습니다. -

  • 한 번에 여러 테마 매개변수를 설정합니다.

  • 온라인 리포지토리에서 예제 데이터세트를 로드합니다(인터넷 필요).

  • 항목 반환 및 드롭 프레임에서. KeyError 발생 찾을 수 없는 경우 pop() 사용 방법.

  • clustermap() 을 사용하여 계층적으로 클러스터된 히트맵으로 매트릭스 데이터세트를 플로팅합니다. 방법.

  • 그림을 표시하려면 show()를 사용하세요. 방법.

예시

from matplotlib import pyplot as plt
import seaborn as sns
plt.rcParams["figure.figsize"] = [7.00, 3.50]
plt.rcParams["figure.autolayout"] = True
sns.set_theme(color_codes=True)
iris = sns.load_dataset("iris")
species = iris.pop("species")
g = sns.clustermap(iris)
plt.show()

출력

Matplotlib에서 sns.clustermap에 미리 계산된 거리 행렬을 제공하는 방법은 무엇입니까?