Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
skais
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
Raphael Sturgis
skais
Commits
a65fed84
Commit
a65fed84
authored
3 years ago
by
Raphael Sturgis
Browse files
Options
Downloads
Plain Diff
Merge branch 'develop' into 'main'
Develop See merge request
!1
parents
62d97a52
bf3d0348
No related branches found
No related tags found
2 merge requests
!15
Resolve "normalisation should raise exception when bad arguments given"
,
!1
Develop
Changes
21
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
skais/utils/stats.py
+39
-0
39 additions, 0 deletions
skais/utils/stats.py
with
39 additions
and
0 deletions
skais/utils/stats.py
0 → 100644
+
39
−
0
View file @
a65fed84
import
math
import
ot
from
scipy.spatial.distance
import
jensenshannon
import
numpy
as
np
def
compare_label_distributions
(
distribution1
,
distribution2
):
assert
len
(
distribution1
)
==
len
(
distribution2
)
n_classes
=
len
(
distribution1
)
if
sum
(
distribution1
)
!=
1
:
distribution1
=
distribution1
/
sum
(
distribution1
)
if
sum
(
distribution2
)
!=
1
:
distribution2
=
distribution2
/
sum
(
distribution2
)
return
ot
.
emd2
(
distribution1
,
distribution2
,
[[
1
if
i
!=
j
else
0
for
i
in
range
(
n_classes
)]
for
j
in
range
(
n_classes
)])
def
compare_x_knowing_y_jsd
(
d1
,
d2
):
jsd
=
0
for
h1
,
h2
in
zip
(
d1
,
d2
):
for
i
in
range
(
h1
.
shape
[
0
]):
jsd
+=
jensenshannon
(
h1
[
i
,
:],
h2
[
i
,
:])
return
jsd
/
(
len
(
d1
)
*
d1
[
0
].
shape
[
0
])
def
calc_std_dev
(
angles
):
sin
=
0
cos
=
0
for
angle
in
angles
:
sin
+=
np
.
sin
(
angle
*
(
math
.
pi
/
180.0
))
cos
+=
np
.
cos
(
angle
*
(
math
.
pi
/
180.0
))
sin
/=
len
(
angles
)
cos
/=
len
(
angles
)
stddev
=
math
.
sqrt
(
-
math
.
log
(
min
(
1
,
sin
*
sin
+
cos
*
cos
)))
return
stddev
This diff is collapsed.
Click to expand it.
Prev
1
2
Next
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