# -*- coding: utf-8 -*-
"""
@author: yq
@time: 2024/11/1
@desc:  常用指标实体集合
"""
from typing import Union

import pandas as pd

from commom import f_format_float


class MetricTrainEntity():
    """
    模型训练结果指标类
    """

    def __init__(self, train_auc: float, train_ks: float, test_auc: float, test_ks: float,
                 train_perf_image_path: str = None, test_perf_image_path: str = None):
        self._train_auc = f_format_float(train_auc)
        self._train_ks = f_format_float(train_ks)
        self._train_perf_image_path = train_perf_image_path

        self._test_auc = f_format_float(test_auc)
        self._test_ks = f_format_float(test_ks)
        self._test_perf_image_path = test_perf_image_path

    def __str__(self):
        return f"train_auc:{self._train_auc} train_ks:{self._train_ks}\ntest_auc:{self._test_auc} test_ks:{self._test_ks}"

    @property
    def train_auc(self):
        return self._train_auc

    @property
    def train_ks(self):
        return self._train_ks

    @property
    def test_auc(self):
        return self._test_auc

    @property
    def test_ks(self):
        return self._test_ks


class MetricFucEntity():
    """
    指标计算函数结果类
    """

    def __init__(self, table: pd.DataFrame = None, value: str = None, image_path: Union[str, list] = None,
                 table_font_size=12, table_autofit=False, table_cell_width=None, image_size: int = 6):
        self._table = table
        self._table_font_size = table_font_size
        self._table_cell_width= table_cell_width
        self._table_autofit = table_autofit

        self._value = value
        self._image_path = image_path
        self._image_size = image_size

    @property
    def table_cell_width(self):
        return self._table_cell_width

    @property
    def table_autofit(self):
        return self._table_autofit

    @property
    def table_font_size(self):
        return self._table_font_size

    @property
    def table(self) -> pd.DataFrame:
        return self._table

    @property
    def value(self):
        return self._value

    @property
    def image_path(self):
        return self._image_path

    @property
    def image_size(self):
        return self._image_size

if __name__ == "__main__":
    pass