Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bob.learn.em
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
bob
bob.learn.em
Commits
1921b8ad
Verified
Commit
1921b8ad
authored
1 year ago
by
Yannick DAYER
Browse files
Options
Downloads
Patches
Plain Diff
tests(kmeans): adapt results to last changes.
parent
dbe31f76
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/test_kmeans.py
+8
-9
8 additions, 9 deletions
tests/test_kmeans.py
with
8 additions
and
9 deletions
tests/test_kmeans.py
+
8
−
9
View file @
1921b8ad
...
@@ -94,27 +94,26 @@ def test_KMeansMachine_var_and_weight():
...
@@ -94,27 +94,26 @@ def test_KMeansMachine_var_and_weight():
np
.
testing
.
assert_equal
(
weights
,
weights_result
)
np
.
testing
.
assert_equal
(
weights
,
weights_result
)
def
test_kmeans_fit
():
def
test_kmeans_fit_parallel
():
np
.
random
.
seed
(
0
)
rs_gen
=
np
.
random
.
RandomState
(
0
)
data1
=
np
.
random
.
normal
(
loc
=
1
,
size
=
(
2000
,
3
))
data1
=
rs_gen
.
normal
(
loc
=
1
,
size
=
(
2000
,
3
))
data2
=
np
.
random
.
normal
(
loc
=-
1
,
size
=
(
2000
,
3
))
data2
=
rs_gen
.
normal
(
loc
=-
1
,
size
=
(
2000
,
3
))
print
(
data1
.
min
(),
data1
.
max
())
data
=
np
.
vstack
([
data1
,
data2
])
print
(
data2
.
min
(),
data2
.
max
())
data
=
np
.
concatenate
([
data1
,
data2
],
axis
=
0
)
for
transform
in
(
to_numpy
,
to_dask_array
):
for
transform
in
(
to_numpy
,
to_dask_array
):
data
=
transform
(
data
)
data
=
transform
(
data
)
machine
=
KMeansMachine
(
2
,
random_state
=
0
).
fit
(
data
)
machine
=
KMeansMachine
(
2
,
random_state
=
0
).
fit
(
data
)
centroids
=
machine
.
centroids_
[
np
.
argsort
(
machine
.
centroids_
[:,
0
])]
centroids
=
machine
.
centroids_
[
np
.
argsort
(
machine
.
centroids_
[:,
0
])]
expected
=
[
expected
=
[
[
-
1.07173464
,
-
1.06200356
,
-
1.0072492
0
],
[
-
1.07173464
,
-
1.06200356
,
-
1.0072492
],
[
0.99479125
,
0.99665564
,
0.97689017
],
[
0.99479125
,
0.99665564
,
0.97689017
],
]
]
np
.
testing
.
assert_almost_equal
(
centroids
,
expected
,
decimal
=
7
)
np
.
testing
.
assert_almost_equal
(
centroids
,
expected
,
decimal
=
7
)
# Early stop
# Early stop
machine
=
KMeansMachine
(
2
,
max_iter
=
2
)
machine
=
KMeansMachine
(
2
,
max_iter
=
2
,
random_state
=
0
)
machine
.
fit
(
data
)
machine
.
fit
(
data
)
np
.
testing
.
assert_almost_equal
(
centroids
,
expected
,
decimal
=
7
)
def
test_kmeans_fit_init_pp
():
def
test_kmeans_fit_init_pp
():
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment