269 lines
160 KiB
Plaintext
269 lines
160 KiB
Plaintext
|
{
|
||
|
"cells": [
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 23,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAABKAAAAGACAYAAACazRotAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy80BEi2AAAACXBIWXMAAA9hAAAPYQGoP6dpAACEzElEQVR4nOzde1xUdf7H8ddwUy6iCHgjFdfAuxXqlma5mmWZlWJlW1m6bpRWm5vbrps/y2q9tLtZluWlNa3MsvWSZSZewworUUoR74U3QAFFQYbbML8/aGYZuQgMw3jo/Xw8ejic8/2e7+ecvgzDh+/FZLVarYiIiIiIiIiIiLiIh7sDEBERERERERGRhk0JKBERERERERERcSkloERERERERERExKWUgBIREREREREREZdSAkpERERERERERFxKCSgREREREREREXEpJaBERERERERERMSllIASERERERERERGX8nJ3AFJziYmJWK1WvL293R2KiIiIiIiIiPxKFRUVYTKZuOaaay5ZViOgDMhqtWK1Wt0dRq1ZrVYKCwsNfQ8ilVH/loZOfVwaMvVvacjUv6WhUx93j5rkJzQCyoBsI5969Ojh5khqJy8vj3379nHllVfi5+fn7nBE6pT6tzR06uPSkKl/S0Om/i0Nnfq4e+zZs6faZTUCSkREREREREREXMowI6BOnDjBTTfdVK2yS5cupU+fPg7H4uPjWbx4Mbt378ZsNtOmTRuGDBlCTEwM/v7+lV7r6NGjzJs3j/j4eM6cOUPz5s3p168fjz/+OG3btq20Xm5uLgsXLiQ2Npa0tDR8fX256qqrGDt2LH379q3eTYuIiIiIiIiINACGSUD5+fkxYsSISs8fPnyYPXv24O/vT7du3RzOLVmyhJkzZ2IymejduzfBwcHs3LmT+fPnExsby7Jly2jevHm5a+7cuZNx48ZhNpuJiIigV69eHDp0iNWrVxMbG8vixY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BAHDx7Ez8+POXPm2JNLZb300kscOXKE+Ph4Bg8eTO/evcnKymLHjh1YrVamTJlS4bpSrma1WsnJyaFp06ZalE2kngQFBXHhwgWys7MJCgrSKCgREREREflVMuQCPLbFx4cNG0ajRo0uWX7MmDEsXryY/v37c/DgQTZv3oy/vz+PPvooK1asqHRUQq9evVizZg3Dhw8nOzubDRs2kJ2dzfDhw1mzZg1XX311hfWCg4NZuXIlMTEx+Pv7s3nzZg4ePEj//v1ZsmQJDz30UK3v3RlFRUUUFRU5tfueiNRc06ZNKSgo0F/WRURERETkV8uQI6Dmz59f4zr9+vWjX79+Na7Xvn17Xn755RrXCwgIYNKkSUyaNKnGdV3Fttudpr2J1C8vr9K3WovF4pa130RERERERNzNkAkocY6mAInUL33PiYiIiIi4Xnp6Ovn5+YZbciYkJIR27dq5OwyXUwJKRERERERERAzt+PHjjLx7JAX5Be4OpcZ8/XzZv29/g09CKQElIiIiIiIiIoaWmZlJQX4Bd/7tTlr9ppW7w6m2jKMZrJ6xmszMTCWgRERERERERESMIKRdCK0jW7s7DKmAIXfBExERERERERER41ACSkREREREREREXEpT8ETqSWFhIRs2bGDbtm3s3r2bs2fPkpubS0BAAGFhYfTo0YMhQ4Zw3XXX4eGh3LCIiIiIiIg0HEpASaWOHTtGZmZmnV/XYrFQWFiIj48Pnp6edX796qjvbS43bNjArFmzOHnyZLlz2dnZZGdns3fvXj766CPCw8P5+9//zu9+97t6i8/IOnXqBMATTzzBk08+6eZoREREREREpCJKQEmFjh07RucunTHnmd0dikvU5zaXb775Jq+//rr
|
||
|
"text/plain": [
|
||
|
"<Figure size 1200x400 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"import pandas as pd\n",
|
||
|
"import matplotlib.pyplot as plt\n",
|
||
|
"import seaborn as sns\n",
|
||
|
"import numpy as np\n",
|
||
|
"\n",
|
||
|
"# 그룹 번호 리스트 설정 (1부터 5까지)\n",
|
||
|
"group_numbers = range(1, 6)\n",
|
||
|
"\n",
|
||
|
"# 빈 데이터프레임 생성\n",
|
||
|
"combined_data = pd.DataFrame()\n",
|
||
|
"\n",
|
||
|
"# 그룹별 CSV 파일 읽고 데이터 합치기\n",
|
||
|
"for group_number in group_numbers:\n",
|
||
|
" file_path = f'0.class_document/knn_tfidf/{group_number}/test_p_c.csv'\n",
|
||
|
" data = pd.read_csv(file_path)\n",
|
||
|
" combined_data = pd.concat([combined_data, data], ignore_index=True)\n",
|
||
|
"\n",
|
||
|
"# p_MDM이 True인 항목 필터링\n",
|
||
|
"filtered_data = combined_data\n",
|
||
|
"\n",
|
||
|
"# ctp_correct가 True인 경우와 False인 경우의 c_score 추출\n",
|
||
|
"correct_scores = filtered_data[filtered_data['ctp_correct'] == True]['c_score']\n",
|
||
|
"incorrect_scores = filtered_data[filtered_data['ctp_correct'] == False]['c_score']\n",
|
||
|
"\n",
|
||
|
"# 시각화 스타일 설정\n",
|
||
|
"sns.set(style=\"whitegrid\")\n",
|
||
|
"\n",
|
||
|
"# 0.0에서 1.0까지 0.2 간격으로 bin을 설정\n",
|
||
|
"bins = np.arange(0, 1.1, 0.05)\n",
|
||
|
"\n",
|
||
|
"# 플롯 크기 설정\n",
|
||
|
"plt.figure(figsize=(12, 4))\n",
|
||
|
"\n",
|
||
|
"# alpha 값을 낮추고, 두 분포가 겹치도록 설정\n",
|
||
|
"# Correct: 초록색, Incorrect: 빨간색, 테두리 추가\n",
|
||
|
"sns.histplot(correct_scores, bins=bins, kde=False, color='green', alpha=0.5, label='Correct', edgecolor='black')\n",
|
||
|
"sns.histplot(incorrect_scores, bins=bins, kde=False, color='red', alpha=0.5, label='Incorrect', edgecolor='black')\n",
|
||
|
"\n",
|
||
|
"# 그래프 꾸미기\n",
|
||
|
"plt.xlabel('Score', fontsize=18)\n",
|
||
|
"plt.ylabel('Frequency', fontsize=18)\n",
|
||
|
"plt.xticks(fontsize=16)\n",
|
||
|
"plt.yticks(fontsize=16)\n",
|
||
|
"\n",
|
||
|
"# 범례 폰트 크기를 키우고 위치 설정\n",
|
||
|
"plt.legend(fontsize=20, loc='upper left')\n",
|
||
|
"\n",
|
||
|
"# 레이아웃 조정 및 출력\n",
|
||
|
"plt.tight_layout()\n",
|
||
|
"plt.show()\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 25,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAABKAAAAGACAYAAACazRotAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy80BEi2AAAACXBIWXMAAA9hAAAPYQGoP6dpAAB2IUlEQVR4nO3de1jUZf7/8dcMBwEBRcATaboKisdE3dRM10PampbSlq5l2Vq0miW/tXYr17JaD+1Wamt5aM1Ks2w9ZJmFx7TCTNRUwHPiGQUUFRlggPn94c58mTgIDsMw+HxcV1cw931/7vfn0z3EvLkPBovFYhEAAAAAAADgJEZXBwAAAAAAAICajQQUAAAAAAAAnIoEFAAAAAAAAJyKBBQAAAAAAACcigQUAAAAAAAAnIoEFAAAAAAAAJyKBBQAAAAAAACcigQUAAAAAAAAnMrT1QGg6uzevVsWi0VeXl6uDgUAAAAAALg5s9ksg8GgTp06XbcuM6BuIhaLRRaLxdVh3DCLxaK8vDy3vgegKMY0aiLGNWoixjVqIsY1aiLGddWrSJ6BGVA3EevMp/bt27s4khuTnZ2t/fv3q2XLlvLz83N1OIDDGNOoiRjXqIkY16iJGNeoiRjXVW/fvn3lrssMKAAAAAAAADgVCSgAAAAAAAA4FQkoAAAAAAAAOBUJKAAAAAAAADgVCSgAAAAAAAA4FQkoAAAAAAAAOBUJKAAAAAAAADgVCSgAAAAAAAA4FQkoAAAAAAAAOBUJKAAAAAAAADgVCSgAAAAAAAA4laer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KHWrVvr+eefr3DdopKSkvTSSy9p4MCB6tSpk2677TYNHDhQL7/8so4dO1auez906JBee+01DRkyRF27dlXbtm11xx13aPTo0Xrvvfd0/vx5W92+ffva9n+SpDlz5tjitv5TUpwAAAAAgBvnNjOgKiovL09btmyRJA0ePLhYeVhYmKKiopSQkKANGzbYfcjfsGGDJOmee+4plugyGo0aNGiQ3n33Xa1fv14jRoywla1fv16SFBUVpbCwsGJ9Dh48WMuXL9fmzZtlNpvl5eUlSdq9e7fS0tLk7e2tgQMHFms3cOBATZo0SefPn9eePXvUqVOnij4OuAmLxaJVq1ZJujb76YEHHnDoeoWFhfrHP/6hjz/+2O71vLw87d+/X/v379fHH3+s2bNn64477ijzWrm5uRozZozi4+Ov22956hYWFur111/Xhx9+KIvFYleWkpKilJQULV++XC+99JKGDx9e4jUKCgr0z3/+s8RrpKenKz09Xdu2bdPRo0c1Y8aM68YNAAAAAHCOGpuASklJsc0iadeuXYl12rVrp4SEBCUnJ9u9bv2+rHZF61nt37+/zHbt27eXJGVnZ+v48eNq2bKlXbvw8HDVqlWrWDsfHx+Fh4crOTlZycnJJKBqsMOHD+vixYuSpM6dO8vf39+h673xxhu25NMtt9yiJ554Qm3atJHJZNKmTZv08ccf68qVK3ryySe1fPnyYktDf32tgwcPqm/fvoqOjlbjxo2Vnp6uq1ev3lDd1157TUuXLpUkde3aVcOGDVOTJk3k4+OjgwcP6sMPP9Thw4f10ksvKSQkRP369SvWz+TJk7VixQpJUmhoqB5++GF16tRJAQEBunDhgvbu3au4uDi7NgsXLpTZbNaQIUMkSX/84x81cuRIuzp16tQpz+MFAAAAAJRTjU1AnTp1SpIUGBhY6of4Ro0a2dWVrp1gl5mZKUlq3Lhxme0uXLig7Oxs+fn52V3HWv5r/v7+8vf3V1ZWlk6dOmVLQF2vnSQ1bNhQycnJdrGi5jlw4IDt67Zt2zp0rYMHD2rRokWSru0R9fH
|
||
|
"text/plain": [
|
||
|
"<Figure size 1200x400 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"import pandas as pd\n",
|
||
|
"import matplotlib.pyplot as plt\n",
|
||
|
"import seaborn as sns\n",
|
||
|
"import numpy as np\n",
|
||
|
"\n",
|
||
|
"# 그룹 번호 리스트 설정 (1부터 5까지)\n",
|
||
|
"group_numbers = range(1, 6)\n",
|
||
|
"\n",
|
||
|
"# 빈 데이터프레임 생성\n",
|
||
|
"combined_data = pd.DataFrame()\n",
|
||
|
"\n",
|
||
|
"# 그룹별 CSV 파일 읽고 데이터 합치기\n",
|
||
|
"for group_number in group_numbers:\n",
|
||
|
" file_path = f'0.class_document/distilbert/{group_number}/test_p_c.csv'\n",
|
||
|
" data = pd.read_csv(file_path)\n",
|
||
|
" combined_data = pd.concat([combined_data, data], ignore_index=True)\n",
|
||
|
"\n",
|
||
|
"# p_MDM이 True인 항목 필터링\n",
|
||
|
"filtered_data = combined_data\n",
|
||
|
"\n",
|
||
|
"# ctp_correct가 True인 경우와 False인 경우의 c_score 추출\n",
|
||
|
"correct_scores = filtered_data[filtered_data['ctp_correct'] == True]['c_score']\n",
|
||
|
"incorrect_scores = filtered_data[filtered_data['ctp_correct'] == False]['c_score']\n",
|
||
|
"\n",
|
||
|
"# 시각화 스타일 설정\n",
|
||
|
"sns.set(style=\"whitegrid\")\n",
|
||
|
"\n",
|
||
|
"# 0.0에서 1.0까지 0.2 간격으로 bin을 설정\n",
|
||
|
"bins = np.arange(0, 1.1, 0.05)\n",
|
||
|
"\n",
|
||
|
"# 플롯 크기 설정\n",
|
||
|
"plt.figure(figsize=(12, 4))\n",
|
||
|
"\n",
|
||
|
"# alpha 값을 낮추고, 두 분포가 겹치도록 설정\n",
|
||
|
"# Correct: 초록색, Incorrect: 빨간색, 테두리 추가\n",
|
||
|
"sns.histplot(correct_scores, bins=bins, kde=False, color='green', alpha=0.5, label='Correct', edgecolor='black')\n",
|
||
|
"sns.histplot(incorrect_scores, bins=bins, kde=False, color='red', alpha=0.5, label='Incorrect', edgecolor='black')\n",
|
||
|
"\n",
|
||
|
"# 그래프 꾸미기\n",
|
||
|
"plt.xlabel('Score', fontsize=18)\n",
|
||
|
"plt.ylabel('Frequency', fontsize=18)\n",
|
||
|
"plt.xticks(fontsize=16)\n",
|
||
|
"plt.yticks(fontsize=16)\n",
|
||
|
"\n",
|
||
|
"# 범례 폰트 크기를 키우고 위치 설정\n",
|
||
|
"plt.legend(fontsize=20, loc='upper left')\n",
|
||
|
"\n",
|
||
|
"# 레이아웃 조정 및 출력\n",
|
||
|
"plt.tight_layout()\n",
|
||
|
"plt.show()\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 2,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAABKAAAAKsCAYAAADbS8X9AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy80BEi2AAAACXBIWXMAAA9hAAAPYQGoP6dpAADEsklEQVR4nOzdeXxU9b3/8fckM1kmG2SBRCCigiCLS8CKVqUirYhglatSFST1VyhSWuxtrdrSIrWo9161Uq1FtFYBUdsr7qKCIlUBlUUJq4hECQRIJntmn8zvD25iYvbMnBwm83o+Hj6Ic77nez5zvpnMmfec8z2WYDAYFAAAAAAAAGCQGLMLAAAAAAAAQM9GAAUAAAAAAABDEUABAAAAAADAUARQAAAAAAAAMBQBFAAAAAAAAAxFAAUAAAAAAABDEUABAAAAAADAUARQAAAAAAAAMJTV7AJ6sm3btikYDMpms5ldCgAAAAAAiHA+n08Wi0XnnHOO2aV0GmdAGSgYDCoYDJpdRo8RDAbl9XrZpyZiDMzHGJiL/W8+xsBc7H/zMQbmYwzMxf43H2NgrkjOGTgDykD1Zz6NHDnS5Ep6BqfTqd27d2v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/4HIFb3nLAIAAAAAAKBbEEABAAAAAADAUARQAAAAAAAAMBQBFAAAAAAAAAxFAAUAAAAAAABDEUABAAAAAADAUARQAAAAAAAAMBQBFAAAAAAAAAxFAAUAAAAAAABDEUABAAAAAADAUARQAAAAAAAAMBQBFAAAAAAAAAx
|
||
|
"text/plain": [
|
||
|
"<Figure size 1200x700 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"import pandas as pd\n",
|
||
|
"import matplotlib.pyplot as plt\n",
|
||
|
"import seaborn as sns\n",
|
||
|
"import numpy as np\n",
|
||
|
"\n",
|
||
|
"# 그룹 번호 리스트 설정 (1부터 5까지)\n",
|
||
|
"group_numbers = range(1, 6)\n",
|
||
|
"\n",
|
||
|
"# 빈 데이터프레임 생성 (TF-IDF와 DistilBERT)\n",
|
||
|
"combined_data_tfidf = pd.DataFrame()\n",
|
||
|
"combined_data_bert = pd.DataFrame()\n",
|
||
|
"\n",
|
||
|
"# TF-IDF 데이터 읽기\n",
|
||
|
"for group_number in group_numbers:\n",
|
||
|
" file_path_tfidf = f'0.class_document/knn_tfidf/{group_number}/test_p_c.csv'\n",
|
||
|
" data_tfidf = pd.read_csv(file_path_tfidf)\n",
|
||
|
" combined_data_tfidf = pd.concat([combined_data_tfidf, data_tfidf], ignore_index=True)\n",
|
||
|
"\n",
|
||
|
"# DistilBERT 데이터 읽기\n",
|
||
|
"for group_number in group_numbers:\n",
|
||
|
" file_path_bert = f'0.class_document/distilbert/{group_number}/test_p_c.csv'\n",
|
||
|
" data_bert = pd.read_csv(file_path_bert)\n",
|
||
|
" combined_data_bert = pd.concat([combined_data_bert, data_bert], ignore_index=True)\n",
|
||
|
"\n",
|
||
|
"# 데이터 필터링 및 점수 추출\n",
|
||
|
"filtered_data_tfidf = combined_data_tfidf\n",
|
||
|
"filtered_data_bert = combined_data_bert\n",
|
||
|
"\n",
|
||
|
"correct_scores_tfidf = filtered_data_tfidf[filtered_data_tfidf['ctp_correct'] == True]['c_score']\n",
|
||
|
"incorrect_scores_tfidf = filtered_data_tfidf[filtered_data_tfidf['ctp_correct'] == False]['c_score']\n",
|
||
|
"\n",
|
||
|
"correct_scores_bert = filtered_data_bert[filtered_data_bert['ctp_correct'] == True]['c_score']\n",
|
||
|
"incorrect_scores_bert = filtered_data_bert[filtered_data_bert['ctp_correct'] == False]['c_score']\n",
|
||
|
"\n",
|
||
|
"# 시각화 스타일 설정\n",
|
||
|
"sns.set(style=\"whitegrid\")\n",
|
||
|
"\n",
|
||
|
"# 0.0에서 1.0까지 0.05 간격으로 bin을 설정\n",
|
||
|
"bins = np.arange(0, 1.05, 0.05)\n",
|
||
|
"\n",
|
||
|
"# TF-IDF와 DistilBERT 점수 분포 계산\n",
|
||
|
"tfidf_correct_hist, _ = np.histogram(correct_scores_tfidf, bins=bins)\n",
|
||
|
"tfidf_incorrect_hist, _ = np.histogram(incorrect_scores_tfidf, bins=bins)\n",
|
||
|
"\n",
|
||
|
"bert_correct_hist, _ = np.histogram(correct_scores_bert, bins=bins)\n",
|
||
|
"bert_incorrect_hist, _ = np.histogram(incorrect_scores_bert, bins=bins)\n",
|
||
|
"\n",
|
||
|
"# 나비 차트 그리기\n",
|
||
|
"fig, ax = plt.subplots(figsize=(12, 7))\n",
|
||
|
"\n",
|
||
|
"bin_centers = 0.5 * (bins[1:] + bins[:-1])\n",
|
||
|
"\n",
|
||
|
"# 왼쪽: DistilBERT 점수 분포\n",
|
||
|
"ax.barh(bin_centers, -bert_correct_hist, height=0.05, color='green', alpha=0.7, label='DistilBERT Correct', edgecolor='black')\n",
|
||
|
"ax.barh(bin_centers, -bert_incorrect_hist, height=0.05, color='red', alpha=0.4, label='DistilBERT Incorrect', edgecolor='black')\n",
|
||
|
"\n",
|
||
|
"# 오른쪽: TF-IDF 점수 분포\n",
|
||
|
"ax.barh(bin_centers, tfidf_correct_hist, height=0.05, color='green', alpha=0.7, label='TF-IDF Correct', edgecolor='black', left=0)\n",
|
||
|
"ax.barh(bin_centers, tfidf_incorrect_hist, height=0.05, color='red', alpha=0.4, label='TF-IDF Incorrect', edgecolor='black', left=0)\n",
|
||
|
"\n",
|
||
|
"\n",
|
||
|
"ax.set_xlabel('Frequency', fontsize=18) # x축 폰트 크기를 18로 설정\n",
|
||
|
"ax.set_ylabel('Score', fontsize=18) # y축 폰트 크기를 18로 설정\n",
|
||
|
"\n",
|
||
|
"# x축과 y축의 눈금 폰트 크기 조정\n",
|
||
|
"ax.tick_params(axis='x', labelsize=16) # x축 눈금 폰트 크기를 16으로 설정\n",
|
||
|
"ax.tick_params(axis='y', labelsize=16) # y축 눈금 폰트 크기를 16으로 설정\n",
|
||
|
"\n",
|
||
|
"ax.set_yticks(np.arange(0, 1.1, 0.1))\n",
|
||
|
"# 기존의 x축 눈금을 설정한 부분을 수정\n",
|
||
|
"ax.set_xticks(np.arange(-10000, 10001, 2000)) # x축 단위를 2000으로 설정\n",
|
||
|
"\n",
|
||
|
"# 음수 눈금을 양수로 표시하도록 라벨을 변경\n",
|
||
|
"ax.set_xticklabels([str(abs(x)) for x in np.arange(-10000, 10001, 2000)])\n",
|
||
|
"\n",
|
||
|
"# 범례 폰트 크기를 키우고 위치 설정\n",
|
||
|
"# DistilBERT는 좌측 하단에, TF-IDF는 우측 하단에 범례 표시\n",
|
||
|
"legend_bert = ax.legend(['DistilBERT Correct', 'DistilBERT Incorrect'], fontsize=20, loc='lower left')\n",
|
||
|
"legend_tfidf = ax.legend(['TF-IDF Correct', 'TF-IDF Incorrect'], fontsize=20, loc='lower right')\n",
|
||
|
"\n",
|
||
|
"# 범례 두 개 모두 추가\n",
|
||
|
"ax.add_artist(legend_bert)\n",
|
||
|
"\n",
|
||
|
"# 레이아웃 조정 및 출력\n",
|
||
|
"plt.tight_layout()\n",
|
||
|
"plt.show()\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"metadata": {
|
||
|
"kernelspec": {
|
||
|
"display_name": "torch",
|
||
|
"language": "python",
|
||
|
"name": "python3"
|
||
|
},
|
||
|
"language_info": {
|
||
|
"codemirror_mode": {
|
||
|
"name": "ipython",
|
||
|
"version": 3
|
||
|
},
|
||
|
"file_extension": ".py",
|
||
|
"mimetype": "text/x-python",
|
||
|
"name": "python",
|
||
|
"nbconvert_exporter": "python",
|
||
|
"pygments_lexer": "ipython3",
|
||
|
"version": "3.10.14"
|
||
|
}
|
||
|
},
|
||
|
"nbformat": 4,
|
||
|
"nbformat_minor": 2
|
||
|
}
|