From 7c16ad0cced6c63ac8cd154dd6b242fde362a689 Mon Sep 17 00:00:00 2001 From: xiaolongsun <95378566+xiaolong0728@users.noreply.github.com> Date: Wed, 8 Jan 2025 11:54:07 +0100 Subject: [PATCH] Add annotation --- .../evaluation/metric_calculation.py | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/views_evaluation/evaluation/metric_calculation.py b/views_evaluation/evaluation/metric_calculation.py index f67e23d..4302489 100644 --- a/views_evaluation/evaluation/metric_calculation.py +++ b/views_evaluation/evaluation/metric_calculation.py @@ -41,6 +41,17 @@ def __init__(self, metrics_list): def time_series_wise_evaluation( self, actual: pd.DataFrame, predictions: List[pd.DataFrame], target: str ) -> pd.DataFrame: + """ + Evaluates the predictions time series-wise and calculates the specified metrics. + + Args: + actual (pd.DataFrame): The actual values. + predictions (List[pd.DataFrame]): A list of DataFrames containing the predictions. + target (str): The target column in the actual DataFrame. + + Returns: + pd.DataFrame: A DataFrame containing the evaluation metrics. + """ evaluation_dict = EvaluationMetrics.make_time_series_wise_evaluation_dict(len(predictions)) for metric in self.metrics_list: @@ -58,6 +69,18 @@ def time_series_wise_evaluation( def step_wise_evaluation( self, actual: pd.DataFrame, predictions: List[pd.DataFrame], target: str, steps: List[int] ) -> pd.DataFrame: + """ + Evaluates the predictions step-wise and calculates the specified metrics. + + Args: + actual (pd.DataFrame): The actual values. + predictions (List[pd.DataFrame]): A list of DataFrames containing the predictions. + target (str): The target column in the actual DataFrame. + steps (List[int]): The steps to evaluate. + + Returns: + pd.DataFrame: A DataFrame containing the evaluation metrics. + """ evaluation_dict = EvaluationMetrics.make_step_wise_evaluation_dict(steps=max(steps)) step_metrics = {} @@ -88,6 +111,17 @@ def step_wise_evaluation( def month_wise_evaluation( self, actual: pd.DataFrame, predictions: List[pd.DataFrame], target: str ) -> pd.DataFrame: + """ + Evaluates the predictions month-wise and calculates the specified metrics. + + Args: + actual (pd.DataFrame): The actual values. + predictions (List[pd.DataFrame]): A list of DataFrames containing the predictions. + target (str): The target column in the actual DataFrame. + + Returns: + pd.DataFrame: A DataFrame containing the evaluation metrics. + """ pred_concat = pd.concat(predictions) pred_concat_target = pred_concat.columns[0] month_range = pred_concat.index.get_level_values(0).unique()