Commit 90291216 authored by Dr.李's avatar Dr.李

fixed bug for linear regression model

parent 06b87635
...@@ -27,6 +27,7 @@ from alphamind.model.linearmodel import LinearRegression ...@@ -27,6 +27,7 @@ from alphamind.model.linearmodel import LinearRegression
from alphamind.model.linearmodel import ConstLinearModel from alphamind.model.linearmodel import ConstLinearModel
from alphamind.model.loader import load_model from alphamind.model.loader import load_model
from alphamind.model.data_preparing import fetch_data_package from alphamind.model.data_preparing import fetch_data_package
from alphamind.model.data_preparing import fetch_train_phase
from alphamind.execution.naiveexecutor import NaiveExecutor from alphamind.execution.naiveexecutor import NaiveExecutor
from alphamind.execution.thresholdexecutor import ThresholdExecutor from alphamind.execution.thresholdexecutor import ThresholdExecutor
...@@ -75,6 +76,7 @@ __all__ = [ ...@@ -75,6 +76,7 @@ __all__ = [
'neutralize', 'neutralize',
'factor_tables', 'factor_tables',
'fetch_data_package', 'fetch_data_package',
'fetch_train_phase',
'LinearRegression', 'LinearRegression',
'ConstLinearModel', 'ConstLinearModel',
'load_model', 'load_model',
......
# -*- coding: utf-8 -*-
"""
Created on 2017-11-8
@author: cheng.li
"""
from alphamind.api import *
ref_date = '2017-11-21'
universe_name = ['zz500', 'hs300']
universe = Universe(universe_name, universe_name)
frequency = '5b'
batch = 8
neutralize_risk = ['SIZE'] + industry_styles
engine = SqlEngine()
linear_model_features = ['eps_q', 'roe_q', 'BDTO', 'CFinc1', 'CHV', 'IVR', 'VAL', 'GREV']
training_data = fetch_train_phase(engine,
linear_model_features,
ref_date,
frequency,
universe,
batch,
neutralize_risk,
pre_process=[winsorize_normal, standardize],
post_process=[winsorize_normal, standardize],
warm_start=batch)
model = LinearRegression(linear_model_features, fit_intercept=False)
x = training_data['train']['x']
y = training_data['train']['y'].flatten()
model.fit(x, y)
print(model.impl.coef_)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment