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
4409c54d
Commit
4409c54d
authored
Sep 15, 2017
by
Dr.李
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
greatly enhance the performance of batch processing
parent
302e8c2c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
11 deletions
+21
-11
data_preparing.py
alphamind/model/data_preparing.py
+21
-11
No files found.
alphamind/model/data_preparing.py
View file @
4409c54d
...
...
@@ -5,6 +5,7 @@ Created on 2017-8-24
@author: cheng.li
"""
import
bisect
import
datetime
as
dt
import
numpy
as
np
import
pandas
as
pd
...
...
@@ -123,11 +124,15 @@ def batch_processing(x_values,
for
i
,
start
in
enumerate
(
groups
[:
-
batch
]):
end
=
groups
[
i
+
batch
]
index
=
(
group_label
>=
start
)
&
(
group_label
<
end
)
this_raw_x
=
x_values
[
index
]
this_raw_y
=
y_values
[
index
]
left_index
=
bisect
.
bisect_left
(
group_label
,
start
)
right_index
=
bisect
.
bisect_left
(
group_label
,
end
)
this_raw_x
=
x_values
[
left_index
:
right_index
]
this_raw_y
=
y_values
[
left_index
:
right_index
]
if
risk_exp
is
not
None
:
this_risk_exp
=
risk_exp
[
index
]
this_risk_exp
=
risk_exp
[
left_index
:
right_
index
]
else
:
this_risk_exp
=
None
...
...
@@ -141,12 +146,14 @@ def batch_processing(x_values,
risk_factors
=
this_risk_exp
,
post_process
=
post_process
)
index
=
(
group_label
>
start
)
&
(
group_label
<=
end
)
sub_dates
=
group_label
[
index
]
this_raw_x
=
x_values
[
index
]
left_index
=
bisect
.
bisect_right
(
group_label
,
start
)
right_index
=
bisect
.
bisect_right
(
group_label
,
end
)
sub_dates
=
group_label
[
left_index
:
right_index
]
this_raw_x
=
x_values
[
left_index
:
right_index
]
if
risk_exp
is
not
None
:
this_risk_exp
=
risk_exp
[
index
]
this_risk_exp
=
risk_exp
[
left_index
:
right_
index
]
else
:
this_risk_exp
=
None
...
...
@@ -154,15 +161,18 @@ def batch_processing(x_values,
pre_process
=
pre_process
,
risk_factors
=
this_risk_exp
,
post_process
=
post_process
)
predict_x_buckets
[
end
]
=
ne_x
[
sub_dates
==
end
]
this_raw_y
=
y_values
[
index
]
inner_left_index
=
bisect
.
bisect_left
(
sub_dates
,
end
)
inner_right_index
=
bisect
.
bisect_right
(
sub_dates
,
end
)
predict_x_buckets
[
end
]
=
ne_x
[
inner_left_index
:
inner_right_index
]
this_raw_y
=
y_values
[
left_index
:
right_index
]
if
len
(
this_raw_y
)
>
0
:
ne_y
=
factor_processing
(
this_raw_y
,
pre_process
=
pre_process
,
risk_factors
=
this_risk_exp
,
post_process
=
post_process
)
predict_y_buckets
[
end
]
=
ne_y
[
sub_dates
==
end
]
predict_y_buckets
[
end
]
=
ne_y
[
inner_left_index
:
inner_right_index
]
return
train_x_buckets
,
train_y_buckets
,
predict_x_buckets
,
predict_y_buckets
...
...
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