hossam 0.4.4__py3-none-any.whl → 0.4.5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
hossam/hs_plot.py CHANGED
@@ -1,13 +1,14 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  from __future__ import annotations
3
3
  from types import SimpleNamespace
4
+ from typing import Callable
4
5
 
5
6
  # ===================================================================
6
7
  import numpy as np
7
8
  import pandas as pd
8
9
  import seaborn as sb
9
10
  import matplotlib.pyplot as plt
10
- from matplotlib.pyplot import Axes
11
+ from matplotlib.pyplot import Axes # type: ignore
11
12
  from math import sqrt
12
13
  from pandas import DataFrame
13
14
 
@@ -15,7 +16,7 @@ from pandas import DataFrame
15
16
  from scipy.stats import t
16
17
  from scipy.spatial import ConvexHull
17
18
  from statsmodels.graphics.gofplots import qqplot as sm_qqplot
18
- from statsmodels.nonparametric.smoothers_lowess import lowess
19
+ from statsmodels.nonparametric.smoothers_lowess import lowess as sm_lowess
19
20
 
20
21
  # ===================================================================
21
22
  from statannotations.Annotator import Annotator
@@ -30,9 +31,6 @@ from sklearn.metrics import (
30
31
  )
31
32
 
32
33
  # ===================================================================
