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
165e81c0
Commit
165e81c0
authored
Mar 02, 2018
by
Dr.李
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed rank bug
parent
c461aee5
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
4 deletions
+30
-4
rank.py
alphamind/data/rank.py
+2
-2
composer.py
alphamind/model/composer.py
+3
-1
test_rank.py
alphamind/tests/data/test_rank.py
+25
-1
No files found.
alphamind/data/rank.py
View file @
165e81c0
...
...
@@ -24,6 +24,6 @@ def rank(x: np.ndarray, groups: Optional[np.ndarray]=None) -> np.ndarray:
curr_idx
=
order
[
start
:
diff_loc
+
1
]
res
[
curr_idx
]
=
x
[
curr_idx
]
.
argsort
(
axis
=
0
)
start
=
diff_loc
+
1
return
res
else
:
return
x
.
argsort
(
axis
=
0
)
\ No newline at end of file
return
x
.
argsort
(
axis
=
0
)
.
argsort
(
axis
=
0
)
alphamind/model/composer.py
View file @
165e81c0
...
...
@@ -16,12 +16,14 @@ from alphamind.model.data_preparing import fetch_predict_phase
from
alphamind.data.engines.universe
import
Universe
from
alphamind.data.engines.sqlengine
import
SqlEngine
from
alphamind.data.winsorize
import
winsorize_normal
from
alphamind.data.rank
import
rank
from
alphamind.data.standardize
import
standardize
from
alphamind.model.loader
import
load_model
PROCESS_MAPPING
=
{
'winsorize_normal'
:
winsorize_normal
,
'standardize'
:
standardize
'standardize'
:
standardize
,
'rank'
:
rank
,
}
...
...
alphamind/tests/data/test_rank.py
View file @
165e81c0
...
...
@@ -6,9 +6,33 @@ Created on 2017-8-8
"""
import
unittest
import
numpy
as
np
import
pandas
as
pd
from
alphamind.data.rank
import
rank
class
TestRank
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
x
=
np
.
random
.
randn
(
1000
,
1
)
self
.
groups
=
np
.
random
.
randint
(
0
,
10
,
1000
)
def
test_rank
(
self
):
pass
\ No newline at end of file
data_rank
=
rank
(
self
.
x
)
sorted_array
=
np
.
zeros_like
(
self
.
x
)
for
i
in
range
(
self
.
x
.
shape
[
0
]):
for
j
in
range
(
self
.
x
.
shape
[
1
]):
sorted_array
[
data_rank
[
i
,
j
],
j
]
=
self
.
x
[
i
,
j
]
arr_diff
=
np
.
diff
(
sorted_array
,
axis
=
0
)
np
.
testing
.
assert_array_less
(
0
,
arr_diff
)
def
test_rank_with_groups
(
self
):
data_rank
=
rank
(
self
.
x
,
groups
=
self
.
groups
)
df
=
pd
.
DataFrame
(
self
.
x
,
index
=
self
.
groups
)
expected_rank
=
df
.
groupby
(
level
=
0
)
.
apply
(
lambda
x
:
x
.
values
.
argsort
()
.
argsort
())
print
(
expected_rank
)
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