feat(pipeline): update transition_matrices and config for 7x7 Zt estimation
This commit is contained in:
@@ -15,8 +15,12 @@ from pathlib import Path
|
||||
from typing import Dict, List, Optional, Tuple
|
||||
|
||||
|
||||
# 등급 레이블
|
||||
RATING_GRADES = ["AAA", "AA", "A", "BBB", "BB", "B", "CCC", "D"]
|
||||
# Rating grade labels
|
||||
RATING_GRADES_8 = ["AAA", "AA", "A", "BBB", "BB", "B", "CCC", "D"]
|
||||
RATING_GRADES_7 = ["AAA", "AA", "A", "BBB", "BB", "B", "D"]
|
||||
|
||||
# Default: 7x7 (CCC excluded for Zt estimation)
|
||||
RATING_GRADES = RATING_GRADES_7
|
||||
N_GRADES = len(RATING_GRADES)
|
||||
|
||||
|
||||
@@ -205,7 +209,7 @@ def _load_real_matrices(data_dir: Optional[str] = None) -> Dict[int, np.ndarray]
|
||||
parse_pdf_matrices.py 로 생성된 3사 평균 CSV 사용.
|
||||
"""
|
||||
if data_dir is None:
|
||||
data_dir = str(Path(__file__).parent / "real")
|
||||
data_dir = str(Path(__file__).parent / "real_v2")
|
||||
real_dir = Path(data_dir)
|
||||
|
||||
if not real_dir.exists():
|
||||
@@ -320,7 +324,11 @@ def get_default_rates(matrices: Dict[int, np.ndarray]) -> pd.DataFrame:
|
||||
index=연도, columns=등급, values=연간 PD
|
||||
"""
|
||||
years = sorted(matrices.keys())
|
||||
grades = RATING_GRADES[:-1] # D 제외
|
||||
n = list(matrices.values())[0].shape[0]
|
||||
if n == 7:
|
||||
grades = RATING_GRADES_7[:-1] # AAA~B (D 제외)
|
||||
else:
|
||||
grades = RATING_GRADES_8[:-1] # AAA~CCC (D 제외)
|
||||
|
||||
data = {}
|
||||
for year in years:
|
||||
@@ -332,10 +340,15 @@ def get_default_rates(matrices: Dict[int, np.ndarray]) -> pd.DataFrame:
|
||||
|
||||
def display_matrix(tm: np.ndarray, title: str = "전이행렬") -> str:
|
||||
"""전이행렬을 보기 좋게 포매팅"""
|
||||
n = tm.shape[0]
|
||||
if n == 7:
|
||||
grades = RATING_GRADES_7
|
||||
else:
|
||||
grades = RATING_GRADES_8
|
||||
df = pd.DataFrame(
|
||||
tm,
|
||||
index=RATING_GRADES,
|
||||
columns=RATING_GRADES
|
||||
index=grades,
|
||||
columns=grades
|
||||
)
|
||||
# 백분율 표시
|
||||
df_pct = df * 100
|
||||
|
||||
Reference in New Issue
Block a user