mirror of
https://github.com/microsoft/qlib.git
synced 2026-07-13 07:46:53 +08:00
recorder refine; signalTemp; fixbug
This commit is contained in:
0
qlib/contrib/eva/__init__.py
Normal file
0
qlib/contrib/eva/__init__.py
Normal file
32
qlib/contrib/eva/alpha.py
Normal file
32
qlib/contrib/eva/alpha.py
Normal file
@@ -0,0 +1,32 @@
|
||||
'''
|
||||
Here is a batch of evaluation functions.
|
||||
|
||||
The interface should be redesigned carefully in the future.
|
||||
'''
|
||||
import pandas as pd
|
||||
|
||||
|
||||
def calc_ic(pred: pd.Series, label: pd.Series, date_col='datetime', dropna=False) -> (pd.Series, pd.Series):
|
||||
"""calc_ic.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
pred :
|
||||
pred
|
||||
label :
|
||||
label
|
||||
date_col :
|
||||
date_col
|
||||
|
||||
Returns
|
||||
-------
|
||||
(pd.Series, pd.Series)
|
||||
ic and rank ic
|
||||
"""
|
||||
df = pd.DataFrame({'pred': pred, 'label': label})
|
||||
ic = df.groupby(date_col).apply(lambda df: df['pred'].corr(df['label']))
|
||||
ric = df.groupby(date_col).apply(lambda df: df['pred'].corr(df['label'], method='spearman'))
|
||||
if dropna:
|
||||
return ic.dropna(), ric.dropna()
|
||||
else:
|
||||
return ic, ric
|
||||
@@ -64,7 +64,7 @@ class LGBModel(ModelFT):
|
||||
def predict(self, dataset):
|
||||
if self.model is None:
|
||||
raise ValueError("model is not fitted yet!")
|
||||
x_test = dataset.prepare("test", col_set="feature")
|
||||
x_test = dataset.prepare("test", col_set="feature", data_key=DataHandlerLP.DK_I)
|
||||
return pd.Series(self.model.predict(np.squeeze(x_test.values)), index=x_test.index)
|
||||
|
||||
def finetune(self, dataset: DatasetH, num_boost_round=10, verbose_eval=20):
|
||||
|
||||
Reference in New Issue
Block a user