1
0
mirror of https://github.com/microsoft/qlib.git synced 2026-07-07 13:00:58 +08:00

dnn model opz

This commit is contained in:
bxdd
2020-11-26 21:15:21 +08:00
parent d3480602c3
commit 52c7076917
3 changed files with 49 additions and 20 deletions

View File

@@ -90,6 +90,7 @@ class DropnaLabel(DropnaProcessor):
return False
class TanhProcess(Processor):
""" Use tanh to process noise data"""
@@ -122,7 +123,6 @@ class ProcessInf(Processor):
return replace_inf(df)
class Fillna(Processor):
"""Process NaN"""
@@ -202,7 +202,8 @@ class CSZScoreNorm(Processor):
def __call__(self, df):
# try not modify original dataframe
cols = get_group_columns(df, self.fields_group)
df[cols] = df[cols].groupby("datetime").apply(lambda df: (df - df.mean()).div(df.std()))
df[cols] = df[cols].groupby("datetime").apply(lambda x: (x - x.mean()).div(x.std()))
return df
@@ -220,3 +221,14 @@ class CSRankNorm(Processor):
t *= 3.46 # NOTE: towards unit std
df[cols] = t
return df
class CSZFillna(Processor):
"""Cross Sectional Fill Nan"""
def __init__(self, fields_group=None):
self.fields_group = fields_group
def __call__(self, df):
cols = get_group_columns(df, self.fields_group)
df[cols] = df[cols].groupby("datetime").apply(lambda x: x.fillna(x.mean()))
return df