Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
S
Subsampling
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Josef Brandt
Subsampling
Commits
c070f4ab
Commit
c070f4ab
authored
Apr 08, 2020
by
Josef Brandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Plots from function
parent
3de80ba6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
73 additions
and
42 deletions
+73
-42
graphs.py
graphs.py
+66
-0
gui/mainView.py
gui/mainView.py
+1
-1
subsampling.py
subsampling.py
+6
-41
No files found.
graphs.py
0 → 100644
View file @
c070f4ab
from
matplotlib.figure
import
Figure
import
matplotlib.pyplot
as
plt
import
numpy
as
np
from
evaluation
import
TotalResults
def
get_error_vs_frac_plot
(
totalResults
:
TotalResults
,
attributes
:
list
=
[],
methods
:
list
=
[])
->
Figure
:
assert
len
(
attributes
)
==
len
(
methods
)
fig
:
Figure
=
plt
.
figure
()
numRows
:
int
=
1
numCols
:
int
=
1
if
len
(
attributes
)
==
0
:
attributes
=
methods
=
[[]]
elif
len
(
attributes
)
<=
2
:
numCols
=
len
(
attributes
)
else
:
numRows
=
2
numCols
=
np
.
ceil
(
len
(
attributes
)
/
numRows
)
index
=
0
for
attrs
,
meths
in
zip
(
attributes
,
methods
):
ax
=
fig
.
add_subplot
(
numRows
,
numCols
,
index
+
1
)
errorPerFraction
:
dict
=
totalResults
.
get_error_vs_fraction_data
(
attributes
=
attrs
,
methods
=
meths
)
for
methodLabel
in
errorPerFraction
.
keys
():
errorDict
:
dict
=
errorPerFraction
[
methodLabel
]
fractions
:
list
=
list
(
errorDict
.
keys
())
errors
:
list
=
[
errorDict
[
fraction
][
0
]
for
fraction
in
fractions
]
stdevs
:
list
=
[
errorDict
[
fraction
][
1
]
for
fraction
in
fractions
]
ax
.
errorbar
(
fractions
,
errors
,
stdevs
,
label
=
methodLabel
,
marker
=
's'
,
capsize
=
5
)
title
:
str
=
''
if
len
(
attrs
)
>
0
:
title
=
', '
.
join
(
attr
for
attr
in
attrs
)
print
(
'title is'
,
title
)
ax
.
set_title
(
title
,
fontSize
=
15
)
ax
.
set_xscale
(
'log'
)
ax
.
set_xlabel
(
'measured fraction'
,
fontsize
=
12
)
ax
.
set_ylabel
(
'mpCountError (%)'
,
fontsize
=
12
)
ax
.
set_xlim
([
0.9
*
min
(
fractions
),
1.05
])
ax
.
set_ylim
([
0
,
100
])
ax
.
legend
()
index
+=
1
return
fig
# def get_grouped_spectra_plot(groupedSpectra: list, wavenumbers=None) -> matplotlib.figure.Figure:
# if wavenumbers is None:
# wavenumbers = np.arange(len(groupedSpectra[0][0]))
#
# numLabels = len(groupedSpectra)
# numRows = numLabels // 3
# numCols = np.ceil(numLabels / numRows)
# fig: matplotlib.figure.Figure = plt.figure()
#
# for index, specs in enumerate(groupedSpectra):
# ax = fig.add_subplot(numRows, numCols, index + 1)
# for spec in specs:
# ax.plot(wavenumbers, spec)
# ax.set_title(f'{len(specs)} spectra of label {index + 1}')
#
# return fig
\ No newline at end of file
gui/mainView.py
View file @
c070f4ab
...
...
@@ -143,4 +143,4 @@ if __name__ == '__main__':
app
=
QtWidgets
.
QApplication
(
sys
.
argv
)
subsampling
=
MainView
()
subsampling
.
show
()
ret
=
app
.
exec_
()
\ No newline at end of file
ret
=
app
.
exec_
()
subsampling.py
View file @
c070f4ab
import
matplotlib.pyplot
as
plt
# import matplotlib.pyplot as plt
from
matplotlib.figure
import
Figure
import
time
from
evaluation
import
TotalResults
,
SampleResult
from
input_output
import
get_pkls_from_directory
,
get_attributes_from_foldername
,
save_results
,
load_results
from
graphs
import
get_error_vs_frac_plot
"""
IMPORTANT!!!
...
...
@@ -27,43 +29,6 @@ if __name__ == '__main__':
results
:
TotalResults
=
load_results
(
'results1.res'
)
# save_results('results1.res', results)
plt
.
clf
()
errorPerFraction
:
dict
=
results
.
get_error_vs_fraction_data
(
attributes
=
[
'air'
,
'water'
],
methods
=
[
'spiral'
,
'cross'
])
plt
.
subplot
(
121
)
for
methodLabel
in
errorPerFraction
.
keys
():
errorDict
:
dict
=
errorPerFraction
[
methodLabel
]
fractions
:
list
=
list
(
errorDict
.
keys
())
errors
:
list
=
[
errorDict
[
fraction
][
0
]
for
fraction
in
fractions
]
stdevs
:
list
=
[
errorDict
[
fraction
][
1
]
for
fraction
in
fractions
]
plt
.
errorbar
(
fractions
,
errors
,
stdevs
,
label
=
methodLabel
,
marker
=
's'
,
capsize
=
5
)
plt
.
title
(
'Air/Water sample'
,
fontSize
=
15
)
plt
.
xscale
(
'log'
)
plt
.
xlabel
(
'measured fraction'
,
fontsize
=
12
)
plt
.
ylabel
(
'mpCountError (%)'
,
fontsize
=
12
)
plt
.
xlim
([
0.9
*
min
(
fractions
),
1.05
])
plt
.
ylim
([
0
,
100
])
plt
.
legend
()
errorPerFraction
:
dict
=
results
.
get_error_vs_fraction_data
(
attributes
=
[
'sediment'
,
'soil'
,
'beach'
,
'slush'
],
methods
=
[
'spiral'
,
'cross'
])
plt
.
subplot
(
122
)
for
methodLabel
in
errorPerFraction
.
keys
():
errorDict
:
dict
=
errorPerFraction
[
methodLabel
]
fractions
:
list
=
list
(
errorDict
.
keys
())
errors
:
list
=
[
errorDict
[
fraction
][
0
]
for
fraction
in
fractions
]
stdevs
:
list
=
[
errorDict
[
fraction
][
1
]
for
fraction
in
fractions
]
plt
.
errorbar
(
fractions
,
errors
,
stdevs
,
label
=
methodLabel
,
marker
=
's'
,
capsize
=
5
)
plt
.
title
(
'Sediment/Beach/Slush sample'
,
fontSize
=
15
)
plt
.
xscale
(
'log'
)
plt
.
xlabel
(
'measured fraction'
,
fontsize
=
12
)
plt
.
ylabel
(
'mpCountError (%)'
,
fontsize
=
12
)
plt
.
xlim
([
0.9
*
min
(
fractions
),
1.05
])
plt
.
ylim
([
0
,
100
])
plt
.
legend
()
plt
.
show
()
plot
:
Figure
=
get_error_vs_frac_plot
(
results
,
attributes
=
[[
'air'
,
'water'
],
[
'sediment'
,
'soil'
,
'beach'
,
'slush'
]],
methods
=
[[
'random'
,
'size'
]]
*
2
)
plot
.
show
()
\ No newline at end of file
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