def fetch_train_data(self, ref_date, alpha_model: ModelBase): return fetch_train_phase(SqlEngine(self.data_source), alpha_model.formulas, ref_date, self.freq, self.universe, self.batch, self.neutralized_risk, self.risk_model, self.pre_process, self.post_process, self.warm_start, fit_target=alpha_model.fit_target)
def fetch_train_data(self, ref_date, alpha_model: ModelBase): return fetch_train_phase(self.engine, alpha_model.formulas, ref_date, self.freq, self.universe, self.batch, self.neutralized_risk, self.risk_model, self.pre_process, self.post_process, self.warm_start)
def train(self, ref_date: str): train_data = fetch_train_phase( self.data_meta.engine, self.data_meta.alpha_factors, ref_date, self.data_meta.freq, self.data_meta.universe, self.data_meta.batch, self.data_meta.neutralized_risk, self.data_meta.risk_model, self.data_meta.pre_process, self.data_meta.post_process, self.data_meta.warm_start) x_values = train_data['train']['x'] y_values = train_data['train']['y'] self.alpha_model.fit(x_values, y_values) self.models[ref_date] = copy.deepcopy(self.alpha_model) self.is_updated = False
def model_train(self, ref_date: str): if not self.is_const_model: if self.cached_data and ref_date in self.scheduled_dates: ref_date = dt.datetime.strptime(ref_date, '%Y-%m-%d') ne_x = self.cached_data['train']['x'][ref_date] ne_y = self.cached_data['train']['y'][ref_date] else: data = fetch_train_phase(self.data_source, self.features, ref_date, self.freq, self.universe, self.batch, self.neutralize_risk, self.risk_model, self.pre_process, self.post_process, self.warm_start) ne_x = data['train']['x'] ne_y = data['train']['y'] self.model.fit(ne_x, ne_y)