feat(pipeline): update transition_matrices and config for 7x7 Zt estimation
This commit is contained in:
@@ -18,14 +18,14 @@ ecos:
|
|||||||
# 전이행렬 데이터 소스
|
# 전이행렬 데이터 소스
|
||||||
data:
|
data:
|
||||||
transition_source: "real" # "real" (3사 실제) | "builtin" (내장 샘플)
|
transition_source: "real" # "real" (3사 실제) | "builtin" (내장 샘플)
|
||||||
transition_dir: null # null이면 기본 data/real/
|
transition_dir: null # null이면 기본 data/real_v2/
|
||||||
|
|
||||||
# 모형 파라미터
|
# 모형 파라미터
|
||||||
model:
|
model:
|
||||||
# 자산상관계수 (Basel IRB 기준 0.12~0.24, 기업 평균 ~0.20)
|
# 자산상관계수 (Basel IRB 기준 0.12~0.24, 기업 평균 ~0.20)
|
||||||
rho: 0.20
|
rho: 0.20
|
||||||
# 신용등급 체계 (한국 3사 공통)
|
# 신용등급 체계 (한국 3사 공통)
|
||||||
rating_grades: ["AAA", "AA", "A", "BBB", "BB", "B", "CCC", "D"]
|
rating_grades: ["AAA", "AA", "A", "BBB", "BB", "B", "D"] # 7x7 (CCC제외, Zt추정용)
|
||||||
|
|
||||||
# 시나리오 설정
|
# 시나리오 설정
|
||||||
scenarios:
|
scenarios:
|
||||||
|
|||||||
@@ -15,8 +15,12 @@ from pathlib import Path
|
|||||||
from typing import Dict, List, Optional, Tuple
|
from typing import Dict, List, Optional, Tuple
|
||||||
|
|
||||||
|
|
||||||
# 등급 레이블
|
# Rating grade labels
|
||||||
RATING_GRADES = ["AAA", "AA", "A", "BBB", "BB", "B", "CCC", "D"]
|
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)
|
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 사용.
|
parse_pdf_matrices.py 로 생성된 3사 평균 CSV 사용.
|
||||||
"""
|
"""
|
||||||
if data_dir is None:
|
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)
|
real_dir = Path(data_dir)
|
||||||
|
|
||||||
if not real_dir.exists():
|
if not real_dir.exists():
|
||||||
@@ -320,7 +324,11 @@ def get_default_rates(matrices: Dict[int, np.ndarray]) -> pd.DataFrame:
|
|||||||
index=연도, columns=등급, values=연간 PD
|
index=연도, columns=등급, values=연간 PD
|
||||||
"""
|
"""
|
||||||
years = sorted(matrices.keys())
|
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 = {}
|
data = {}
|
||||||
for year in years:
|
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:
|
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(
|
df = pd.DataFrame(
|
||||||
tm,
|
tm,
|
||||||
index=RATING_GRADES,
|
index=grades,
|
||||||
columns=RATING_GRADES
|
columns=grades
|
||||||
)
|
)
|
||||||
# 백분율 표시
|
# 백분율 표시
|
||||||
df_pct = df * 100
|
df_pct = df * 100
|
||||||
|
|||||||
Reference in New Issue
Block a user