Files
drift/reporting/wandb.py
T
Mark Aron Szulyovszky cc70d3f907 feat(Selection): added toggleable feature selection step into the pipeline (#83)
* feat(Selection): added prototype feature selection python script

* feat(Utils): added some helpers for the future from Advances in Financial ML book

* feat(Selection): added RFECV

* feat(Selection): added configurable feature selection step into pipeline

* feat(Config): added level_1 & level_2 default config, PCA before feature selection process starts

* feat(Selection): added backup feature selector models if current one can't output feature importance, removed unnecessary array for level-2 models

* fix(Training): deal with zero first value coming out of static models

* feat(Sweep): added feature selection sweep

* fix(Sweep): config problem

* fix(Sweep): config

* chore(Utils): removed unnecessary purged k-fold crossval class

* feat(Config): added dimensionality_reduction as a separate flag

* fix(Sweep): config updated

* fix(Sweep): sweep name

* chore(Config): updated level_2 config to the best performing configuation
2021-12-27 21:59:22 +01:00

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:
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):
if wandb is None: return
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]
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()