1
|
|
|
# Author: Simon Blanke |
2
|
|
|
# Email: [email protected] |
3
|
|
|
# License: MIT License |
4
|
|
|
|
5
|
|
|
import sys |
6
|
|
|
import glob |
7
|
|
|
|
8
|
|
|
# import inspect |
9
|
|
|
# import imageio |
10
|
|
|
|
11
|
|
|
import hiplot as hip |
12
|
|
|
import numpy as np |
13
|
|
|
import pandas as pd |
14
|
|
|
|
15
|
|
|
import streamlit as st |
16
|
|
|
import plotly.express as px |
17
|
|
|
|
18
|
|
|
|
19
|
|
|
def _score_statistics(search_data): |
20
|
|
|
values_ = search_data["score"].values |
21
|
|
|
|
22
|
|
|
mean_ = values_.mean() |
23
|
|
|
std_ = values_.std() |
24
|
|
|
min_ = np.amin(values_) |
25
|
|
|
max_ = np.amax(values_) |
26
|
|
|
|
27
|
|
|
df_data = pd.DataFrame( |
28
|
|
|
[[mean_, std_, min_, max_]], |
29
|
|
|
index=["score"], |
30
|
|
|
columns=["mean", "std", "min", "max"], |
31
|
|
|
) |
32
|
|
|
|
33
|
|
|
col1, col2 = st.beta_columns(2) |
34
|
|
|
|
35
|
|
|
col1.header("Score statistics") |
36
|
|
|
col1.text("") |
37
|
|
|
col2.text("") |
38
|
|
|
|
39
|
|
|
col1.table(df_data) |
40
|
|
|
|
41
|
|
|
def _score_statistics_plot(search_data): |
42
|
|
|
fig = px.histogram( |
43
|
|
|
search_data, x="score", nbins=int(len(search_data)) |
44
|
|
|
).update_layout(width=1000, height=300) |
45
|
|
|
col2.plotly_chart(fig) |
46
|
|
|
|
47
|
|
|
_score_statistics_plot(search_data) |
48
|
|
|
|
49
|
|
|
|
50
|
|
|
def _1d_scatter(search_data): |
51
|
|
|
para_names = search_data.columns.drop("score") |
52
|
|
|
|
53
|
|
|
st.text("") |
54
|
|
|
col1, col2 = st.beta_columns(2) |
55
|
|
|
|
56
|
|
|
col1.header("1D Scatter plot") |
57
|
|
|
col1.text("") |
58
|
|
|
|
59
|
|
|
scatter1_para1 = col1.selectbox( |
60
|
|
|
"1D scatter plot parameter 1", |
61
|
|
|
para_names, |
62
|
|
|
index=0, |
63
|
|
|
) |
64
|
|
|
|
65
|
|
|
def _1d_scatter_plot(search_data): |
66
|
|
|
fig = px.scatter( |
67
|
|
|
search_data, x=scatter1_para1, y=search_data["score"] |
68
|
|
|
).update_layout(width=1000, height=600) |
69
|
|
|
col2.plotly_chart(fig) |
70
|
|
|
|
71
|
|
|
_1d_scatter_plot(search_data) |
72
|
|
|
|
73
|
|
|
|
74
|
|
|
def _2d_scatter(search_data): |
75
|
|
|
para_names = search_data.columns.drop("score") |
76
|
|
|
|
77
|
|
|
st.text("") |
78
|
|
|
col1, col2 = st.beta_columns(2) |
79
|
|
|
|
80
|
|
|
col1.header("2D Scatter plot") |
81
|
|
|
col1.text("") |
82
|
|
|
|
83
|
|
|
scatter2_para1 = col1.selectbox( |
84
|
|
|
"2D scatter plot parameter 1", |
85
|
|
|
para_names, |
86
|
|
|
index=0, |
87
|
|
|
) |
88
|
|
|
scatter2_para2 = col1.selectbox( |
89
|
|
|
"2D scatter plot parameter 2", |
90
|
|
|
para_names, |
91
|
|
|
index=1, |
92
|
|
|
) |
93
|
|
|
|
94
|
|
|
def _2d_scatter_plot(search_data): |
95
|
|
|
fig = px.scatter( |
96
|
|
|
search_data, x=scatter2_para1, y=scatter2_para2, color="score" |
97
|
|
|
).update_layout(width=1000, height=600) |
98
|
|
|
col2.plotly_chart(fig) |
99
|
|
|
|
100
|
|
|
_2d_scatter_plot(search_data) |
101
|
|
|
|
102
|
|
|
|
103
|
|
|
def _3d_scatter(search_data): |
104
|
|
|
para_names = search_data.columns.drop("score") |
105
|
|
|
|
106
|
|
|
st.text("") |
107
|
|
|
col1, col2 = st.beta_columns(2) |
108
|
|
|
|
109
|
|
|
col1.header("3D Scatter plot") |
110
|
|
|
col1.text("") |
111
|
|
|
|
112
|
|
|
scatter3_para1 = col1.selectbox( |
113
|
|
|
"3D scatter plot parameter 1", |
114
|
|
|
para_names, |
115
|
|
|
index=0, |
116
|
|
|
) |
117
|
|
|
scatter3_para2 = col1.selectbox( |
118
|
|
|
"3D scatter plot parameter 2", |
119
|
|
|
para_names, |
120
|
|
|
index=1, |
121
|
|
|
) |
122
|
|
|
scatter3_para3 = col1.selectbox( |
123
|
|
|
"3D scatter plot parameter 3", |
124
|
|
|
para_names, |
125
|
|
|
index=2, |
126
|
|
|
) |
127
|
|
|
|
128
|
|
|
def _3d_scatter_plot(search_data): |
129
|
|
|
fig = px.scatter_3d( |
130
|
|
|
search_data, |
131
|
|
|
x=scatter3_para1, |
132
|
|
|
y=scatter3_para2, |
133
|
|
|
z=scatter3_para3, |
134
|
|
|
color="score", |
135
|
|
|
).update_layout(width=1000, height=600) |
136
|
|
|
col2.plotly_chart(fig) |
137
|
|
|
|
138
|
|
|
_3d_scatter_plot(search_data) |
139
|
|
|
|
140
|
|
|
|
141
|
|
|
def _parallel_coordinates(search_data): |
142
|
|
|
st.text("") |
143
|
|
|
col1, col2 = st.beta_columns(2) |
144
|
|
|
|
145
|
|
|
col1.header("Parallel Corrdinates") |
146
|
|
|
col1.text("") |
147
|
|
|
col2.text("") |
148
|
|
|
|
149
|
|
|
xp = hip.Experiment.from_dataframe(search_data) |
150
|
|
|
ret_val = xp.display_st(key="key1") |
151
|
|
|
|
152
|
|
|
|
153
|
|
|
plots_dict = { |
154
|
|
|
"score_statistics": _score_statistics, |
155
|
|
|
"1d_scatter": _1d_scatter, |
156
|
|
|
"2d_scatter": _2d_scatter, |
157
|
|
|
"3d_scatter": _3d_scatter, |
158
|
|
|
"parallel_coordinates": _parallel_coordinates, |
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
|
162
|
|
|
st.set_page_config(page_title="Hyperactive Dashboard", layout="wide") |
163
|
|
|
path = sys.argv[1] |
164
|
|
|
streamlit_plot_args = sys.argv[2:] |
165
|
|
|
|
166
|
|
|
search_data = pd.read_csv(path) |
167
|
|
|
# print("\n search_data \n", search_data) |
168
|
|
|
|
169
|
|
|
st.title("Hyperactive Dashboard") |
170
|
|
|
st.text("") |
171
|
|
|
st.text("") |
172
|
|
|
|
173
|
|
|
|
174
|
|
|
if len(search_data) > 0: |
175
|
|
|
# --- # create plots in order of "streamlit_plot_args" |
176
|
|
|
for streamlit_plot_arg in streamlit_plot_args: |
177
|
|
|
plots_dict[streamlit_plot_arg](search_data) |
178
|
|
|
|
179
|
|
|
else: |
180
|
|
|
st.subheader("---> Error: Search data is empty!") |