Qнефти / (Qнефти + Qводы) * 100%
Qводы / Qнефти
import os
import pandas as pd
import numpy as np
from sklearn.metrics import mean_squared_error
from tqdm import tqdm
def calculate_final_score(path_to_forecast: str, path_to_test_file: str):
df_with_metrics = pd.read_csv(path_to_forecast, parse_dates=['datetime'])
test_df = pd.read_csv(path_to_test_file, parse_dates=['datetime'])
wells = list(df_with_metrics["Номер скважины"].unique())
metrics = []
with tqdm(total=len(wells)) as pbar:
for well in wells:
well_forecast_df = df_with_metrics[df_with_metrics["Номер скважины"] == well]
well_forecast_df = well_forecast_df.sort_values(by='datetime')
well_actual_df = test_df[test_df["Номер скважины"] == well]
well_actual_df = well_actual_df.sort_values(by='datetime')
rmse_metric = mean_squared_error(np.array(well_actual_df['Дебит нефти']),
np.array(well_forecast_df['forecast']),
squared=False)
metrics.append(rmse_metric)
metrics = np.array(metrics)
return np.mean(metrics)