mirror of
https://github.com/microsoft/qlib.git
synced 2026-07-16 09:11:00 +08:00
update format
This commit is contained in:
@@ -7,7 +7,10 @@ import pandas as pd
|
|||||||
|
|
||||||
from typing import Tuple
|
from typing import Tuple
|
||||||
|
|
||||||
def calc_prec(pred: pd.Series, label: pd.Series, date_col="datetime", quantile: float = 0.2, dropna=False, is_alpha=False) -> Tuple[pd.Series, pd.Series]:
|
|
||||||
|
def calc_prec(
|
||||||
|
pred: pd.Series, label: pd.Series, date_col="datetime", quantile: float = 0.2, dropna=False, is_alpha=False
|
||||||
|
) -> Tuple[pd.Series, pd.Series]:
|
||||||
"""calculate the precision
|
"""calculate the precision
|
||||||
pred :
|
pred :
|
||||||
pred
|
pred
|
||||||
@@ -26,7 +29,6 @@ def calc_prec(pred: pd.Series, label: pd.Series, date_col="datetime", quantile:
|
|||||||
if int(1 / quantile) >= len(label.index.get_level_values(1).unique()):
|
if int(1 / quantile) >= len(label.index.get_level_values(1).unique()):
|
||||||
raise ValueError("Need more instruments to calculate precision")
|
raise ValueError("Need more instruments to calculate precision")
|
||||||
|
|
||||||
|
|
||||||
df = pd.DataFrame({"pred": pred, "label": label})
|
df = pd.DataFrame({"pred": pred, "label": label})
|
||||||
if dropna:
|
if dropna:
|
||||||
df.dropna(inplace=True)
|
df.dropna(inplace=True)
|
||||||
|
|||||||
@@ -160,6 +160,7 @@ class HFSignalRecord(SignalRecord):
|
|||||||
"""
|
"""
|
||||||
This is the Signal Analysis Record class that generates the analysis results such as IC and IR. This class inherits the ``RecordTemp`` class.
|
This is the Signal Analysis Record class that generates the analysis results such as IC and IR. This class inherits the ``RecordTemp`` class.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
artifact_path = "hg_sig_analysis"
|
artifact_path = "hg_sig_analysis"
|
||||||
|
|
||||||
def __init__(self, recorder, **kwargs):
|
def __init__(self, recorder, **kwargs):
|
||||||
@@ -177,7 +178,7 @@ class HFSignalRecord(SignalRecord):
|
|||||||
"Rank IC": ric.mean(),
|
"Rank IC": ric.mean(),
|
||||||
"Rank ICIR": ric.mean() / ric.std(),
|
"Rank ICIR": ric.mean() / ric.std(),
|
||||||
"Long precision": long_pre.mean(),
|
"Long precision": long_pre.mean(),
|
||||||
"Short precision": short_pre.mean()
|
"Short precision": short_pre.mean(),
|
||||||
}
|
}
|
||||||
objects = {"ic.pkl": ic, "ric.pkl": ric}
|
objects = {"ic.pkl": ic, "ric.pkl": ric}
|
||||||
objects.update({"long_pre.pkl": long_pre, "short_pre.pkl": short_pre})
|
objects.update({"long_pre.pkl": long_pre, "short_pre.pkl": short_pre})
|
||||||
@@ -199,7 +200,12 @@ class HFSignalRecord(SignalRecord):
|
|||||||
pprint(metrics)
|
pprint(metrics)
|
||||||
|
|
||||||
def list(self):
|
def list(self):
|
||||||
paths = [self.get_path("ic.pkl"), self.get_path("ric.pkl"), self.get_path("long_pre.pkl"), self.get_path("short_pre.pkl")]
|
paths = [
|
||||||
|
self.get_path("ic.pkl"),
|
||||||
|
self.get_path("ric.pkl"),
|
||||||
|
self.get_path("long_pre.pkl"),
|
||||||
|
self.get_path("short_pre.pkl"),
|
||||||
|
]
|
||||||
paths.extend([self.get_path("long_short_r.pkl"), self.get_path("long_avg_r.pkl")])
|
paths.extend([self.get_path("long_short_r.pkl"), self.get_path("long_avg_r.pkl")])
|
||||||
return paths
|
return paths
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user