snajmark commited on
Commit
7d1040b
·
1 Parent(s): 4c110f6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +41 -41
app.py CHANGED
@@ -316,48 +316,7 @@ test_data_columns = ['Binder_ADA',
316
  'Duration (h)',
317
  'Washing_cycles',
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:
326
- dimensionality_dict[c] = 0
327
- one_hot_mapping[c] = []
328
- for c in categorical_columns:
329
- for t in test_data_columns:
330
- if c in t:
331
- dimensionality_dict[c]+=1
332
- one_hot_mapping[c].append(t)
333
-
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
 
@@ -383,6 +342,47 @@ def fit_outputs_constraints(X, antimicrobial_activity_target, request: gr.Reques
383
 
384
  def predict_inverse(antimicrobial_activity_target, request: gr.Request):
385
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
386
  def fit_outputs(x):
387
  return fit_outputs_constraints(x, antimicrobial_activity_target, request)
388
  opt = GPyOpt.methods.BayesianOptimization(f = fit_outputs, # function to optimize
 
316
  'Duration (h)',
317
  'Washing_cycles',
318
  'Concetration (µg/mL)']
 
319
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
320
 
321
 
322
 
 
342
 
343
  def predict_inverse(antimicrobial_activity_target, request: gr.Request):
344
 
345
+ ### Define space and constrains
346
+
347
+ dimensionality_dict = {}
348
+ one_hot_mapping = {}
349
+ for c in categorical_columns:
350
+ dimensionality_dict[c] = 0
351
+ one_hot_mapping[c] = []
352
+ for c in categorical_columns:
353
+ for t in test_data_columns:
354
+ if c in t:
355
+ dimensionality_dict[c]+=1
356
+ one_hot_mapping[c].append(t)
357
+
358
+ domain = []
359
+ for column in targets:
360
+ df_columns.remove(column)
361
+ constrained_columns = ['Substrate', 'Washing_cycles', 'Microorganism ']
362
+ for c in df_columns:
363
+ if c in constrained_columns:
364
+ if c.startswith('Substrate'):
365
+ if c == substrate:
366
+ domain.append({'name': str(c), 'type': 'categorical', 'domain': (1.0, 1.0)})
367
+ else:
368
+ domain.append({'name': str(c), 'type': 'categorical', 'domain': (0.0, 0.0)})
369
+ if c == 'Microorganism ':
370
+ if c == microorganism:
371
+ domain.append({'name': str(c), 'type': 'categorical', 'domain': (1.0, 1.0)})
372
+ else:
373
+ domain.append({'name': str(c), 'type': 'categorical', 'domain': (0.0, 0.0)})
374
+ if c == 'Washing_cycles':
375
+ domain.append({'name': str(c), 'type': 'categorical', 'domain': (int(num_washing_cycles), int(num_washing_cycles))})
376
+ else:
377
+ if c in numerical_columns:
378
+ domain.append({'name': str(c), 'type': 'continuous', 'domain': (0.,1.)})
379
+ else:
380
+ domain.append({'name': str(c), 'type': 'categorical', 'domain': (0,1),
381
+ 'dimensionality': dimensionality_dict[c]})
382
+
383
+ # Constraints
384
+ constraints = []
385
+
386
  def fit_outputs(x):
387
  return fit_outputs_constraints(x, antimicrobial_activity_target, request)
388
  opt = GPyOpt.methods.BayesianOptimization(f = fit_outputs, # function to optimize