Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PARADISE
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
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
SIG
Theses
Pierre Lotte
PARADISE
Commits
e656158b
Commit
e656158b
authored
8 months ago
by
Pierre LOTTE
Browse files
Options
Downloads
Patches
Plain Diff
Add possibility to generate same config with different contamination levels
parent
80ffd548
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
config_maker/config_maker.py
+10
-4
10 additions, 4 deletions
config_maker/config_maker.py
config_maker/generator.py
+3
-1
3 additions, 1 deletion
config_maker/generator.py
with
13 additions
and
5 deletions
config_maker/config_maker.py
+
10
−
4
View file @
e656158b
...
...
@@ -4,6 +4,7 @@ This scripts automatically generates configurations usable by the TSG software.
"""
import
json
from
copy
import
deepcopy
from
argparse
import
ArgumentParser
...
...
@@ -26,6 +27,7 @@ if __name__ == "__main__":
"
-c
"
,
type
=
float
,
required
=
True
,
nargs
=
"
+
"
,
help
=
"
Contamination percentage to use
"
,
dest
=
"
contamination
"
)
...
...
@@ -48,8 +50,12 @@ if __name__ == "__main__":
args
=
parser
.
parse_args
()
# Generate anomalies
generator
=
ConfigGenerator
(
args
.
length
).
generate
(
args
.
nb_dim
).
add_anomalies
(
contamination
=
args
.
contamination
)
config
=
generator
.
get_config
()
generator
=
ConfigGenerator
(
args
.
length
).
generate
(
args
.
nb_dim
)
with
open
(
args
.
output
,
"
w
"
,
encoding
=
"
utf-8
"
)
as
f
:
f
.
write
(
json
.
dumps
(
config
))
for
c
in
args
.
contamination
:
gen_copy
=
deepcopy
(
generator
)
config
=
gen_copy
.
add_anomalies
(
contamination
=
c
).
get_config
()
with
open
(
f
"
{
args
.
output
}
/gc_d
{
args
.
nb_dim
}
_l
{
args
.
length
}
_c
{
int
(
c
)
}
.json
"
,
"
w
"
,
encoding
=
"
utf-8
"
)
as
f
:
f
.
write
(
json
.
dumps
(
config
))
# .add_anomalies(contamination=args.contamination)
This diff is collapsed.
Click to expand it.
config_maker/generator.py
+
3
−
1
View file @
e656158b
...
...
@@ -80,11 +80,13 @@ class ConfigGenerator:
others. This choice is not motivated by any statistical or mathematical choice
and could probably be improved.
"""
print
(
contamination
)
nb_points
=
int
((
self
.
config
[
"
length
"
]
/
100
)
*
contamination
)
nb_sub
=
len
(
self
.
config
[
"
subsystems
"
])
anomalies_per_sub
=
[
round
(
np
.
random
.
uniform
(
low
=
0
.25
,
high
=
0
.75
),
4
)
for
_
in
range
(
nb_sub
)]
anomalies_per_sub
=
[
round
(
np
.
random
.
uniform
(
low
=
0
,
high
=
1
0
),
4
)
for
_
in
range
(
nb_sub
)]
anomalies_per_sub
=
(
self
.
__softmax
(
anomalies_per_sub
)
*
nb_points
).
astype
(
int
)
print
(
anomalies_per_sub
)
for
idx
,
sub
in
enumerate
(
self
.
config
[
"
subsystems
"
]):
nb_dim_erroneous
=
np
.
random
.
randint
(
1
,
int
(
len
(
sub
)
/
2
))
if
len
(
sub
)
>
3
else
1
...
...
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