33
- if pd.__version__ > "2.0.0":
34
- pd.DataFrame.iteritems = pd.DataFrame.items
35
-
36
34
  config = SimpleNamespace(
37
35
  dpi=200,
38
36
  width=600,
@@ -49,7 +47,7 @@ config = SimpleNamespace(
49
47
  # ===================================================================
50
48
  # 기본 크기가 설정된 Figure와 Axes를 생성한다
51
49
  # ===================================================================
52
- def get_default_ax(width: int = config.width, height: int = config.height, rows: int = 1, cols: int = 1, dpi: int = config.dpi, flatten: bool = False, ws: int | None = None, hs: int | None = None, title: str = None):
50
+ def get_default_ax(width: int = config.width, height: int = config.height, rows: int = 1, cols: int = 1, dpi: int = config.dpi, flatten: bool = False, ws: int | None = None, hs: int | None = None, title: str | None = None):
53
51
  """기본 크기의 Figure와 Axes를 생성한다.
54
52
 
55
53
  Args:
@@ -95,7 +93,7 @@ def get_default_ax(width: int = config.width, height: int = config.height, rows:
95
93
  for spine in a.spines.values():
96
94
  spine.set_linewidth(config.frame_width)
97
95
  else:
98
- for spine in ax.spines.values():
96
+ for spine in ax.spines.values(): # type: ignore
99
97
  spine.set_linewidth(config.frame_width)
100
98
 
101
99
  return fig, ax
@@ -104,7 +102,7 @@ def get_default_ax(width: int = config.width, height: int = config.height, rows:
104
102
  # ===================================================================
105
103
  # 기본 크기가 설정된 Figure와 Axes를 생성한다
106
104
  # ===================================================================
107
- def create_figure(width: int = config.width, height: int = config.height, rows: int = 1, cols: int = 1, dpi: int = config.dpi, flatten: bool = False, ws: int | None = None, hs: int | None = None, title: str = None):
105
+ def create_figure(width: int = config.width, height: int = config.height, rows: int = 1, cols: int = 1, dpi: int = config.dpi, flatten: bool = False, ws: int | None = None, hs: int | None = None, title: str | None = None):
108
106
  """기본 크기의 Figure와 Axes를 생성한다. get_default_ax의 래퍼 함수.
109
107
 
110
108
  Args:
@@ -128,7 +126,7 @@ def create_figure(width: int = config.width, height: int = config.height, rows:
128
126
  # ===================================================================
129
127
  # 그래프의 그리드, 레이아웃을 정리하고 필요 시 저장 또는 표시한다
130
128
  # ===================================================================
131
- def finalize_plot(ax: Axes | np.ndarray, callback: any = None, outparams: bool = False, save_path: str = None, grid: bool = True, title: str = None) -> None:
129
+ def finalize_plot(ax: Axes | np.ndarray, callback: Callable | None = None, outparams: bool = False, save_path: str | None = None, grid: bool = True, title: str | None = None) -> None:
132
130
  """공통 후처리를 수행한다: 콜백 실행, 레이아웃 정리, 필요 시 표시/종료.
133
131
 
134
132
  Args:
@@ -176,7 +174,7 @@ def finalize_plot(ax: Axes | np.ndarray, callback: any = None, outparams: bool =
176
174
  # ===================================================================
177
175
  # 그래프의 그리드, 레이아웃을 정리하고 필요 시 저장 또는 표시한다
178
176
  # ===================================================================
179
- def show_figure(ax: Axes | np.ndarray, callback: any = None, outparams: bool = False, save_path: str = None, grid: bool = True, title: str = None) -> None:
177
+ def show_figure(ax: Axes | np.ndarray, callback: Callable | None = None, outparams: bool = False, save_path: str | None = None, grid: bool = True, title: str | None = None) -> None:
180
178
  """공통 후처리를 수행한다: 콜백 실행, 레이아웃 정리, 필요 시 표시/종료.
181
179
  finalize_plot의 래퍼 함수.
182
180
 
@@ -199,19 +197,19 @@ def show_figure(ax: Axes | np.ndarray, callback: any = None, outparams: bool = F
199
197
  # ===================================================================
200
198
  def lineplot(
201
199
  df: DataFrame,
202
- xname: str = None,
203
- yname: str = None,
204
- hue: str = None,
200
+ xname: str | None = None,
201
+ yname: str | None = None,
202
+ hue: str | None = None,
205
203
  title: str | None = None,
206
- marker: str = None,
207
- palette: str = None,
204
+ marker: str | None = None,
205
+ palette: str | None = None,
208
206
  width: int = config.width,
209
207
  height: int = config.height,
210
208
  linewidth: float = config.line_width,
211
209
  dpi: int = config.dpi,
212
- save_path: str = None,
213
- callback: any = None,
214
- ax: Axes = None,
210
+ save_path: str | None = None,
211
+ callback: Callable | None = None,
212
+ ax: Axes | None = None,
215
213
  **params,
216
214
  ) -> None:
217
215
  """선 그래프를 그린다.
@@ -239,7 +237,7 @@ def lineplot(
239
237
  outparams = False
240
238
 
241
239
  if ax is None:
242
- fig, ax = get_default_ax(width, height, 1, 1, dpi)
240
+ fig, ax = get_default_ax(width, height, 1, 1, dpi) # type: ignore
243
241
  outparams = True
244
242
 
245
243
  # hue가 있을 때만 palette 사용, 없으면 color 사용
@@ -260,7 +258,7 @@ def lineplot(
260
258
  lineplot_kwargs.update(params)
261
259
 
262
260
  sb.lineplot(**lineplot_kwargs, linewidth=linewidth)
263
- finalize_plot(ax, callback, outparams, save_path, True, title)
261
+ finalize_plot(ax, callback, outparams, save_path, True, title) # type: ignore
264
262
 
265
263
 
266
264
  # ===================================================================
@@ -268,18 +266,18 @@ def lineplot(
268
266
  # ===================================================================
269
267
  def boxplot(
270
268
  df: DataFrame,
271
- xname: str = None,
272
- yname: str = None,
269
+ xname: str | None = None,
270
+ yname: str | None = None,
273
271
  title: str | None = None,
274
272
  orient: str = "v",
275
- palette: str = None,
273
+ palette: str | None = None,
276
274
  width: int = config.width,
277
275
  height: int = config.height,
278
276
  linewidth: float = config.line_width,
279
277
  dpi: int = config.dpi,
280
- save_path: str = None,
281
- callback: any = None,
282
- ax: Axes = None,
278
+ save_path: str | None = None,
279
+ callback: Callable | None = None,
280
+ ax: Axes | None = None,
283
281
  **params,
284
282
  ) -> None:
285
283
  """상자그림(boxplot)을 그린다.
@@ -306,7 +304,7 @@ def boxplot(
306
304
  outparams = False
307
305
 
308
306
  if ax is None:
309
- fig, ax = get_default_ax(width, height, 1, 1, dpi)
307
+ fig, ax = get_default_ax(width, height, 1, 1, dpi) # type: ignore
310
308
  outparams = True
311
309
 
312
310
  if xname is not None and yname is not None:
@@ -329,9 +327,9 @@ def boxplot(
329
327
  boxplot_kwargs.update(params)
330
328
  sb.boxplot(**boxplot_kwargs, linewidth=linewidth)
331
329
  else:
332
- sb.boxplot(data=df, orient=orient, ax=ax, linewidth=linewidth, **params)
330
+ sb.boxplot(data=df, orient=orient, ax=ax, linewidth=linewidth, **params) # type: ignore
333
331
 
334
- finalize_plot(ax, callback, outparams, save_path, True, title)
332
+ finalize_plot(ax, callback, outparams, save_path, True, title) # type: ignore
335
333
 
336
334
 
337
335
  # ===================================================================
@@ -339,11 +337,11 @@ def boxplot(
339
337
  # ===================================================================
340
338
  def kdeplot(
341
339
  df: DataFrame,
342
- xname: str = None,
343
- yname: str = None,
344
- hue: str = None,
340
+ xname: str | None = None,
341
+ yname: str | None = None,
342
+ hue: str | None = None,
345
343
  title: str | None = None,
346
- palette: str = None,
344
+ palette: str | None = None,
347
345
  fill: bool = False,
348
346
  fill_alpha: float = config.fill_alpha,
349
347
  linewidth: float = config.line_width,
@@ -351,9 +349,9 @@ def kdeplot(
351
349
  width: int = config.width,
352
350
  height: int = config.height,
353
351
  dpi: int = config.dpi,
354
- save_path: str = None,
355
- callback: any = None,
356
- ax: Axes = None,
352
+ save_path: str | None = None,
353
+ callback: Callable | None = None,
354
+ ax: Axes | None = None,
357
355
  **params,
358
356
  ) -> None:
359
357
  """커널 밀도 추정(KDE) 그래프를 그린다.
@@ -434,7 +432,7 @@ def kdeplot(
434
432
  return
435
433
 
436
434
  if ax is None:
437
- fig, ax = get_default_ax(width, height, 1, 1, dpi)
435
+ fig, ax = get_default_ax(width, height, 1, 1, dpi) # type: ignore
438
436
  outparams = True
439
437
 
440
438
  # 기본 kwargs 설정
@@ -464,7 +462,7 @@ def kdeplot(
464
462
 
465
463
  sb.kdeplot(**kdeplot_kwargs)
466
464
 
467
- finalize_plot(ax, callback, outparams, save_path, True, title)
465
+ finalize_plot(ax, callback, outparams, save_path, True, title) # type: ignore
468
466
 
469
467
 
470
468
  # ===================================================================
@@ -477,14 +475,14 @@ def histplot(
477
475
  title: str | None = None,
478
476
  bins: int | None = None,
479
477
  kde: bool = True,
480
- palette: str = None,
478
+ palette: str | None = None,
481
479
  width: int = config.width,
482
480
  height: int = config.height,
483
481
  linewidth: float = config.line_width,
484
482
  dpi: int = config.dpi,
485
- save_path: str = None,
486
- callback: any = None,
487
- ax: Axes = None,
483
+ save_path: str | None = None,
484
+ callback: Callable | None = None,
485
+ ax: Axes | None = None,
488
486
  **params,
489
487
  ) -> None:
490
488
  """히스토그램을 그리고 필요 시 KDE를 함께 표시한다.
@@ -511,7 +509,7 @@ def histplot(
511
509
  outparams = False
512
510
 
513
511
  if ax is None:
514
- fig, ax = get_default_ax(width, height, 1, 1, dpi)
512
+ fig, ax = get_default_ax(width, height, 1, 1, dpi) # type: ignore
515
513
  outparams = True
516
514
 
517
515
  if bins:
@@ -550,7 +548,7 @@ def histplot(
550
548
  histplot_kwargs.update(params)
551
549
  sb.histplot(**histplot_kwargs)
552
550
 
553
- finalize_plot(ax, callback, outparams, save_path, True, title)
551
+ finalize_plot(ax, callback, outparams, save_path, True, title) # type: ignore
554
552
 
555
553
 
556
554
  # ===================================================================
@@ -561,14 +559,14 @@ def stackplot(
561
559
  xname: str,
562
560
  hue: str,
563
561
  title: str | None = None,
564
- palette: str = None,
562
+ palette: str | None = None,
565
563
  width: int = config.width,
566
564
  height: int = config.height,
567
565
  linewidth: float = 0.25,
568
566
  dpi: int = config.dpi,
569
- save_path: str = None,
570
- callback: any = None,
571
- ax: Axes = None,
567
+ save_path: str | None = None,
568
+ callback: Callable | None = None,
569
+ ax: Axes | None = None,
572
570
  **params,
573
571
  ) -> None:
574
572
  """클래스 비율을 100% 누적 막대로 표현한다.
@@ -593,7 +591,7 @@ def stackplot(
593
591
  outparams = False
594
592
 
595
593
  if ax is None:
596
- fig, ax = get_default_ax(width, height, 1, 1, dpi)
594
+ fig, ax = get_default_ax(width, height, 1, 1, dpi) # type: ignore
597
595
  outparams = True
598
596
 
599
597
  df2 = df[[xname, hue]].copy()
@@ -620,11 +618,11 @@ def stackplot(
620
618
  sb.histplot(**stackplot_kwargs)
621
619
 
622
620
  # 그래프의 x축 항목 수 만큼 반복
623
- for p in ax.patches:
621
+ for p in ax.patches: # type: ignore
624
622
  # 각 막대의 위치, 넓이, 높이
625
- left, bottom, width, height = p.get_bbox().bounds
623
+ left, bottom, width, height = p.get_bbox().bounds # type: ignore
626
624
  # 막대의 중앙에 글자 표시하기
627
- ax.annotate(
625
+ ax.annotate( # type: ignore
628
626
  "%0.1f%%" % (height * 100),
629
627
  xy=(left + width / 2, bottom + height / 2),
630
628
  ha="center",
@@ -633,10 +631,10 @@ def stackplot(
633
631
 
634
632
  if str(df[xname].dtype) in ["int", "int32", "int64", "float", "float32", "float64"]:
635
633
  xticks = list(df[xname].unique())
636
- ax.set_xticks(xticks)
637
- ax.set_xticklabels(xticks)
634
+ ax.set_xticks(xticks) # type: ignore
635
+ ax.set_xticklabels(xticks) # type: ignore
638
636
 
639
- finalize_plot(ax, callback, outparams, save_path, True, title)
637
+ finalize_plot(ax, callback, outparams, save_path, True, title) # type: ignore
640
638
 
641
639
 
642
640
  # ===================================================================
@@ -648,14 +646,14 @@ def scatterplot(
648
646
  yname: str,
649
647
  hue=None,
650
648
  title: str | None = None,
651
- palette: str = None,
649
+ palette: str | None = None,
652
650
  width: int = config.width,
653
651
  height: int = config.height,
654
652
  linewidth: float = config.line_width,
655
653
  dpi: int = config.dpi,
656
- save_path: str = None,
657
- callback: any = None,
658
- ax: Axes = None,
654
+ save_path: str | None = None,
655
+ callback: Callable | None = None,
656
+ ax: Axes | None = None,
659
657
  **params,
660
658
  ) -> None:
661
659
  """산점도를 그린다.
@@ -681,7 +679,7 @@ def scatterplot(
681
679
  outparams = False
682
680
 
683
681
  if ax is None:
684
- fig, ax = get_default_ax(width, height, 1, 1, dpi)
682
+ fig, ax = get_default_ax(width, height, 1, 1, dpi) # type: ignore
685
683
  outparams = True
686
684
 
687
685
  # hue가 있을 때만 palette 사용, 없으면 color 사용
@@ -703,7 +701,7 @@ def scatterplot(
703
701
 
704
702
  sb.scatterplot(**scatterplot_kwargs)
705
703
 
706
- finalize_plot(ax, callback, outparams, save_path, True, title)
704
+ finalize_plot(ax, callback, outparams, save_path, True, title) # type: ignore
707
705
 
708
706
 
709
707
  # ===================================================================
@@ -714,14 +712,14 @@ def regplot(
714
712
  xname: str,
715
713
  yname: str,
716
714
  title: str | None = None,
717
- palette: str = None,
715
+ palette: str | None = None,
718
716
  width: int = config.width,
719
717
  height: int = config.height,
720
718
  linewidth: float = config.line_width,
721
719
  dpi: int = config.dpi,
722
- save_path: str = None,
723
- callback: any = None,
724
- ax: Axes = None,
720
+ save_path: str | None = None,
721
+ callback: Callable | None = None,
722
+ ax: Axes | None = None,
725
723
  **params,
726
724
  ) -> None:
727
725
  """단순 회귀선이 포함된 산점도를 그린다.
@@ -746,7 +744,7 @@ def regplot(
746
744
  outparams = False
747
745
 
748
746
  if ax is None:
749
- fig, ax = get_default_ax(width, height, 1, 1, dpi)
747
+ fig, ax = get_default_ax(width, height, 1, 1, dpi) # type: ignore
750
748
  outparams = True
751
749
 
752
750
  # regplot은 hue를 지원하지 않으므로 palette를 color로 변환
@@ -771,7 +769,7 @@ def regplot(
771
769
 
772
770
  sb.regplot(**regplot_kwargs)
773
771
 
774
- finalize_plot(ax, callback, outparams, save_path, True, title)
772
+ finalize_plot(ax, callback, outparams, save_path, True, title) # type: ignore
775
773
 
776
774
 
777
775
  # ===================================================================
@@ -783,12 +781,12 @@ def lmplot(
783
781
  yname: str,
784
782
  hue=None,
785
783
  title: str | None = None,
786
- palette: str = None,
784
+ palette: str | None = None,
787
785
  width: int = config.width,
788
786
  height: int = config.height,
789
787
  linewidth: float = config.line_width,
790
788
  dpi: int = config.dpi,
791
- save_path: str = None,
789
+ save_path: str | None = None,
792
790
  **params,
793
791
  ) -> None:
794
792
  """seaborn lmplot으로 선형 모델 시각화를 수행한다.
@@ -835,7 +833,7 @@ def lmplot(
835
833
  continue
836
834
  line.set_linewidth(linewidth)
837
835
 
838
- g.fig.grid(True, alpha=config.grid_alpha, linewidth=config.grid_width)
836
+ g.fig.grid(True, alpha=config.grid_alpha, linewidth=config.grid_width) # type: ignore
839
837
 
840
838
  if title:
841
839
  g.fig.suptitle(title, fontsize=config.font_size * 1.5, fontweight='bold')
@@ -858,12 +856,12 @@ def pairplot(
858
856
  title: str | None = None,
859
857
  diag_kind: str = "kde",
860
858
  hue=None,
861
- palette: str = None,
859
+ palette: str | None = None,
862
860
  width: int = config.height,
863
861
  height: int = config.height,
864
862
  linewidth: float = config.line_width,
865
863
  dpi: int = config.dpi,
866
- save_path: str = None,
864
+ save_path: str | None = None,
867
865
  **params,
868
866
  ) -> None:
869
867
  """연속형 변수의 숫자형 컬럼 쌍에 대한 관계를 그린다.
@@ -936,7 +934,7 @@ def pairplot(
936
934
  g.map_upper(func=sb.scatterplot, linewidth=linewidth)
937
935
 
938
936
  # KDE 대각선에도 linewidth 적용
939
- for ax in g.axes.diag:
937
+ for ax in g.axes.diag: # type: ignore
940
938
  for line in ax.get_lines():
941
939
  line.set_linewidth(linewidth)
942
940
 
@@ -957,15 +955,15 @@ def countplot(
957
955
  xname: str,
958
956
  hue=None,
959
957
  title: str | None = None,
960
- palette: str = None,
958
+ palette: str | None = None,
961
959
  order: int = 1,
962
960
  width: int = config.width,
963
961
  height: int = config.height,
964
962
  linewidth: float = config.line_width,
965
963
  dpi: int = config.dpi,
966
- save_path: str = None,
967
- callback: any = None,
968
- ax: Axes = None,
964
+ save_path: str | None = None,
965
+ callback: Callable | None = None,
966
+ ax: Axes | None = None,
969
967
  **params,
970
968
  ) -> None:
971
969
  """범주 빈도 막대그래프를 그린다.
@@ -997,7 +995,7 @@ def countplot(
997
995
  sort = sorted(list(df[xname].value_counts().index))
998
996
 
999
997
  if ax is None:
1000
- fig, ax = get_default_ax(width, height, 1, 1, dpi)
998
+ fig, ax = get_default_ax(width, height, 1, 1, dpi) # type: ignore
1001
999
  outparams = True
1002
1000
 
1003
1001
  # hue가 있을 때만 palette 사용, 없으면 color 사용
@@ -1020,7 +1018,7 @@ def countplot(
1020
1018
 
1021
1019
  sb.countplot(**countplot_kwargs)
1022
1020
 
1023
- finalize_plot(ax, callback, outparams, save_path, True, title)
1021
+ finalize_plot(ax, callback, outparams, save_path, True, title) # type: ignore
1024
1022
 
1025
1023
 
1026
1024
  # ===================================================================
@@ -1032,14 +1030,14 @@ def barplot(
1032
1030
  yname: str,
1033
1031
  hue=None,
1034
1032
  title: str | None = None,
1035
- palette: str = None,
1033
+ palette: str | None = None,
1036
1034
  width: int = config.width,
1037
1035
  height: int = config.height,
1038
1036
  linewidth: float = config.line_width,
1039
1037
  dpi: int = config.dpi,
1040
- save_path: str = None,
1041
- callback: any = None,
1042
- ax: Axes = None,
1038
+ save_path: str | None = None,
1039
+ callback: Callable | None = None,
1040
+ ax: Axes | None = None,
1043
1041
  **params,
1044
1042
  ) -> None:
1045
1043
  """막대그래프를 그린다.
@@ -1065,7 +1063,7 @@ def barplot(
1065
1063
  outparams = False
1066
1064
 
1067
1065
  if ax is None:
1068
- fig, ax = get_default_ax(width, height, 1, 1, dpi)
1066
+ fig, ax = get_default_ax(width, height, 1, 1, dpi) # type: ignore
1069
1067
  outparams = True
1070
1068
 
1071
1069
  # hue가 있을 때만 palette 사용, 없으면 color 사용
@@ -1086,7 +1084,7 @@ def barplot(
1086
1084
  barplot_kwargs.update(params)
1087
1085
 
1088
1086
  sb.barplot(**barplot_kwargs)
1089
- finalize_plot(ax, callback, outparams, save_path, True, title)
1087
+ finalize_plot(ax, callback, outparams, save_path, True, title) # type: ignore
1090
1088
 
1091
1089
 
1092
1090
  # ===================================================================
@@ -1098,14 +1096,14 @@ def boxenplot(
1098
1096
  yname: str,
1099
1097
  hue=None,
1100
1098
  title: str | None = None,
1101
- palette: str = None,
1099
+ palette: str | None = None,
1102
1100
  width: int = config.width,
1103
1101
  height: int = config.height,
1104
1102
  linewidth: float = config.line_width,
1105
1103
  dpi: int = config.dpi,
1106
- save_path: str = None,
1107
- callback: any = None,
1108
- ax: Axes = None,
1104
+ save_path: str | None = None,
1105
+ callback: Callable | None = None,
1106
+ ax: Axes | None = None,
1109
1107
  **params,
1110
1108
  ) -> None:
1111
1109
  """박스앤 위스커 확장(boxen) 플롯을 그린다.
@@ -1131,7 +1129,7 @@ def boxenplot(
1131
1129
  outparams = False
1132
1130
 
1133
1131
  if ax is None:
1134
- fig, ax = get_default_ax(width, height, 1, 1, dpi)
1132
+ fig, ax = get_default_ax(width, height, 1, 1, dpi) # type: ignore
1135
1133
  outparams = True
1136
1134
 
1137
1135
  # palette은 hue가 있을 때만 사용
@@ -1150,7 +1148,7 @@ def boxenplot(
1150
1148
  boxenplot_kwargs.update(params)
1151
1149
 
1152
1150
  sb.boxenplot(**boxenplot_kwargs)
1153
- finalize_plot(ax, callback, outparams, save_path, True, title)
1151
+ finalize_plot(ax, callback, outparams, save_path, True, title) # type: ignore
1154
1152
 
1155
1153
 
1156
1154
  # ===================================================================
@@ -1162,14 +1160,14 @@ def violinplot(
1162
1160
  yname: str,
1163
1161
  hue=None,
1164
1162
  title: str | None = None,
1165
- palette: str = None,
1163
+ palette: str | None = None,
1166
1164
  width: int = config.width,
1167
1165
  height: int = config.height,
1168
1166
  linewidth: float = config.line_width,
1169
1167
  dpi: int = config.dpi,
1170
- save_path: str = None,
1171
- callback: any = None,
1172
- ax: Axes = None,
1168
+ save_path: str | None = None,
1169
+ callback: Callable | None = None,
1170
+ ax: Axes | None = None,
1173
1171
  **params,
1174
1172
  ) -> None:
1175
1173
  """바이올린 플롯을 그린다.
@@ -1195,7 +1193,7 @@ def violinplot(
1195
1193
  outparams = False
1196
1194
 
1197
1195
  if ax is None:
1198
- fig, ax = get_default_ax(width, height, 1, 1, dpi)
1196
+ fig, ax = get_default_ax(width, height, 1, 1, dpi) # type: ignore
1199
1197
  outparams = True
1200
1198
 
1201
1199
  # palette은 hue가 있을 때만 사용
@@ -1213,7 +1211,7 @@ def violinplot(
1213
1211
 
1214
1212
  violinplot_kwargs.update(params)
1215
1213
  sb.violinplot(**violinplot_kwargs)
1216
- finalize_plot(ax, callback, outparams, save_path, True, title)
1214
+ finalize_plot(ax, callback, outparams, save_path, True, title) # type: ignore
1217
1215
 
1218
1216
 
1219
1217
  # ===================================================================
@@ -1225,14 +1223,14 @@ def pointplot(
1225
1223
  yname: str,
1226
1224
  hue=None,
1227
1225
  title: str | None = None,
1228
- palette: str = None,
1226
+ palette: str | None = None,
1229
1227
  width: int = config.width,
1230
1228
  height: int = config.height,
1231
1229
  linewidth: float = config.line_width,
1232
1230
  dpi: int = config.dpi,
1233
- save_path: str = None,
1234
- callback: any = None,
1235
- ax: Axes = None,
1231
+ save_path: str | None = None,
1232
+ callback: Callable | None = None,
1233
+ ax: Axes | None = None,
1236
1234
  **params,
1237
1235
  ) -> None:
1238
1236
  """포인트 플롯을 그린다.
@@ -1258,7 +1256,7 @@ def pointplot(
1258
1256
  outparams = False
1259
1257
 
1260
1258
  if ax is None:
1261
- fig, ax = get_default_ax(width, height, 1, 1, dpi)
1259
+ fig, ax = get_default_ax(width, height, 1, 1, dpi) # type: ignore
1262
1260
  outparams = True
1263
1261
 
1264
1262
  # hue가 있을 때만 palette 사용, 없으면 color 사용
@@ -1278,7 +1276,7 @@ def pointplot(
1278
1276
 
1279
1277
  pointplot_kwargs.update(params)
1280
1278
  sb.pointplot(**pointplot_kwargs)
1281
- finalize_plot(ax, callback, outparams, save_path, True, title)
1279
+ finalize_plot(ax, callback, outparams, save_path, True, title) # type: ignore
1282
1280
 
1283
1281
 
1284
1282
  # ===================================================================
@@ -1290,12 +1288,12 @@ def jointplot(
1290
1288
  yname: str,
1291
1289
  hue=None,
1292
1290
  title: str | None = None,
1293
- palette: str = None,
1291
+ palette: str | None = None,
1294
1292
  width: int = config.width,
1295
1293
  height: int = config.height,
1296
1294
  linewidth: float = config.line_width,
1297
1295
  dpi: int = config.dpi,
1298
- save_path: str = None,
1296
+ save_path: str | None = None,
1299
1297
  **params,
1300
1298
  ) -> None:
1301
1299
  """공동 분포(joint) 플롯을 그린다.
@@ -1358,14 +1356,14 @@ def jointplot(
1358
1356
  def heatmap(
1359
1357
  data: DataFrame,
1360
1358
  title: str | None = None,
1361
- palette: str = None,
1359
+ palette: str | None = None,
1362
1360
  width: int | None = None,
1363
1361
  height: int | None = None,
1364
1362
  linewidth: float = 0.25,
1365
1363
  dpi: int = config.dpi,
1366
- save_path: str = None,
1367
- callback: any = None,
1368
- ax: Axes = None,
1364
+ save_path: str | None = None,
1365
+ callback: Callable | None = None,
1366
+ ax: Axes | None = None,
1369
1367
  **params,
1370
1368
  ) -> None:
1371
1369
  """히트맵을 그린다(값 주석 포함).
@@ -1389,10 +1387,10 @@ def heatmap(
1389
1387
 
1390
1388
  if width == None or height == None:
1391
1389
  width = (config.font_size * config.dpi / 72) * 4.5 * len(data.columns)
1392
- height = width * 0.8
1390
+ height = width * 0.8 # type: ignore
1393
1391
 
1394
1392
  if ax is None:
1395
- fig, ax = get_default_ax(width, height, 1, 1, dpi)
1393
+ fig, ax = get_default_ax(width, height, 1, 1, dpi) # type: ignore
1396
1394
  outparams = True
1397
1395
 
1398
1396
  heatmatp_kwargs = {
@@ -1410,26 +1408,26 @@ def heatmap(
1410
1408
  # heatmap은 hue를 지원하지 않으므로 cmap에 palette 사용
1411
1409
  sb.heatmap(**heatmatp_kwargs)
1412
1410
 
1413
- finalize_plot(ax, callback, outparams, save_path, True, title)
1411
+ finalize_plot(ax, callback, outparams, save_path, True, title) # type: ignore
1414
1412
 
1415
1413
 
1416
1414
  # ===================================================================
1417
- # 클러스터별 볼록 ꯐ막(convex hull)을 그린다
1415
+ # 클러스터별 볼록 경계막(convex hull)을 그린다
1418
1416
  # ===================================================================
1419
1417
  def convex_hull(
1420
1418
  data: DataFrame,
1421
1419
  xname: str,
1422
1420
  yname: str,
1423
- hue: str,
1421
+ hue: str | None = None,
1424
1422
  title: str | None = None,
1425
- palette: str = None,
1423
+ palette: str | None = None,
1426
1424
  width: int = config.width,
1427
1425
  height: int = config.height,
1428
1426
  linewidth: float = config.line_width,
1429
1427
  dpi: int = config.dpi,
1430
- save_path: str = None,
1431
- callback: any = None,
1432
- ax: Axes = None,
1428
+ save_path: str | None = None,
1429
+ callback: Callable | None = None,
1430
+ ax: Axes | None = None,
1433
1431
  **params,
1434
1432
  ):
1435
1433
  """클러스터별 볼록 껍질(convex hull)과 산점도를 그린다.
@@ -1455,7 +1453,7 @@ def convex_hull(
1455
1453
  outparams = False
1456
1454
 
1457
1455
  if ax is None:
1458
- fig, ax = get_default_ax(width, height, 1, 1, dpi)
1456
+ fig, ax = get_default_ax(width, height, 1, 1, dpi) # type: ignore
1459
1457
  outparams = True
1460
1458
 
1461
1459
  # 군집별 값의 종류별로 반복 수행
@@ -1473,10 +1471,10 @@ def convex_hull(
1473
1471
  # 마지막 좌표 이후에 첫 번째 좌표를 연결
1474
1472
  points = np.append(hull.vertices, hull.vertices[0])
1475
1473
 
1476
- ax.plot(
1474
+ ax.plot( # type: ignore
1477
1475
  df_c.iloc[points, 0], df_c.iloc[points, 1], linewidth=linewidth, linestyle=":"
1478
1476
  )
1479
- ax.fill(df_c.iloc[points, 0], df_c.iloc[points, 1], alpha=0.1)
1477
+ ax.fill(df_c.iloc[points, 0], df_c.iloc[points, 1], alpha=0.1) # type: ignore
1480
1478
  except:
1481
1479
  pass
1482
1480
 
@@ -1484,7 +1482,7 @@ def convex_hull(
1484
1482
  sb.scatterplot(
1485
1483
  data=data, x=xname, y=yname, hue=hue, palette=palette, ax=ax, **params
1486
1484
  )
1487
- finalize_plot(ax, callback, outparams, save_path, True, title)
1485
+ finalize_plot(ax, callback, outparams, save_path, True, title) # type: ignore
1488
1486
 
1489
1487
 
1490
1488
  # ===================================================================
@@ -1500,9 +1498,9 @@ def kde_confidence_interval(
1500
1498
  linewidth: float = config.line_width,
1501
1499
  fill: bool = False,
1502
1500
  dpi: int = config.dpi,
1503
- save_path: str = None,
1504
- callback: any = None,
1505
- ax: Axes = None,
1501
+ save_path: str | None = None,
1502
+ callback: Callable | None = None,
1503
+ ax: Axes | None = None,
1506
1504
  ) -> None:
1507
1505
  """각 숫자 컬럼에 대해 KDE와 t-분포 기반 신뢰구간을 그린다.
1508
1506
 
@@ -1572,7 +1570,7 @@ def kde_confidence_interval(
1572
1570
  cmin, cmax = t.interval(clevel, dof, loc=sample_mean, scale=sample_std_error)
1573
1571
 
1574
1572
  # 현재 컬럼에 대한 커널밀도추정
1575
- sb.kdeplot(data=column, linewidth=linewidth, ax=current_ax, fill=fill, alpha=config.fill_alpha)
1573
+ sb.kdeplot(data=column, linewidth=linewidth, ax=current_ax, fill=fill, alpha=config.fill_alpha) # type: ignore
1576
1574
 
1577
1575
  # 그래프 축의 범위
1578
1576
  xmin, xmax, ymin, ymax = current_ax.get_position().bounds
@@ -1597,7 +1595,7 @@ def kde_confidence_interval(
1597
1595
 
1598
1596
  current_ax.grid(True, alpha=config.grid_alpha, linewidth=config.grid_width)
1599
1597
 
1600
- finalize_plot(axes[0] if isinstance(axes, list) and len(axes) > 0 else ax, callback, outparams, save_path, True, title)
1598
+ finalize_plot(axes[0] if isinstance(axes, list) and len(axes) > 0 else ax, callback, outparams, save_path, True, title) # type: ignore
1601
1599
 
1602
1600
 
1603
1601
  # ===================================================================
@@ -1608,7 +1606,7 @@ def pvalue1_anotation(
1608
1606
  target: str,
1609
1607
  hue: str,
1610
1608
  title: str | None = None,
1611
- pairs: list = None,
1609
+ pairs: list | None = None,
1612
1610
  test: str = "t-test_ind",
1613
1611
  text_format: str = "star",
1614
1612
  loc: str = "outside",
@@ -1616,9 +1614,9 @@ def pvalue1_anotation(
1616
1614
  height: int = config.height,
1617
1615
  linewidth: float = config.line_width,
1618
1616
  dpi: int = config.dpi,
1619
- save_path: str = None,
1620
- callback: any = None,
1621
- ax: Axes = None,
1617
+ save_path: str | None = None,
1618
+ callback: Callable | None = None,
1619
+ ax: Axes | None = None,
1622
1620
  **params
1623
1621
  ) -> None:
1624
1622
  """statannotations를 이용해 상자그림에 p-value 주석을 추가한다.
@@ -1652,7 +1650,7 @@ def pvalue1_anotation(
1652
1650
  outparams = False
1653
1651
 
1654
1652
  if ax is None:
1655
- fig, ax = get_default_ax(width, height, 1, 1, dpi)
1653
+ fig, ax = get_default_ax(width, height, 1, 1, dpi) # type: ignore
1656
1654
  outparams = True
1657
1655
 
1658
1656
  # params에서 palette 추출 (있으면)
@@ -1679,7 +1677,7 @@ def pvalue1_anotation(
1679
1677
  annotator.apply_and_annotate()
1680
1678
 
1681
1679
  sb.despine()
1682
- finalize_plot(ax, callback, outparams, save_path, True, title)
1680
+ finalize_plot(ax, callback, outparams, save_path, True, title) # type: ignore
1683
1681
 
1684
1682
 
1685
1683
 
@@ -1695,9 +1693,9 @@ def ols_residplot(
1695
1693
  height: int = config.height,
1696
1694
  linewidth: float = config.line_width,
1697
1695
  dpi: int = config.dpi,
1698
- save_path: str = None,
1699
- callback: any = None,
1700
- ax: Axes = None,
1696
+ save_path: str | None = None,
1697
+ callback: Callable | None = None,
1698
+ ax: Axes | None = None,
1701
1699
  **params,
1702
1700
  ) -> None:
1703
1701
  """잔차도를 그린다(선택적으로 MSE 범위와 LOWESS 포함).
@@ -1739,24 +1737,23 @@ def ols_residplot(
1739
1737
  y = y_pred + resid # 실제값 = 적합값 + 잔차
1740
1738
 
1741
1739
  if ax is None:
1742
- fig, ax = get_default_ax(width + 150 if mse else width, height, 1, 1, dpi)
1740
+ fig, ax = get_default_ax(width + 150 if mse else width, height, 1, 1, dpi) # type: ignore
1743
1741
  outparams = True
1744
1742
 
1745
- # 산점도 직접 그리기 (seaborn.residplot보다 훨씬 빠름)
1746
- ax.scatter(y_pred, resid, edgecolor="white", alpha=0.7, **params)
1743
+ # 산점도 seaborn으로 그리기
1744
+ sb.scatterplot(x=y_pred, y=resid, ax=ax, s=0.5, edgecolor="white", alpha=config.fill_alpha, **params)
1747
1745
 
1748
1746
  # 기준선 (잔차 = 0)
1749
- ax.axhline(0, color="gray", linestyle="--", linewidth=linewidth)
1747
+ ax.axhline(0, color="gray", linestyle="--", linewidth=linewidth*0.7) # type: ignore
1750
1748
 
1751
1749
  # LOWESS 스무딩 (선택적)
1752
1750
  if lowess:
1753
- from statsmodels.nonparametric.smoothers_lowess import lowess as sm_lowess
1754
1751
  lowess_result = sm_lowess(resid, y_pred, frac=0.6667)
1755
- ax.plot(lowess_result[:, 0], lowess_result[:, 1],
1756
- color="red", linewidth=linewidth, label="LOWESS")
1752
+ ax.plot(lowess_result[:, 0], lowess_result[:, 1], # type: ignore
1753
+ color="red", linewidth=linewidth, label="LOWESS") # type: ignore
1757
1754
 
1758
- ax.set_xlabel("Fitted values")
1759
- ax.set_ylabel("Residuals")
1755
+ ax.set_xlabel("Fitted values") # type: ignore
1756
+ ax.set_ylabel("Residuals") # type: ignore
1760
1757
 
1761
1758
  if mse:
1762
1759
  mse_val = mean_squared_error(y, y_pred)
@@ -1776,40 +1773,40 @@ def ols_residplot(
1776
1773
 
1777
1774
  mse_r = [r1, r2, r3]
1778
1775
 
1779
- xmin, xmax = ax.get_xlim()
1776
+ xmin, xmax = ax.get_xlim() # type: ignore
1780
1777
 
1781
1778
  # 구간별 반투명 색상 채우기 (안쪽부터 바깥쪽으로, 진한 색에서 연한 색으로)
1782
1779
  colors = ["red", "green", "blue"]
1783
1780
  alphas = [0.15, 0.10, 0.05] # 안쪽이 더 진하게
1784
1781
 
1785
1782
  # 3σ 영역 (가장 바깥쪽, 가장 연함)
1786
- ax.axhspan(-3 * mse_sq, 3 * mse_sq, facecolor=colors[2], alpha=alphas[2], zorder=0)
1783
+ ax.axhspan(-3 * mse_sq, 3 * mse_sq, facecolor=colors[2], alpha=alphas[2], zorder=0) # type: ignore
1787
1784
  # 2σ 영역 (중간)
1788
- ax.axhspan(-2 * mse_sq, 2 * mse_sq, facecolor=colors[1], alpha=alphas[1], zorder=1)
1785
+ ax.axhspan(-2 * mse_sq, 2 * mse_sq, facecolor=colors[1], alpha=alphas[1], zorder=1) # type: ignore
1789
1786
  # 1σ 영역 (가장 안쪽, 가장 진함)
1790
- ax.axhspan(-mse_sq, mse_sq, facecolor=colors[0], alpha=alphas[0], zorder=2)
1787
+ ax.axhspan(-mse_sq, mse_sq, facecolor=colors[0], alpha=alphas[0], zorder=2) # type: ignore
1791
1788
 
1792
1789
  # 경계선 그리기
1793
1790
  for i, c in enumerate(["red", "green", "blue"]):
1794
- ax.axhline(mse_sq * (i + 1), color=c, linestyle="--", linewidth=linewidth/2)
1795
- ax.axhline(mse_sq * (-(i + 1)), color=c, linestyle="--", linewidth=linewidth/2)
1791
+ ax.axhline(mse_sq * (i + 1), color=c, linestyle="--", linewidth=linewidth/2) # type: ignore
1792
+ ax.axhline(mse_sq * (-(i + 1)), color=c, linestyle="--", linewidth=linewidth/2) # type: ignore
1796
1793
 
1797
1794
  target = [68, 95, 99.7]
1798
1795
  for i, c in enumerate(["red", "green", "blue"]):
1799
- ax.text(
1796
+ ax.text( # type: ignore
1800
1797
  s=f"{i+1} sqrt(MSE) = {mse_r[i]:.2f}% ({mse_r[i] - target[i]:.2f}%)",
1801
1798
  x=xmax + 0.2,
1802
1799
  y=(i + 1) * mse_sq,
1803
1800
  color=c,
1804
1801
  )
1805
- ax.text(
1802
+ ax.text( # type: ignore
1806
1803
  s=f"-{i+1} sqrt(MSE) = {mse_r[i]:.2f}% ({mse_r[i] - target[i]:.2f}%)",
1807
1804
  x=xmax + 0.2,
1808
1805
  y=-(i + 1) * mse_sq,
1809
1806
  color=c,
1810
1807
  )
1811
1808
 
1812
- finalize_plot(ax, callback, outparams, save_path, True, title)
1809
+ finalize_plot(ax, callback, outparams, save_path, True, title) # type: ignore
1813
1810
 
1814
1811
 
1815
1812
  # ===================================================================
@@ -1823,9 +1820,9 @@ def ols_qqplot(
1823
1820
  height: int = config.height,
1824
1821
  linewidth: float = config.line_width,
1825
1822
  dpi: int = config.dpi,
1826
- save_path: str = None,
1827
- callback: any = None,
1828
- ax: Axes = None,
1823
+ save_path: str | None = None,
1824
+ callback: Callable | None = None,
1825
+ ax: Axes | None = None,
1829
1826
  **params,
1830
1827
  ) -> None:
1831
1828
  """표준화된 잔차의 정규성 확인을 위한 QQ 플롯을 그린다.
@@ -1870,7 +1867,7 @@ def ols_qqplot(
1870
1867
  outparams = False
1871
1868
 
1872
1869
  if ax is None:
1873
- fig, ax = get_default_ax(width, height, 1, 1, dpi)
1870
+ fig, ax = get_default_ax(width, height, 1, 1, dpi) # type: ignore
1874
1871
  outparams = True
1875
1872
 
1876
1873
  # fit 객체에서 잔차(residuals) 추출
@@ -1885,7 +1882,7 @@ def ols_qqplot(
1885
1882
  sm_qqplot(residuals, line=line, ax=ax, **params)
1886
1883
 
1887
1884
  # 점의 스타일 개선: 연한 내부, 진한 테두리
1888
- for collection in ax.collections:
1885
+ for collection in ax.collections: # type: ignore
1889
1886
  # PathCollection (scatter plot의 점들)
1890
1887
  collection.set_facecolor('#4A90E2') # 연한 파란색 내부
1891
1888
  collection.set_edgecolor('#1E3A8A') # 진한 파란색 테두리
@@ -1893,11 +1890,11 @@ def ols_qqplot(
1893
1890
  collection.set_alpha(0.7) # 약간의 투명도
1894
1891
 
1895
1892
  # 선 굵기 조정
1896
- for line in ax.get_lines():
1897
- if line.get_linestyle() == '--' or line.get_color() == 'r':
1898
- line.set_linewidth(linewidth)
1893
+ for line in ax.get_lines(): # type: ignore
1894
+ if line.get_linestyle() == '--' or line.get_color() == 'r': # type: ignore
1895
+ line.set_linewidth(linewidth) # type: ignore
1899
1896
 
1900
- finalize_plot(ax, callback, outparams, save_path, True, title)
1897
+ finalize_plot(ax, callback, outparams, save_path, True, title) # type: ignore
1901
1898
 
1902
1899
 
1903
1900
  # ===================================================================
@@ -1906,18 +1903,18 @@ def ols_qqplot(
1906
1903
  def distribution_by_class(
1907
1904
  data: DataFrame,
1908
1905
  title: str | None = None,
1909
- xnames: list = None,
1910
- hue: str = None,
1906
+ xnames: list | None = None,
1907
+ hue: str | None = None,
1911
1908
  type: str = "kde",
1912
- bins: any = 5,
1913
- palette: str = None,
1909
+ bins: list[int] | int = 5,
1910
+ palette: str | None = None,
1914
1911
  fill: bool = False,
1915
1912
  width: int = config.width,
1916
1913
  height: int = config.height,
1917
1914
  linewidth: float = config.line_width,
1918
1915
  dpi: int = config.dpi,
1919
- save_path: str = None,
1920
- callback: any = None,
1916
+ save_path: str | None = None,
1917
+ callback: Callable | None = None,
1921
1918
  ) -> None:
1922
1919
  """클래스별로 각 숫자형 특징의 분포를 KDE 또는 히스토그램으로 그린다.
1923
1920
 
@@ -1940,9 +1937,9 @@ def distribution_by_class(
1940
1937
  None
1941
1938
  """
1942
1939
  if xnames is None:
1943
- xnames = data.columns
1940
+ xnames = data.columns # type: ignore
1944
1941
 
1945
- for i, v in enumerate(xnames):
1942
+ for i, v in enumerate(xnames): # type: ignore
1946
1943
  # 종속변수이거나 숫자형이 아닌 경우는 제외
1947
1944
  if v == hue or data[v].dtype not in [
1948
1945
  "int",
@@ -1973,7 +1970,7 @@ def distribution_by_class(
1973
1970
  df=data,
1974
1971
  xname=v,
1975
1972
  hue=hue,
1976
- bins=bins,
1973
+ bins=bins, # type: ignore
1977
1974
  kde=False,
1978
1975
  palette=palette,
1979
1976
  width=width,
@@ -1988,7 +1985,7 @@ def distribution_by_class(
1988
1985
  df=data,
1989
1986
  xname=v,
1990
1987
  hue=hue,
1991
- bins=bins,
1988
+ bins=bins, # type: ignore
1992
1989
  kde=True,
1993
1990
  palette=palette,
1994
1991
  width=width,
@@ -2015,8 +2012,8 @@ def scatter_by_class(
2015
2012
  height: int = config.height,
2016
2013
  linewidth: float = config.line_width,
2017
2014
  dpi: int = config.dpi,
2018
- save_path: str = None,
2019
- callback: any = None,
2015
+ save_path: str | None = None,
2016
+ callback: Callable | None = None,
2020
2017
  ) -> None:
2021
2018
  """종속변수(y)와 각 연속형 독립변수(x) 간 산점도/볼록껍질을 그린다.
2022
2019
 
@@ -2071,7 +2068,7 @@ def scatter_by_class(
2071
2068
  for v in group:
2072
2069
  scatterplot(data=data, xname=v[0], yname=v[1], hue=hue, palette=palette,
2073
2070
  width=width, height=height, linewidth=linewidth, dpi=dpi, callback=callback,
2074
- save_path=save_path)
2071
+ save_path=save_path) # type: ignore
2075
2072
 
2076
2073
 
2077
2074
  # ===================================================================
@@ -2090,8 +2087,8 @@ def categorical_target_distribution(
2090
2087
  linewidth: float = config.line_width,
2091
2088
  dpi: int = config.dpi,
2092
2089
  cols: int = 2,
2093
- save_path: str = None,
2094
- callback: any = None,
2090
+ save_path: str | None = None,
2091
+ callback: Callable | None = None,
2095
2092
  ) -> None:
2096
2093
  """명목형 변수별로 종속변수 분포 차이를 시각화한다.
2097
2094
 
@@ -2166,16 +2163,16 @@ def categorical_target_distribution(
2166
2163
  # ===================================================================
2167
2164
  def roc_curve_plot(
2168
2165
  fit,
2169
- y: np.ndarray | pd.Series = None,
2170
- X: pd.DataFrame | np.ndarray = None,
2166
+ y: np.ndarray | pd.Series | None = None,
2167
+ X: pd.DataFrame | np.ndarray | None = None,
2171
2168
  title: str | None = None,
2172
2169
  width: int = config.height,
2173
2170
  height: int = config.height,
2174
2171
  linewidth: float = config.line_width,
2175
2172
  dpi: int = config.dpi,
2176
- save_path: str = None,
2177
- callback: any = None,
2178
- ax: Axes = None,
2173
+ save_path: str | None = None,
2174
+ callback: Callable | None = None,
2175
+ ax: Axes | None = None,
2179
2176
  ) -> None:
2180
2177
  """로지스틱 회귀 적합 결과의 ROC 곡선을 시각화한다.
2181
2178
 
@@ -2200,7 +2197,7 @@ def roc_curve_plot(
2200
2197
  """
2201
2198
  outparams = False
2202
2199
  if ax is None:
2203
- fig, ax = get_default_ax(width, height, 1, 1, dpi)
2200
+ fig, ax = get_default_ax(width, height, 1, 1, dpi) # type: ignore
2204
2201
  outparams = True
2205
2202
 
2206
2203
  # 실제값(y_true) 결정
@@ -2221,16 +2218,16 @@ def roc_curve_plot(
2221
2218
  roc_auc = auc(fpr, tpr)
2222
2219
 
2223
2220
  # ROC 곡선 그리기
2224
- ax.plot(fpr, tpr, color='darkorange', lw=linewidth, label=f'ROC curve (AUC = {roc_auc:.4f})')
2225
- ax.plot([0, 1], [0, 1], color='navy', lw=linewidth, linestyle='--', label='Random Classifier')
2221
+ ax.plot(fpr, tpr, color='darkorange', lw=linewidth, label=f'ROC curve (AUC = {roc_auc:.4f})') # type: ignore
2222
+ ax.plot([0, 1], [0, 1], color='navy', lw=linewidth, linestyle='--', label='Random Classifier') # type: ignore
2226
2223
 
2227
- ax.set_xlim([0.0, 1.0])
2228
- ax.set_ylim([0.0, 1.05])
2229
- ax.set_xlabel('위양성율 (False Positive Rate)', fontsize=8)
2230
- ax.set_ylabel('재현율 (True Positive Rate)', fontsize=8)
2231
- ax.set_title('ROC 곡선', fontsize=10, fontweight='bold')
2232
- ax.legend(loc="lower right", fontsize=7)
2233
- finalize_plot(ax, callback, outparams, save_path, True, title)
2224
+ ax.set_xlim([0.0, 1.0]) # type: ignore
2225
+ ax.set_ylim([0.0, 1.05]) # type: ignore
2226
+ ax.set_xlabel('위양성율 (False Positive Rate)', fontsize=8) # type: ignore
2227
+ ax.set_ylabel('재현율 (True Positive Rate)', fontsize=8) # type: ignore
2228
+ ax.set_title('ROC 곡선', fontsize=10, fontweight='bold') # type: ignore
2229
+ ax.legend(loc="lower right", fontsize=7) # type: ignore
2230
+ finalize_plot(ax, callback, outparams, save_path, True, title) # type: ignore
2234
2231
 
2235
2232
 
2236
2233
  # ===================================================================
@@ -2243,9 +2240,9 @@ def confusion_matrix_plot(
2243
2240
  width: int = config.width,
2244
2241
  height: int = config.height,
2245
2242
  dpi: int = config.dpi,
2246
- save_path: str = None,
2247
- callback: any = None,
2248
- ax: Axes = None,
2243
+ save_path: str | None = None,
2244
+ callback: Callable | None = None,
2245
+ ax: Axes | None = None,
2249
2246
  ) -> None:
2250
2247
  """로지스틱 회귀 적합 결과의 혼동행렬을 시각화한다.
2251
2248
 
@@ -2264,7 +2261,7 @@ def confusion_matrix_plot(
2264
2261
  """
2265
2262
  outparams = False
2266
2263
  if ax is None:
2267
- fig, ax = get_default_ax(width, height, 1, 1, dpi)
2264
+ fig, ax = get_default_ax(width, height, 1, 1, dpi) # type: ignore
2268
2265
  outparams = True
2269
2266
 
2270
2267
  # 학습 데이터 기반 실제값/예측 확률 결정
@@ -2280,9 +2277,9 @@ def confusion_matrix_plot(
2280
2277
  # 가독성을 위해 텍스트 크기/굵기 조정
2281
2278
  disp.plot(ax=ax, cmap='Blues', values_format='d', text_kw={"fontsize": 16, "weight": "bold"})
2282
2279
 
2283
- ax.set_title(f'혼동행렬 (임계값: {threshold})', fontsize=8, fontweight='bold')
2280
+ ax.set_title(f'혼동행렬 (임계값: {threshold})', fontsize=8, fontweight='bold') # type: ignore
2284
2281
 
2285
- finalize_plot(ax, callback, outparams, save_path, False, title)
2282
+ finalize_plot(ax, callback, outparams, save_path, False, title) # type: ignore
2286
2283
 
2287
2284
 
2288
2285
  # ===================================================================
@@ -2290,20 +2287,20 @@ def confusion_matrix_plot(
2290
2287
  # ===================================================================
2291
2288
  def radarplot(
2292
2289
  df: DataFrame,
2293
- columns: list = None,
2294
- hue: str = None,
2290
+ columns: list | None = None,
2291
+ hue: str | None = None,
2295
2292
  title: str | None = None,
2296
2293
  normalize: bool = True,
2297
2294
  fill: bool = True,
2298
2295
  fill_alpha: float = 0.25,
2299
- palette: str = None,
2296
+ palette: str | None = None,
2300
2297
  width: int = config.width,
2301
2298
  height: int = config.height,
2302
2299
  linewidth: float = config.line_width,
2303
2300
  dpi: int = config.dpi,
2304
- save_path: str = None,
2305
- callback: any = None,
2306
- ax: Axes = None,
2301
+ save_path: str | None = None,
2302
+ callback: Callable | None = None,
2303
+ ax: Axes | None = None,
2307
2304
  **params,
2308
2305
  ) -> None:
2309
2306
  """레이더 차트(방사형 차트)를 그린다.
@@ -2414,7 +2411,7 @@ def radarplot(
2414
2411
  else:
2415
2412
  ax.set_title('Radar Chart', pad=20)
2416
2413
 
2417
- finalize_plot(ax, callback, outparams, save_path, True, title)
2414
+ finalize_plot(ax, callback, outparams, save_path, True, title) # type: ignore
2418
2415
 
2419
2416
 
2420
2417
  # ===================================================================
@@ -2432,8 +2429,8 @@ def distribution_plot(
2432
2429
  height: int = config.height,
2433
2430
  linewidth: float = config.line_width,
2434
2431
  dpi: int = config.dpi,
2435
- save_path: str = None,
2436
- callback: any = None,
2432
+ save_path: str | None = None,
2433
+ callback: Callable | None = None,
2437
2434
  ) -> None:
2438
2435
  """연속형 데이터의 분포를 KDE와 Boxplot으로 시각화한다.
2439
2436
 
@@ -2480,7 +2477,7 @@ def distribution_plot(
2480
2477
  )
2481
2478
  else:
2482
2479
  boxplot(
2483
- df=data[column],
2480
+ df=data[column], # type: ignore
2484
2481
  linewidth=linewidth,
2485
2482
  ax=axes[1]
2486
2483
  )
@@ -2518,7 +2515,7 @@ def distribution_plot(
2518
2515
  )
2519
2516
  else:
2520
2517
  boxplot(
2521
- df=subset[column],
2518
+ df=subset[column], # type: ignore
2522
2519
  linewidth=linewidth,
2523
2520
  ax=right_ax
2524
2521
  )