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
268cf073
Commit
268cf073
authored
Feb 09, 2019
by
Dr.李
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed
parent
46c0dc18
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
13 deletions
+12
-13
composer.py
alphamind/model/composer.py
+12
-13
No files found.
alphamind/model/composer.py
View file @
268cf073
...
...
@@ -179,8 +179,8 @@ class Composer:
self
.
is_updated
=
False
self
.
sorted_keys
=
None
def
train
(
self
,
ref_date
:
str
)
->
Tuple
[
ModelBase
,
pd
.
DataFrame
,
pd
.
DataFrame
]:
model
,
x
,
y
=
train_model
(
ref_date
,
self
.
alpha_model
,
self
.
data_meta
)
def
train
(
self
,
ref_date
:
str
,
x
=
None
,
y
=
None
)
->
Tuple
[
ModelBase
,
pd
.
DataFrame
,
pd
.
DataFrame
]:
model
,
x
,
y
=
train_model
(
ref_date
,
self
.
alpha_model
,
self
.
data_meta
,
x
,
y
)
self
.
models
[
ref_date
]
=
model
self
.
is_updated
=
False
return
model
,
x
,
y
...
...
@@ -190,31 +190,30 @@ class Composer:
if
x
is
None
:
return
predict_by_model
(
ref_date
,
model
,
self
.
data_meta
)
else
:
x_values
=
x
.
values
codes
=
x
.
index
return
pd
.
DataFrame
(
model
.
predict
(
x
_values
)
.
flatten
(),
index
=
codes
),
x
return
pd
.
DataFrame
(
model
.
predict
(
x
)
.
flatten
(),
index
=
codes
),
x
def
score
(
self
,
ref_date
:
str
,
x
:
pd
.
DataFrame
=
None
,
y
:
np
.
ndarray
=
None
,
d_type
:
str
=
'test'
)
\
->
Tuple
[
float
,
pd
.
DataFrame
,
pd
.
DataFrame
]:
model
=
self
.
_fetch_latest_model
(
ref_date
)
if
x
is
None
:
if
x
is
None
or
y
is
None
:
if
d_type
==
'test'
:
test_data
=
self
.
data_meta
.
fetch_predict_data
(
ref_date
,
model
)
x
=
test_data
[
'predict'
][
'x'
]
if
y
is
None
:
y
=
test_data
[
'predict'
][
'y'
]
y
=
test_data
[
'predict'
][
'y'
]
else
:
test_data
=
self
.
data_meta
.
fetch_train_data
(
ref_date
,
model
)
x
=
test_data
[
'train'
][
'x'
]
if
y
is
None
:
y
=
test_data
[
'train'
][
'y'
]
y
=
test_data
[
'train'
][
'y'
]
return
model
.
score
(
x
,
y
),
x
,
y
def
ic
(
self
,
ref_date
)
->
Tuple
[
float
,
pd
.
DataFrame
,
pd
.
DataFrame
]:
def
ic
(
self
,
ref_date
,
x
=
None
,
y
=
None
)
->
Tuple
[
float
,
pd
.
DataFrame
,
pd
.
DataFrame
]:
model
=
self
.
_fetch_latest_model
(
ref_date
)
test_data
=
self
.
data_meta
.
fetch_predict_data
(
ref_date
,
model
)
x
=
test_data
[
'predict'
][
'x'
]
y
=
test_data
[
'predict'
][
'y'
]
if
x
is
None
or
y
is
None
:
test_data
=
self
.
data_meta
.
fetch_predict_data
(
ref_date
,
model
)
x
=
test_data
[
'predict'
][
'x'
]
y
=
test_data
[
'predict'
][
'y'
]
return
model
.
ic
(
x
,
y
),
x
,
y
def
_fetch_latest_model
(
self
,
ref_date
)
->
ModelBase
:
...
...
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