def calc_all_ic(pred_dict_all, label, date_col="datetime", dropna=False, n_jobs=-1): """calc_all_ic. Parameters ---------- pred_dict_all : A dict like {<method_name>: <prediction>} label: A pd.Series of label values Returns ------- {'Q2+IND_z': {'ic': <ic series like> 2016-01-04 -0.057407 ... 2020-05-28 0.183470 2020-05-29 0.171393 'ric': <rank ic series like> 2016-01-04 -0.040888 ... 2020-05-28 0.236665 2020-05-29 0.183886 } ...} """ pred_all_ics = {} for k, pred in pred_dict_all.items(): pred_all_ics[k] = DelayedDict(["ic", "ric"], delayed(calc_ic)(pred, label, date_col=date_col, dropna=dropna)) pred_all_ics = complex_parallel(Parallel(n_jobs=n_jobs, verbose=10), pred_all_ics) return pred_all_ics
def pred_autocorr_all(pred_dict, n_jobs=-1, **kwargs): """ calculate auto correlation for pred_dict Parameters ---------- pred_dict : dict A dict like {<method_name>: <prediction>} kwargs : all these arguments will be passed into pred_autocorr """ ac_dict = {} for k, pred in pred_dict.items(): ac_dict[k] = delayed(pred_autocorr)(pred, **kwargs) return complex_parallel(Parallel(n_jobs=n_jobs, verbose=10), ac_dict)