qlib
qlib copied to clipboard
score_ic_graph got nan data and throw error
follow office document,analysis score IC
:
pred_df = recorder.load_object("pred.pkl")
pred_df_dates = pred_df.index.get_level_values(level='datetime')
features_df = D.features(D.instruments('csi500'), ['Ref($close, -2)/Ref($close, -1)-1'], pred_df_dates.min(), pred_df_dates.max())
features_df.columns = ['label']
pred_label = pd.concat([features_df, pred], axis=1, sort=True).reindex(features_df.index)
analysis_position.score_ic_graph(pred_label)
but score_ic_graph throw error:
If using all scalar values, you must pass an index
with debug,score_ic.py drop nan:
concat_data.dropna(axis=0, how="any", inplace=True)
print dataframe for debug,the third variable(pred_label) with nan:
is features_df or pred with wrong format cause nan?
i guess because features_df and pred with different MultiIndex,so use below code to transform it:
pred_df = pred_df.swaplevel(0, 1)
pred_df.sort_index(inplace=True)
now,it work without error,is it a right transform?and why office demo without transform?
This issue is stale because it has been open for three months with no activity. Remove the stale label or comment on the issue otherwise this will be closed in 5 days