snajmark commited on
Commit
a945af8
·
1 Parent(s): d4040a7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -23
app.py CHANGED
@@ -358,31 +358,30 @@ def predict_inverse(antimicrobial_activity_target, substrate, microorganism, num
358
  domain = []
359
  for column in targets:
360
  df_columns.remove(column)
 
361
  constrained_columns = ['Substrate', 'Washing_cycles', 'Microorganism ']
362
- not_constrained_columns = [column for column in df_columns if column not in constrained_columns]
363
- ### Add input constraints
364
- for c in test_data_columns:
365
- if c.startswith('Substrate'):
366
- if c == substrate:
367
- domain.append({'name': str(c), 'type': 'categorical', 'domain': (1.0, 1.0)})
368
- else:
369
- domain.append({'name': str(c), 'type': 'categorical', 'domain': (0.0, 0.0)})
370
- elif c == 'Microorganism ':
371
- if c == microorganism:
372
- domain.append({'name': str(c), 'type': 'categorical', 'domain': (1.0, 1.0)})
373
- else:
374
- domain.append({'name': str(c), 'type': 'categorical', 'domain': (0.0, 0.0)})
375
- elif c == 'Washing_cycles':
376
- domain.append({'name': str(c), 'type': 'categorical', 'domain': (int(num_washing_cycles), int(num_washing_cycles))})
377
- elif c in numerical_columns:
378
- domain.append({'name': str(c), 'type': 'continuous', 'domain': (0.,1.)})
 
 
379
  else:
380
- seen_not_constrained = []
381
- for not_c in not_constrained_columns:
382
- if c.startswith(not_c) and not_c not in seen_not_constrained:
383
- domain.append({'name': str(not_c), 'type': 'categorical', 'domain': (0,1),
384
- 'dimensionality': dimensionality_dict[not_c]})
385
- seen_not_constrained.append(str(not_c))
386
  print("Domain is ", domain)
387
  print(len(domain))
388
 
 
358
  domain = []
359
  for column in targets:
360
  df_columns.remove(column)
361
+
362
  constrained_columns = ['Substrate', 'Washing_cycles', 'Microorganism ']
363
+
364
+ ### Add input domain
365
+ for df_column in df_columns:
366
+ if df_column == "Substrate":
367
+ for one_hot_column in one_hot_mapping[df_column]:
368
+ if one_hot_column == substrate:
369
+ domain.append({'name': str(one_hot_column), 'type': 'categorical', 'domain': (1.0, 1.0)})
370
+ else:
371
+ domain.append({'name': str(one_hot_column), 'type': 'categorical', 'domain': (0.0, 0.0)})
372
+ elif df_column == 'Microorganism ':
373
+ for one_hot_column in one_hot_mapping[df_column]:
374
+ if one_hot_column == microorganism:
375
+ domain.append({'name': str(one_hot_column), 'type': 'categorical', 'domain': (1.0, 1.0)})
376
+ else:
377
+ domain.append({'name': str(one_hot_column), 'type': 'categorical', 'domain': (0.0, 0.0)})
378
+ elif df_column == 'Washing_cycles':
379
+ domain.append({'name': str(df_column), 'type': 'categorical', 'domain': (int(num_washing_cycles), int(num_washing_cycles))})
380
+ elif df_column in numerical_columns:
381
+ domain.append({'name': str(df_column), 'type': 'continuous', 'domain': (0.,1.)})
382
  else:
383
+ domain.append({'name': str(df_column), 'type': 'categorical', 'domain': (0,1),
384
+ 'dimensionality': dimensionality_dict[df_column]})
 
 
 
 
385
  print("Domain is ", domain)
386
  print(len(domain))
387