Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
Intro2MM-Homework1
Project
Overview
Details
Activity
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
Tianqi Yang
Intro2MM-Homework1
Commits
dbaeeff0
Commit
dbaeeff0
authored
Oct 13, 2019
by
Tianqi Yang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(handle_data): support threshold
parent
96ec9f28
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
12 deletions
+20
-12
gen.py
gen.py
+1
-1
handle_data.py
handle_data.py
+19
-11
No files found.
gen.py
View file @
dbaeeff0
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
import
numpy
as
np
import
numpy
as
np
import
math
import
math
print
(
' '
.
join
(
list
(
map
(
str
,
range
(
100
,
501
,
5
)
)
)
)
)
print
(
' '
.
join
(
list
(
map
(
str
,
range
(
100
,
501
,
2
)
)
)
)
)
a
=
np
.
logspace
(
math
.
log
(
0.0001
,
10
),
math
.
log
(
0.01
,
10
),
40
)
.
tolist
()[
0
:
-
1
]
+
np
.
logspace
(
math
.
log
(
0.01
,
10
),
math
.
log
(
1
,
10
),
80
)
.
tolist
()
a
=
np
.
logspace
(
math
.
log
(
0.0001
,
10
),
math
.
log
(
0.01
,
10
),
40
)
.
tolist
()[
0
:
-
1
]
+
np
.
logspace
(
math
.
log
(
0.01
,
10
),
math
.
log
(
1
,
10
),
80
)
.
tolist
()
print
(
' '
.
join
(
list
(
map
(
str
,
a
)
)
)
)
print
(
' '
.
join
(
list
(
map
(
str
,
a
)
)
)
)
...
...
handle_data.py
View file @
dbaeeff0
...
@@ -32,11 +32,12 @@ def main ():
...
@@ -32,11 +32,12 @@ def main ():
try
:
try
:
cur
=
data
[
line_id
]
.
split
()
cur
=
data
[
line_id
]
.
split
()
line_id
+=
1
line_id
+=
1
if
len
(
cur
)
!=
2
:
if
len
(
cur
)
!=
3
:
print
(
'Syntax error at line {}: lambda
or p
not found: {}'
.
format
(
line_id
,
cur
))
print
(
'Syntax error at line {}: lambda
, p, threshold,
not found: {}'
.
format
(
line_id
,
cur
))
raise
Exception
()
raise
Exception
()
lbd
=
int
(
cur
[
0
])
lbd
=
int
(
cur
[
0
])
p
=
float
(
cur
[
1
])
p
=
float
(
cur
[
1
])
thres
=
int
(
cur
[
2
])
cur_res
=
[]
cur_res
=
[]
for
i
in
range
(
args
.
repeat
):
# pylint: disable=unused-variable
for
i
in
range
(
args
.
repeat
):
# pylint: disable=unused-variable
cur
=
data
[
line_id
]
cur
=
data
[
line_id
]
...
@@ -49,7 +50,7 @@ def main ():
...
@@ -49,7 +50,7 @@ def main ():
raise
Exception
()
raise
Exception
()
mean
=
np
.
mean
(
cur_res
)
mean
=
np
.
mean
(
cur_res
)
var
=
np
.
var
(
cur_res
)
var
=
np
.
var
(
cur_res
)
result
[(
lbd
,
p
)]
=
(
mean
,
var
)
result
[(
lbd
,
p
,
thres
)]
=
(
mean
,
var
)
except
Exception
:
except
Exception
:
print
(
'Exception at line {}'
.
format
(
line_id
))
print
(
'Exception at line {}'
.
format
(
line_id
))
else
:
else
:
...
@@ -57,38 +58,45 @@ def main ():
...
@@ -57,38 +58,45 @@ def main ():
lbd_axis
=
[]
lbd_axis
=
[]
p_axis
=
[]
p_axis
=
[]
thres_axis
=
[]
for
i
in
result
.
keys
():
for
i
in
result
.
keys
():
if
i
[
0
]
not
in
lbd_axis
:
if
i
[
0
]
not
in
lbd_axis
:
lbd_axis
.
append
(
i
[
0
])
lbd_axis
.
append
(
i
[
0
])
if
i
[
1
]
not
in
p_axis
:
if
i
[
1
]
not
in
p_axis
:
p_axis
.
append
(
i
[
1
])
p_axis
.
append
(
i
[
1
])
if
i
[
2
]
not
in
thres_axis
:
thres_axis
.
append
(
i
[
2
])
lbd_axis
.
sort
()
lbd_axis
.
sort
()
p_axis
.
sort
()
p_axis
.
sort
()
thres_axis
.
sort
()
with
open
(
args
.
output
,
'w'
)
as
OUT
:
with
open
(
args
.
output
,
'w'
)
as
OUT
:
for
thres
in
thres_axis
:
mean_format
=
',{:.
%
d}'
%
(
args
.
precision_mean
)
mean_format
=
',{:.
%
d}'
%
(
args
.
precision_mean
)
if
args
.
precision_var
==
-
1
:
if
args
.
precision_var
==
-
1
:
var_format
=
',{}'
var_format
=
',{}'
else
:
else
:
var_format
=
',{:.
%
d}'
%
(
args
.
precision_var
)
var_format
=
',{:.
%
d}'
%
(
args
.
precision_var
)
print
(
','
.
join
([
'Mean'
]
+
list
(
map
(
str
,
p_axis
))),
file
=
OUT
)
print
(
','
.
join
([
'Mean (threshold={})'
.
format
(
thres
)
]
+
list
(
map
(
str
,
p_axis
))),
file
=
OUT
)
for
lbd
in
lbd_axis
:
for
lbd
in
lbd_axis
:
print
(
'{}'
.
format
(
lbd
),
end
=
''
,
file
=
OUT
)
print
(
'{}'
.
format
(
lbd
),
end
=
''
,
file
=
OUT
)
for
p
in
p_axis
:
for
p
in
p_axis
:
if
(
lbd
,
p
)
in
result
:
if
(
lbd
,
p
,
thres
)
in
result
:
print
(
mean_format
.
format
(
result
[(
lbd
,
p
)][
0
]),
end
=
''
,
file
=
OUT
)
print
(
mean_format
.
format
(
result
[(
lbd
,
p
,
thres
)][
0
]),
end
=
''
,
file
=
OUT
)
else
:
else
:
print
(
',N/A
'
,
file
=
OUT
)
print
(
',N/A'
,
end
=
'
'
,
file
=
OUT
)
print
(
file
=
OUT
)
print
(
file
=
OUT
)
print
(
file
=
OUT
)
print
(
file
=
OUT
)
print
(
','
.
join
([
'Variance'
]
+
list
(
map
(
str
,
p_axis
))),
file
=
OUT
)
for
thres
in
thres_axis
:
print
(
','
.
join
([
'Variance (threshold={})'
.
format
(
thres
)]
+
list
(
map
(
str
,
p_axis
))),
file
=
OUT
)
for
lbd
in
lbd_axis
:
for
lbd
in
lbd_axis
:
print
(
'{}'
.
format
(
lbd
),
end
=
''
,
file
=
OUT
)
print
(
'{}'
.
format
(
lbd
),
end
=
''
,
file
=
OUT
)
for
p
in
p_axis
:
for
p
in
p_axis
:
if
(
lbd
,
p
)
in
result
:
if
(
lbd
,
p
,
thres
)
in
result
:
print
(
var_format
.
format
(
result
[(
lbd
,
p
)][
1
]),
end
=
''
,
file
=
OUT
)
print
(
var_format
.
format
(
result
[(
lbd
,
p
,
thres
)][
1
]),
end
=
''
,
file
=
OUT
)
else
:
else
:
print
(
',N/A'
,
file
=
OUT
)
print
(
',N/A'
,
end
=
''
,
file
=
OUT
)
print
(
file
=
OUT
)
print
(
file
=
OUT
)
print
(
file
=
OUT
)
...
...
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