snajmark commited on
Commit
7721b2f
·
1 Parent(s): d210c54

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -10
app.py CHANGED
@@ -318,9 +318,8 @@ test_data_columns = ['Binder_ADA',
318
  'Concetration (µg/mL)']
319
 
320
 
321
- ### Define space and constraints
322
 
323
- constraints = []
324
  dimensionality_dict = {}
325
  one_hot_mapping = {}
326
  for c in categorical_columns:
@@ -335,12 +334,30 @@ for c in categorical_columns:
335
  domain = []
336
  for column in targets:
337
  df_columns.remove(column)
 
338
  for c in df_columns:
339
- if c in numerical_columns:
340
- domain.append({'name': str(c), 'type': 'continuous', 'domain': (0.,1.)})
 
 
 
 
 
 
 
 
 
 
 
341
  else:
342
- domain.append({'name': str(c), 'type': 'categorical', 'domain': (0,1),
343
- 'dimensionality': dimensionality_dict[c]})
 
 
 
 
 
 
344
 
345
 
346
 
@@ -397,7 +414,7 @@ def predict_inverse(antimicrobial_activity_target, request: gr.Request):
397
  return optimized_x
398
 
399
 
400
- example_inputs = [80]
401
 
402
  css_styling = """#submit {background: #1eccd8}
403
  #submit:hover {background: #a2f1f6}
@@ -418,7 +435,7 @@ light_theme_colors = gr.themes.Color(c50="#e4f3fa", # Dataframe background cell
418
  # secondary color used for highlight box content when typing in light mode, and download option in dark mode
419
  # primary color used for login button in dark mode
420
  osium_theme = gr.themes.Default(primary_hue="cyan", secondary_hue="cyan", neutral_hue=light_theme_colors)
421
- page_title = "Recommendation of optimal parameters to fulfill coating antimicrobial activity requirement"
422
  favicon_path = "osiumai_favicon.ico"
423
  logo_path = "osiumai_logo.jpg"
424
  html = f"""<html> <link rel="icon" type="image/x-icon" href="file={favicon_path}">
@@ -436,6 +453,10 @@ with gr.Blocks(css=css_styling, title=page_title, theme=osium_theme) as demo:
436
  with gr.Column():
437
  gr.Markdown("### The target antimicrobial activity of your textile coating")
438
  antimicrobial_activity_target = gr.Text(label="Enter the minimum acceptable antimicrobial activity for your textile coating")
 
 
 
 
439
 
440
  with gr.Column():
441
  with gr.Row():
@@ -444,13 +465,13 @@ with gr.Blocks(css=css_styling, title=page_title, theme=osium_theme) as demo:
444
  optimal_conditions = gr.DataFrame(label="Optimal conditions")
445
 
446
  with gr.Row():
447
- gr.Examples([example_inputs], [antimicrobial_activity_target])
448
 
449
 
450
 
451
  prediction_button.click(
452
  fn=predict_inverse,
453
- inputs=[antimicrobial_activity_target],
454
  outputs=[optimal_conditions],
455
  show_progress=True,
456
  )
@@ -459,6 +480,7 @@ with gr.Blocks(css=css_styling, title=page_title, theme=osium_theme) as demo:
459
  [],
460
  [
461
  antimicrobial_activity_target,
 
462
  optimal_conditions,
463
  ],
464
  )
 
318
  'Concetration (µg/mL)']
319
 
320
 
321
+ ### Define space and constrains
322
 
 
323
  dimensionality_dict = {}
324
  one_hot_mapping = {}
325
  for c in categorical_columns:
 
334
  domain = []
335
  for column in targets:
336
  df_columns.remove(column)
337
+ constrained_columns = ['Substrate', 'Washing_cycles', 'Microorganism ']
338
  for c in df_columns:
339
+ if c in constrained_columns:
340
+ if c.startswith('Substrate'):
341
+ if c == substrate:
342
+ domain.append({'name': str(c), 'type': 'categorical', 'domain': (1.0, 1.0)})
343
+ else:
344
+ domain.append({'name': str(c), 'type': 'categorical', 'domain': (0.0, 0.0)})
345
+ if c == 'Microorganism ':
346
+ if c == microorganism:
347
+ domain.append({'name': str(c), 'type': 'categorical', 'domain': (1.0, 1.0)})
348
+ else:
349
+ domain.append({'name': str(c), 'type': 'categorical', 'domain': (0.0, 0.0)})
350
+ if c == 'Washing_cycles':
351
+ domain.append({'name': str(c), 'type': 'categorical', 'domain': (int(num_washing_cycles), int(num_washing_cycles))})
352
  else:
353
+ if c in numerical_columns:
354
+ domain.append({'name': str(c), 'type': 'continuous', 'domain': (0.,1.)})
355
+ else:
356
+ domain.append({'name': str(c), 'type': 'categorical', 'domain': (0,1),
357
+ 'dimensionality': dimensionality_dict[c]})
358
+
359
+ # Constraints
360
+ constraints = []
361
 
362
 
363
 
 
414
  return optimized_x
415
 
416
 
417
+ example_inputs = [80, "Substrate_Bamboo", "Microorganism _Alt_brassicicola", 50]
418
 
419
  css_styling = """#submit {background: #1eccd8}
420
  #submit:hover {background: #a2f1f6}
 
435
  # secondary color used for highlight box content when typing in light mode, and download option in dark mode
436
  # primary color used for login button in dark mode
437
  osium_theme = gr.themes.Default(primary_hue="cyan", secondary_hue="cyan", neutral_hue=light_theme_colors)
438
+ page_title = "Recommendation of optimal parameters to fulfill coating antimicrobial activity requirement and constraints"
439
  favicon_path = "osiumai_favicon.ico"
440
  logo_path = "osiumai_logo.jpg"
441
  html = f"""<html> <link rel="icon" type="image/x-icon" href="file={favicon_path}">
 
453
  with gr.Column():
454
  gr.Markdown("### The target antimicrobial activity of your textile coating")
455
  antimicrobial_activity_target = gr.Text(label="Enter the minimum acceptable antimicrobial activity for your textile coating")
456
+ gr.Markwdown("### Your constraints")
457
+ substrate = gr.Dropdown(label="Your substrate", choices=[c in test_data_columns if c.startwith("Substrate")])
458
+ num_washing_cycles = gr.Text("Your number of washing cycles")
459
+ microorganism = gr.Dropdown(label="Microorganism", choices=[c in test_data_columns if c.startwith("Microorganism"))
460
 
461
  with gr.Column():
462
  with gr.Row():
 
465
  optimal_conditions = gr.DataFrame(label="Optimal conditions")
466
 
467
  with gr.Row():
468
+ gr.Examples([example_inputs], [antimicrobial_activity_target, substrate, microorganism, num_washing_cycles])
469
 
470
 
471
 
472
  prediction_button.click(
473
  fn=predict_inverse,
474
+ inputs=[antimicrobial_activity_target, substrate, microorganism, num_washing_cycles],
475
  outputs=[optimal_conditions],
476
  show_progress=True,
477
  )
 
480
  [],
481
  [
482
  antimicrobial_activity_target,
483
+ substrate, microorganism, num_washing_cycles,
484
  optimal_conditions,
485
  ],
486
  )