Skip to content

Commit

Permalink
Add annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaolong0728 committed Jan 8, 2025
1 parent 3655ba6 commit 7c16ad0
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions views_evaluation/evaluation/metric_calculation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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 = {}

Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 7c16ad0

Please sign in to comment.