snajmark commited on
Commit
25a3e91
·
1 Parent(s): 9d46951

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -7
app.py CHANGED
@@ -359,6 +359,7 @@ def predict_inverse(antimicrobial_activity_target, substrate, microorganism, num
359
  for column in targets:
360
  df_columns.remove(column)
361
  constrained_columns = ['Substrate', 'Washing_cycles', 'Microorganism ']
 
362
  ### Add input constraints
363
  for c in test_data_columns:
364
  if c.startswith('Substrate'):
@@ -373,14 +374,15 @@ def predict_inverse(antimicrobial_activity_target, substrate, microorganism, num
373
  domain.append({'name': str(c), 'type': 'categorical', 'domain': (0.0, 0.0)})
374
  elif c == 'Washing_cycles':
375
  domain.append({'name': str(c), 'type': 'categorical', 'domain': (int(num_washing_cycles), int(num_washing_cycles))})
376
- for df_column in df_columns:
377
- if df_column.startswith('Substrate') or df_column.startswith('Washing_cycles') or df_column.startswith('Microorganism'):
378
- continue
379
- if df_column in numerical_columns:
380
- domain.append({'name': str(df_column), 'type': 'continuous', 'domain': (0.,1.)})
381
  else:
382
- domain.append({'name': str(df_column), 'type': 'categorical', 'domain': (0,1),
383
- 'dimensionality': dimensionality_dict[df_column]})
 
 
 
 
384
  print("Domain is ", domain)
385
  print(len(domain))
386
 
 
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'):
 
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(not_c)
386
  print("Domain is ", domain)
387
  print(len(domain))
388