def test_export_load(self, data_loader, tmpdir): f1, target, model = self._create_base_components() pipeline = BasePipeline(feature=f1, target=target, model=model, metric=median_absolute_relative_error, out_name=None) res = pipeline.fit(data_loader, tickers) df = pipeline.execute(data_loader, tickers) pipeline.export_core('{}/pipeline'.format(str(tmpdir))) pipeline = BasePipeline.load('{}/pipeline.pickle'.format(str(tmpdir))) df1 = pipeline.execute(data_loader, tickers[:100]) np.testing.assert_array_equal(df['y_0'].values, df1['y_0'].values)
agg_day_counts=pipeline_config['agg_day_counts'], max_back_quarter=pipeline_config['max_back_quarter']) feature = FeatureMerger(fc1, fc2, on='ticker') feature = FeatureMerger(feature, fc3, on=['ticker', 'date']) feature = FeatureMerger(feature, fc4, on=['ticker', 'date']) target = DailyAggTarget(col='marketcap', horizon=pipeline_config['target_horizon'], foo=down_std_norm) base_models = [ lgbm.sklearn.LGBMRegressor(), ctb.CatBoostRegressor(verbose=False) ] ansamble = AnsambleModel(base_models=base_models, bagging_fraction=0.7, model_cnt=20) model = TimeSeriesOOFModel(ansamble, time_column='date', fold_cnt=20) pipeline = BasePipeline(feature=feature, target=target, model=model, metric=median_absolute_relative_error) result = pipeline.fit(data_loader, ticker_list) print(result) pipeline.export_core('models_data/marketcap_down_std')
agg_day_counts=pipeline_config['agg_day_counts'], max_back_quarter=pipeline_config['max_back_quarter']) feature = FeatureMerger(fc1, fc2, on='ticker') feature = FeatureMerger(feature, fc3, on=['ticker', 'date']) target = QuarterlyTarget(col='marketcap', quarter_shift=0) base_models = [LogExpModel(lgbm.sklearn.LGBMRegressor()), LogExpModel(ctb.CatBoostRegressor(verbose=False))] ansamble = AnsambleModel( base_models=base_models, bagging_fraction=pipeline_config['bagging_fraction'], model_cnt=pipeline_config['model_cnt']) model = GroupedOOFModel(ansamble, group_column='ticker', fold_cnt=5) pipeline = BasePipeline(feature=feature, target=target, model=model, metric=median_absolute_relative_error) result = pipeline.fit(data_loader, ticker_list) print(result) pipeline.export_core('models_data/marketcap')
# normalized and there are no leakage. fc3 = DailyAggQuarterFeatures(columns=DAILY_AGG_COLUMNS, agg_day_counts=AGG_DAY_COUNTS, max_back_quarter=MAX_BACK_QUARTER) feature = FeatureMerger(fc1, fc2, on='ticker') feature = FeatureMerger(feature, fc3, on=['ticker', 'date']) target = QuarterlyTarget(col='marketcap', quarter_shift=0) base_models = [ LogExpModel(lgbm.sklearn.LGBMRegressor()), LogExpModel(ctb.CatBoostRegressor(verbose=False)) ] ensemble = EnsembleModel(base_models=base_models, bagging_fraction=BAGGING_FRACTION, model_cnt=MODEL_CNT) model = GroupedOOFModel(ensemble, group_column='ticker', fold_cnt=FOLD_CNT) pipeline = BasePipeline(feature=feature, target=target, model=model, metric=median_absolute_relative_error, out_name=OUT_NAME) result = pipeline.fit(data_loader, ticker_list) print(result) pipeline.export_core(SAVE_PATH)