mirror of
https://github.com/webclinic017/drift.git
synced 2026-08-03 22:27:47 +00:00
a9b05dbd42
* fix(Reporting): use weighted average (with no_of_samples as weights) and only report level-1 OR level-2 model performance * chore(Config): updated sweep config * fix(Reporting): missing import * fix(Evaluation): get_first_valid_return_index can deal with zero valid indexes * fix(Training): increase threshold for skipping assets * fix(DataLoader): target asset should be always the first column
45 lines
1.4 KiB
Python
45 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:
|
|
return None
|
|
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):
|
|
config: dict = wandb.config
|
|
|
|
if type(wandb) is not type(None):
|
|
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]
|
|
|
|
|
|
def send_report_to_wandb(results: pd.DataFrame, wandb:Optional[object], project_name: str, model_name: str):
|
|
if wandb is None: return
|
|
|
|
run = wandb.init(project=project_name, config={"model_type": model_name}, reinit=True)
|
|
wandb.run.name = model_name+ "-" + wandb.run.id
|
|
wandb.run.save()
|
|
|
|
mean_results = weighted_average(results, 'no_of_samples')
|
|
for key, value in mean_results.iteritems():
|
|
run.log({"model_type": model_name, key: value })
|
|
|
|
run.finish()
|
|
|
|
|
|
|