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
243e8f69
Commit
243e8f69
authored
3 years ago
by
Raphael
Browse files
Options
Downloads
Patches
Plain Diff
Normalisation improvements
parent
af593660
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!12
version 0.2a
,
!10
Resolve "Image creation bugs with 0 size windows"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
skais/ais/ais_points.py
+51
-27
51 additions, 27 deletions
skais/ais/ais_points.py
with
51 additions
and
27 deletions
skais/ais/ais_points.py
+
51
−
27
View file @
243e8f69
...
...
@@ -73,35 +73,59 @@ class AISPoints:
self
.
df
=
self
.
df
[
self
.
df
[
"
heading
"
]
<=
360
]
self
.
df
=
self
.
df
[
self
.
df
[
"
heading
"
]
>=
0
]
def
normalize
(
self
,
features
,
normalization_type
=
"
min-max
"
):
normalization_dict
=
{}
if
normalization_
type
==
"
min-max
"
:
for
f
in
features
:
minimum
=
self
.
df
[
f
].
min
()
max
imum
=
self
.
df
[
f
].
m
ax
()
diff
=
(
maximum
-
minimum
)
if
diff
=
=
0
:
print
(
"
Warning: diff = %d
"
,
diff
)
diff
=
1
self
.
df
[
f
]
=
(
self
.
df
[
f
]
-
minimum
)
/
diff
normalization_dict
[
f
"
{
f
}
_minimum
"
]
=
minimum
normalization_dict
[
f
"
{
f
}
_m
ax
imum
"
]
=
m
ax
imum
elif
normalization_type
==
"
standardization
"
:
normali
s
ation_
factors
=
(
"
standardization
"
,
{})
for
f
in
features
:
mean
=
self
.
df
[
f
].
mean
()
std
=
self
.
df
[
f
].
std
()
if
std
==
0
:
print
(
"
Warning: std = %d
"
,
std
)
std
=
1
self
.
df
[
f
]
=
(
self
.
df
[
f
]
-
mean
)
/
std
normalization_dict
[
f
"
{
f
}
_mean
"
]
=
mean
normalization_dict
[
f
"
{
f
}
_std
"
]
=
std
def
normalize
(
self
,
features
,
normalization_type
=
"
min-max
"
,
normalization_dict
=
None
):
if
normalization_dict
is
None
:
normalization_
dict
=
{
'
normalization_type
'
:
normalization_type
}
if
normalization_type
==
"
min-max
"
:
for
f
in
features
:
min
imum
=
self
.
df
[
f
].
m
in
()
maximum
=
self
.
df
[
f
].
max
(
)
diff
=
(
maximum
-
minimum
)
if
diff
==
0
:
print
(
"
Warning: diff = %d
"
,
diff
)
diff
=
1
self
.
df
[
f
]
=
(
self
.
df
[
f
]
-
minimum
)
/
diff
normalization_dict
[
f
"
{
f
}
_m
in
imum
"
]
=
m
in
imum
normalization_dict
[
f
"
{
f
}
_maximum
"
]
=
maximum
elif
normali
z
ation_
type
=
=
"
standardization
"
:
for
f
in
features
:
mean
=
self
.
df
[
f
].
mean
()
std
=
self
.
df
[
f
].
std
()
if
std
==
0
:
print
(
"
Warning: std = %d
"
,
std
)
std
=
1
self
.
df
[
f
]
=
(
self
.
df
[
f
]
-
mean
)
/
std
normalization_dict
[
f
"
{
f
}
_mean
"
]
=
mean
normalization_dict
[
f
"
{
f
}
_std
"
]
=
std
else
:
raise
ValueError
(
f
"
{
normalization_type
}
not a valid normalization method. Must be on of [min-max,
"
f
"
standardization]
"
)
else
:
raise
ValueError
(
f
"
{
normalization_type
}
not a valid normalization method. Must be on of [min-max,
"
f
"
standardization]
"
)
normalization_type
=
normalization_dict
[
'
normalization_type
'
]
if
normalization_type
==
"
min-max
"
:
for
f
in
features
:
minimum
=
normalization_dict
[
f
"
{
f
}
_minimum
"
]
maximum
=
normalization_dict
[
f
"
{
f
}
_maximum
"
]
diff
=
(
maximum
-
minimum
)
if
diff
==
0
:
print
(
"
Warning: diff = %d
"
,
diff
)
diff
=
1
self
.
df
[
f
]
=
(
self
.
df
[
f
]
-
minimum
)
/
diff
elif
normalization_type
==
"
standardization
"
:
for
f
in
features
:
mean
=
normalization_dict
[
f
"
{
f
}
_mean
"
]
std
=
normalization_dict
[
f
"
{
f
}
_std
"
]
if
std
==
0
:
print
(
"
Warning: std = %d
"
,
std
)
std
=
1
self
.
df
[
f
]
=
(
self
.
df
[
f
]
-
mean
)
/
std
else
:
raise
ValueError
(
f
"
{
normalization_type
}
not a valid normalization method. Must be on of [min-max,
"
f
"
standardization]
"
)
return
normalization_type
,
normalization_dict
# New features
...
...
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