pykt.utils package

Submodules

pykt.utils.utils module

pykt.utils.utils.debug_print(text, fuc_name='')[source]

Printing text with function name.

Parameters
  • text (str) – the text will print

  • fuc_name (str, optional) – _description_. Defaults to “”.

pykt.utils.utils.get_now_time()[source]

Return the time string, the format is %Y-%m-%d %H:%M:%S

Returns

now time

Return type

str

pykt.utils.utils.set_seed(seed)[source]

Set the global random seed.

Parameters

seed (int) – random seed

pykt.utils.wandb_utils module

class pykt.utils.wandb_utils.WandbUtils(user, project_name)[source]

Bases: object

wandb utils

wandb_api = WandbUtils(user=’tabchen’, project_name=’pykt_iekt_pred’) >self.sweep_dict is {‘mx2tvwfy’: [‘mx2tvwfy’]}

check_sweep_by_pattern(sweep_pattern, metric='testauc', metric_type='max', min_run_num=300, patience=100, force_check_df=False)[source]

Check sweeps by pattern

Parameters
  • sweep_pattern (str) – check the sweeps which sweep names start with sweep_pattern

  • metric (str, optional) – the metric to check. Defaults to testauc.

  • metric_type (str, optional) – the type of metric max or min. Defaults to max.

  • min_run_num (int, optional) – the min run num to check. Defaults to 300.

  • patience (int, optional) – the patience to stop. Defaults to 100.

  • force_check_df – always check df, defalut is false.

Returns

the list of dict, each dict is {“id”:id,”state”:state,’df’:df,”num_run”:num_run}, state is ‘RUNNING’, ‘CANCELED’ or ‘FINISHED’,df is the df of the sweep, num_run is the num of sweep run, -1 mean the sweep is finished to save time we will not check it again.

Return type

list

check_sweep_early_stop(id, input_type='sweep_name', metric='testauc', metric_type='max', min_run_num=300, patience=100, force_check_df=False)[source]

Check sweep early stop

Parameters
  • id (str) – the sweep name or sweep id.

  • input_type (str, optional) – the type of id. Defaults to sweep_name.

  • metric (str, optional) – the metric to check. Defaults to testauc.

  • metric_type (str, optional) – the type of metric max or min. Defaults to max.

  • min_run_num (int, optional) – the min run num to check. Defaults to 300.

  • patience (int, optional) – the patience to stop. Defaults to 100.

  • force_check_df – always check df, defalut is false.

Returns

{“state”:state,’df’:df,”num_run”:num_run}, state is ‘RUNNING’, ‘CANCELED’ or ‘FINISHED’,df is the df of the sweep, num_run is the num of sweep run, -1 mean the sweep is finished to save time we will not check it again.

Return type

dict

get_df(id, input_type='sweep_name')[source]

Get one sweep result

Parameters
  • id (str) – the sweep name or sweep id.

  • input_type (str, optional) – the type of id. Defaults to sweep_name.

Returns

_description_

Return type

pd.Data

get_multi_df(id_list=[], input_type='sweep_name')[source]

Get multi sweep result

Parameters
  • id_list (list) – the list of sweep name or sweep id.

  • input_type (str, optional) – the type of id. Defaults to sweep_name.

Returns

_description_

Return type

_type_

get_sweep_dict()[source]

Get sweep dict

get_sweep_run_num(id, input_type='sweep_name')[source]

Get sweep run num

Parameters
  • id (str) – the sweep name or sweep id.

  • input_type (str, optional) – the type of id. Defaults to sweep_name.

Returns

the num of sweep run

Return type

int

get_sweep_status(id, input_type='sweep_name')[source]

Get sweep run status

Parameters
  • id (str) – the sweep name or sweep id.

  • input_type (str, optional) – the type of id. Defaults to sweep_name.

Returns

the state of sweep. ‘RUNNING’, ‘CANCELED’ or ‘FINISHED’

Return type

str

pykt.utils.wandb_utils.get_runs_result(runs, drop_duplicate=False)[source]

Module contents