Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
A
alpha-mind
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dr.李
alpha-mind
Commits
43779306
Commit
43779306
authored
Jan 23, 2018
by
Dr.李
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update models
parent
139bddec
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
17 deletions
+23
-17
transformer.py
alphamind/data/transformer.py
+2
-1
linearmodel.py
alphamind/model/linearmodel.py
+9
-9
modelbase.py
alphamind/model/modelbase.py
+4
-3
treemodel.py
alphamind/model/treemodel.py
+8
-4
No files found.
alphamind/data/transformer.py
View file @
43779306
...
...
@@ -5,6 +5,7 @@ Created on 2017-8-23
@author: cheng.li
"""
import
copy
import
pandas
as
pd
from
PyFin.api
import
pyFinAssert
from
PyFin.Analysis.SecurityValueHolders
import
SecurityValueHolder
...
...
@@ -58,7 +59,7 @@ class Transformer(object):
def
__init__
(
self
,
expressions
):
expression_dict
,
expression_dependency
=
\
factor_translator
(
expressions
)
factor_translator
(
copy
.
deepcopy
(
expressions
)
)
if
expression_dict
:
self
.
names
=
sorted
(
expression_dict
.
keys
())
...
...
alphamind/model/linearmodel.py
View file @
43779306
...
...
@@ -32,9 +32,9 @@ class ConstLinearModel(ModelBase):
def
__init__
(
self
,
features
:
list
=
None
,
weights
:
np
.
ndarray
=
None
,
**
kwargs
):
super
()
.
__init__
(
features
,
**
kwarg
s
)
formulas
:
dict
=
None
,
weights
:
np
.
ndarray
=
None
):
super
()
.
__init__
(
features
,
formulas
=
formula
s
)
if
features
is
not
None
and
weights
is
not
None
:
pyFinAssert
(
len
(
features
)
==
len
(
weights
),
ValueError
,
...
...
@@ -57,8 +57,8 @@ class ConstLinearModel(ModelBase):
class
LinearRegression
(
ModelBase
):
def
__init__
(
self
,
features
:
list
=
None
,
fit_intercept
:
bool
=
False
,
**
kwargs
):
super
()
.
__init__
(
features
,
**
kwarg
s
)
def
__init__
(
self
,
features
:
list
=
None
,
f
ormulas
:
dict
=
None
,
f
it_intercept
:
bool
=
False
,
**
kwargs
):
super
()
.
__init__
(
features
,
formulas
=
formula
s
)
self
.
impl
=
LinearRegressionImpl
(
fit_intercept
=
fit_intercept
,
**
kwargs
)
self
.
trained_time
=
None
...
...
@@ -85,8 +85,8 @@ class LinearRegression(ModelBase):
class
LassoRegression
(
ModelBase
):
def
__init__
(
self
,
alpha
=
0.01
,
features
:
list
=
None
,
fit_intercept
:
bool
=
False
,
**
kwargs
):
super
()
.
__init__
(
features
,
**
kwarg
s
)
def
__init__
(
self
,
alpha
=
0.01
,
features
:
list
=
None
,
f
ormulas
:
dict
=
None
,
f
it_intercept
:
bool
=
False
,
**
kwargs
):
super
()
.
__init__
(
features
,
formulas
=
formula
s
)
self
.
impl
=
Lasso
(
alpha
=
alpha
,
fit_intercept
=
fit_intercept
,
**
kwargs
)
self
.
trained_time
=
None
...
...
@@ -113,8 +113,8 @@ class LassoRegression(ModelBase):
class
LogisticRegression
(
ModelBase
):
def
__init__
(
self
,
features
:
list
=
None
,
fit_intercept
:
bool
=
False
,
**
kwargs
):
super
()
.
__init__
(
features
,
**
kwarg
s
)
def
__init__
(
self
,
features
:
list
=
None
,
f
ormulas
:
dict
=
None
,
f
it_intercept
:
bool
=
False
,
**
kwargs
):
super
()
.
__init__
(
features
,
formulas
=
formula
s
)
self
.
impl
=
LogisticRegressionImpl
(
fit_intercept
=
fit_intercept
,
**
kwargs
)
def
save
(
self
)
->
dict
:
...
...
alphamind/model/modelbase.py
View file @
43779306
...
...
@@ -6,6 +6,7 @@ Created on 2017-9-4
"""
import
abc
import
copy
import
arrow
import
numpy
as
np
from
alphamind.utilities
import
alpha_logger
...
...
@@ -15,13 +16,13 @@ from alphamind.utilities import decode
class
ModelBase
(
metaclass
=
abc
.
ABCMeta
):
def
__init__
(
self
,
features
:
list
=
None
,
formulas
:
dict
=
None
,
**
kwargs
):
def
__init__
(
self
,
features
:
list
=
None
,
formulas
:
dict
=
None
):
if
features
is
not
None
:
self
.
features
=
list
(
features
)
else
:
self
.
features
=
formulas
self
.
features
=
None
self
.
impl
=
None
self
.
formulas
=
formulas
self
.
formulas
=
copy
.
deepcopy
(
formulas
)
self
.
trained_time
=
None
def
fit
(
self
,
x
:
np
.
ndarray
,
y
:
np
.
ndarray
):
...
...
alphamind/model/treemodel.py
View file @
43779306
...
...
@@ -61,8 +61,9 @@ class RandomForestClassifier(ModelBase):
n_estimators
:
int
=
100
,
max_features
:
str
=
'auto'
,
features
:
List
=
None
,
formulas
:
dict
=
None
,
**
kwargs
):
super
()
.
__init__
(
features
,
**
kwarg
s
)
super
()
.
__init__
(
features
,
formulas
=
formula
s
)
self
.
impl
=
RandomForestClassifierImpl
(
n_estimators
=
n_estimators
,
max_features
=
max_features
,
**
kwargs
)
...
...
@@ -96,8 +97,9 @@ class XGBRegressor(ModelBase):
learning_rate
:
float
=
0.1
,
max_depth
:
int
=
3
,
features
:
List
=
None
,
formulas
:
dict
=
None
,
**
kwargs
):
super
()
.
__init__
(
features
,
**
kwarg
s
)
super
()
.
__init__
(
features
,
formulas
=
formula
s
)
self
.
impl
=
XGBRegressorImpl
(
n_estimators
=
n_estimators
,
learning_rate
=
learning_rate
,
max_depth
=
max_depth
,
...
...
@@ -131,8 +133,9 @@ class XGBClassifier(ModelBase):
learning_rate
:
float
=
0.1
,
max_depth
:
int
=
3
,
features
:
List
=
None
,
formulas
:
dict
=
None
,
**
kwargs
):
super
()
.
__init__
(
features
,
**
kwarg
s
)
super
()
.
__init__
(
features
,
formulas
=
formula
s
)
self
.
impl
=
XGBClassifierImpl
(
n_estimators
=
n_estimators
,
learning_rate
=
learning_rate
,
max_depth
=
max_depth
,
...
...
@@ -173,9 +176,10 @@ class XGBTrainer(ModelBase):
subsample
=
1.
,
colsample_bytree
=
1.
,
features
:
List
=
None
,
formulas
:
dict
=
None
,
random_state
=
0
,
**
kwargs
):
super
()
.
__init__
(
features
)
super
()
.
__init__
(
features
,
formulas
=
formulas
)
self
.
params
=
{
'silent'
:
1
,
'objective'
:
objective
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment