<jupyter_start><jupyter_text>作業1. 請用 numpy 建立一個 10 x 10, 數值分布自 -1.0 ~ 1.0 的矩陣並繪製 Heatmap2. 請用 numpy 建立一個 1000 x 3, 數值分布為 -1.0 ~ 1.0 的矩陣，並繪製 PairPlot (上半部為 scatter, 對角線為 hist, 下半部為 density)3. 請用 numpy 建立一個 1000 x 3, 數值分布為常態分佈的矩陣，並繪製 PairPlot (上半部為 scatter, 對角線為 hist, 下半部為 density)<jupyter_code># Import 需要的套件
import os
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns # 另一個繪圖-樣式套件
plt.style.use('ggplot')

%matplotlib inline

import warnings
warnings.filterwarnings('ignore')
"""
Your Code Here
"""
ncol = 10
nrow = 10
matrix = np.random.uniform(low=-1.0, high=1.0, size=nrow*ncol).reshape(ncol, nrow)

plt.figure(figsize=(10,10))
"""
Your Code Here
"""
heatmap = sns.heatmap(data=matrix, cmap=plt.cm.Blues, annot=True, robust=True, annot_kws={'size': 10})
plt.show()
nrow = 1000
ncol = 3
"""
Your Code Here
"""
matrix = np.random.uniform(-1.0, 1.0, nrow * ncol).reshape((nrow, ncol))

indice = np.random.choice([0,1,2], size=nrow)
plot_data = pd.DataFrame(matrix, indice)


grid = sns.PairGrid(data = plot_data, size = 3, diag_sharey=False)
"""
Your Code Here
Please replace "..." to correct plot function
"""
grid.map_upper(plt.scatter, alpha = 0.2)
grid.map_diag(plt.hist)
grid.map_lower(sns.kdeplot, cmap = plt.cm.OrRd_r)

plt.show()
nrow = 1000
ncol = 3
"""
Your Code Here
"""
matrix = np.random.normal(size=nrow*ncol).reshape((nrow, ncol))

indice = np.random.choice([0,1,2], size=nrow)
plot_data = pd.DataFrame(matrix, indice)


grid = sns.PairGrid(data = plot_data, size = 3, diag_sharey=False)
"""
Your Code Here
Please replace "..." to correct plot function
"""
grid.map_upper(plt.scatter, alpha = 0.2)
grid.map_diag(plt.hist)
grid.map_lower(sns.kdeplot, cmap = plt.cm.OrRd_r)

plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.154627539503386, 'fraction_numerical': 0.03668171557562077, 'mean_word_length': 4.989864864864865, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '190461', 'license': 'MIT', 'n_tokens_mistral': 856, 'n_tokens_neox': 831, 'n_words': 175, 'path': 'Day_015_HW.ipynb', 'repo_name': 'hengbinxu/ML100-Days', 'size': '1772'}