Spaces:
Running
Running
adding xes feature for the ui
Browse files- utils/config_fabric.py +30 -14
utils/config_fabric.py
CHANGED
@@ -14,6 +14,7 @@ import shutil
|
|
14 |
import zipfile
|
15 |
import io
|
16 |
from column_mappings import column_mappings
|
|
|
17 |
|
18 |
st.set_page_config(layout='wide')
|
19 |
INPUT_XES="output/inputlog_temp.xes"
|
@@ -169,8 +170,8 @@ def create_objectives_grid(df, objectives, n_para_obj=2, method="combinatorial")
|
|
169 |
sys.exit(1)
|
170 |
|
171 |
def set_generator_experiments(generator_params):
|
172 |
-
def handle_csv_file(grid_option):
|
173 |
-
uploaded_file = st.file_uploader("Pick a csv-file containing feature values for features:", type="csv")
|
174 |
if uploaded_file is not None:
|
175 |
df = pd.read_csv(uploaded_file)
|
176 |
if len(df.columns) <= 1:
|
@@ -257,14 +258,35 @@ def set_generator_experiments(generator_params):
|
|
257 |
return[]
|
258 |
|
259 |
|
260 |
-
grid_option, csv_option = double_switch("Point-", "Grid-based", third_label="Manual", fourth_label="From
|
261 |
|
262 |
if csv_option:
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
268 |
else: # Manual
|
269 |
experiments = handle_manual_option(grid_option)
|
270 |
|
@@ -369,12 +391,6 @@ if __name__ == '__main__':
|
|
369 |
if os.path.exists(path):
|
370 |
shutil.rmtree(path)
|
371 |
|
372 |
-
if os.path.exists(path_to_logs):
|
373 |
-
shutil.rmtree(path_to_logs)
|
374 |
-
|
375 |
-
if os.path.exists(path_to_logs):
|
376 |
-
shutil.rmtree(path_to_logs)
|
377 |
-
|
378 |
if os.path.exists(path_to_logs):
|
379 |
shutil.rmtree(path_to_logs)
|
380 |
|
|
|
14 |
import zipfile
|
15 |
import io
|
16 |
from column_mappings import column_mappings
|
17 |
+
from feeed.feature_extractor import extract_features
|
18 |
|
19 |
st.set_page_config(layout='wide')
|
20 |
INPUT_XES="output/inputlog_temp.xes"
|
|
|
170 |
sys.exit(1)
|
171 |
|
172 |
def set_generator_experiments(generator_params):
|
173 |
+
def handle_csv_file(uploaded_file,grid_option):
|
174 |
+
# uploaded_file = st.file_uploader("Pick a csv-file containing feature values for features:", type="csv")
|
175 |
if uploaded_file is not None:
|
176 |
df = pd.read_csv(uploaded_file)
|
177 |
if len(df.columns) <= 1:
|
|
|
258 |
return[]
|
259 |
|
260 |
|
261 |
+
grid_option, csv_option = double_switch("Point-", "Grid-based", third_label="Manual", fourth_label="From File")
|
262 |
|
263 |
if csv_option:
|
264 |
+
uploaded_file = st.file_uploader("Pick a csv-file containing feature values for features (or) an xes-event log:", type=["csv","xes"])
|
265 |
+
experiments = []
|
266 |
+
if uploaded_file is not None:
|
267 |
+
if uploaded_file.name.endswith('.xes'):
|
268 |
+
with open(f"{uploaded_file.name}", 'wb') as f:
|
269 |
+
f.write(uploaded_file.getbuffer())
|
270 |
+
|
271 |
+
sel_features = st.multiselect("Selected features", list(generator_params['experiment'].keys()))
|
272 |
+
if 'ratio_variants_per_number_of_traces' in sel_features: #Hotfix
|
273 |
+
sel_features[sel_features.index('ratio_variants_per_number_of_traces')] = 'ratio_unique_traces_per_trace'
|
274 |
+
|
275 |
+
xes_features = extract_features(f"{uploaded_file.name}", sel_features)
|
276 |
+
del xes_features['log']
|
277 |
+
# removing the temporary file
|
278 |
+
uploaded_file.close()
|
279 |
+
if os.path.exists(f"{uploaded_file.name}"):
|
280 |
+
os.remove(f"{uploaded_file.name}")
|
281 |
+
xes_features = {key: float(value) for key, value in xes_features.items()}
|
282 |
+
experiments = [xes_features]
|
283 |
+
|
284 |
+
if uploaded_file.name.endswith('.csv'):
|
285 |
+
df, sel_features = handle_csv_file(uploaded_file,grid_option)
|
286 |
+
if df is not None and sel_features is not None:
|
287 |
+
experiments = handle_csv_option(grid_option, df, sel_features)
|
288 |
+
else:
|
289 |
+
experiments = []
|
290 |
else: # Manual
|
291 |
experiments = handle_manual_option(grid_option)
|
292 |
|
|
|
391 |
if os.path.exists(path):
|
392 |
shutil.rmtree(path)
|
393 |
|
|
|
|
|
|
|
|
|
|
|
|
|
394 |
if os.path.exists(path_to_logs):
|
395 |
shutil.rmtree(path_to_logs)
|
396 |
|