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
cc4f39b3
Commit
cc4f39b3
authored
Apr 29, 2017
by
Dr.李
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added test for grouped neutralize
parent
140b4f7c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
0 deletions
+15
-0
test_neutralize.py
alphamind/tests/data/test_neutralize.py
+15
-0
No files found.
alphamind/tests/data/test_neutralize.py
View file @
cc4f39b3
...
...
@@ -27,6 +27,21 @@ class TestNeutralize(unittest.TestCase):
np
.
testing
.
assert_array_almost_equal
(
calc_res
,
exp_res
)
def
test_neutralize_with_group
(
self
):
y
=
np
.
random
.
randn
(
3000
,
4
)
x
=
np
.
random
.
randn
(
3000
,
10
)
groups
=
np
.
random
.
randint
(
30
,
size
=
3000
)
calc_res
=
neutralize
(
x
,
y
,
groups
)
model
=
LinearRegression
(
fit_intercept
=
False
)
for
i
in
range
(
30
):
curr_x
=
x
[
groups
==
i
]
curr_y
=
y
[
groups
==
i
]
model
.
fit
(
curr_x
,
curr_y
)
exp_res
=
curr_y
-
curr_x
@
model
.
coef_
.
T
np
.
testing
.
assert_array_almost_equal
(
calc_res
[
groups
==
i
],
exp_res
)
if
__name__
==
'__main__'
:
unittest
.
main
()
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