mirror of
https://github.com/webclinic017/drift.git
synced 2026-07-31 20:57:51 +00:00
73cfc67336
* fix(Evaluation): correlation test should work on a per asset level, not per model level * fix(Evaluation): correlations series initalized correctly * fix(Reporting): don't name the run after the incorrectly supposed model_type * fix(Reporting): put back send_report_to_wandb() into its original place * fix(CI): sending reports again in comment
46 lines
1.4 KiB
Python
46 lines
1.4 KiB
Python
import pandas as pd
|
|
from typing import Optional
|
|
from utils.helpers import weighted_average
|
|
|
|
def launch_wandb(project_name:str, default_config:dict, sweep:bool=False):
|
|
from wandb_setup import get_wandb
|
|
wandb = get_wandb()
|
|
if wandb is None:
|
|
raise Exception("Wandb can not be initalized, the environment variable WANDB_API_KEY is missing (can also use .env file)")
|
|
|
|
elif sweep:
|
|
wandb.init(project=project_name, config = default_config)
|
|
return wandb
|
|
else:
|
|
wandb.init(project=project_name, config = default_config, reinit=True)
|
|
return wandb
|
|
|
|
|
|
def register_config_with_wandb(wandb: Optional[object], model_config:dict, training_config:dict, data_config:dict):
|
|
if wandb is None: return model_config, training_config, data_config
|
|
|
|
config: dict = wandb.config
|
|
|
|
for k in training_config:
|
|
training_config[k] = config[k]
|
|
for k in model_config:
|
|
model_config[k] = config[k]
|
|
for k in data_config:
|
|
data_config[k] = config[k]
|
|
|
|
return model_config, training_config, data_config
|
|
|
|
def send_report_to_wandb(results: pd.DataFrame, wandb:Optional[object], project_name: str, model_name: str):
|
|
if wandb is None: return
|
|
|
|
run = wandb.run
|
|
run.save()
|
|
|
|
mean_results = weighted_average(results, 'no_of_samples')
|
|
for key, value in mean_results.iteritems():
|
|
run.log({ key: value })
|
|
|
|
run.finish()
|
|
|
|
|
|
|