haneulpark commited on
Commit
0613fc4
1 Parent(s): 26b5a5e

Update Preprocessing Script.py

Browse files
Files changed (1) hide show
  1. Preprocessing Script.py +7 -5
Preprocessing Script.py CHANGED
@@ -75,6 +75,8 @@ from scipy.cluster import hierarchy
75
 
76
  #7. Split the dataset into test and train
77
 
 
 
78
  class MolecularFingerprint:
79
  def __init__(self, fingerprint):
80
  self.fingerprint = fingerprint
@@ -140,7 +142,7 @@ def butina_cluster(fingerprints, num_points, distance_threshold, reordering=Fals
140
 
141
  def hierarchal_cluster(fingerprints):
142
 
143
- num_finger_prints = len(fingerprints)
144
 
145
  av_cluster_size = 8
146
  dists = []
@@ -175,11 +177,9 @@ def cluster_fingerprints(fingerprints, method="Auto"):
175
  print("Butina clustering is selected. Dataset size is:", num_fingerprints)
176
  clusters = butina_cluster(fingerprints, num_fingerprints, cutoff)
177
 
178
- return clusters
179
-
180
  elif method == "Hierarchy":
181
  print("Hierarchical clustering is selected. Dataset size is:", num_fingerprints)
182
- clusters = hierarchal_cluster(fingerprints, num_fingerprints, 0.56)
183
 
184
  return clusters
185
 
@@ -255,11 +255,13 @@ def split_df_into_train_and_test_sets(df):
255
  test = df[df['group'] == 'testing']
256
  return train, test
257
 
 
 
258
  smiles_index = 0 # Because smiles is in the first column
259
  realistic = realistic_split(newAA.copy(), smiles_index, 0.8, split_for_exact_frac=True, cluster_method="Auto")
260
  realistic_train, realistic_test = split_df_into_train_and_test_sets(realistic)
261
 
262
- #8. Test and train datasets have been made
263
 
264
  selected_columns = realistic_train[['new SMILES', 'substance_id', 'aggref_index', 'logP', 'reference']]
265
  selected_columns.to_csv("AggregatorAdvisor_train.csv", index=False)
 
75
 
76
  #7. Split the dataset into test and train
77
 
78
+ #7. Split the dataset into test and train
79
+
80
  class MolecularFingerprint:
81
  def __init__(self, fingerprint):
82
  self.fingerprint = fingerprint
 
142
 
143
  def hierarchal_cluster(fingerprints):
144
 
145
+ num_fingerprints = len(fingerprints)
146
 
147
  av_cluster_size = 8
148
  dists = []
 
177
  print("Butina clustering is selected. Dataset size is:", num_fingerprints)
178
  clusters = butina_cluster(fingerprints, num_fingerprints, cutoff)
179
 
 
 
180
  elif method == "Hierarchy":
181
  print("Hierarchical clustering is selected. Dataset size is:", num_fingerprints)
182
+ clusters = hierarchal_cluster(fingerprints)
183
 
184
  return clusters
185
 
 
255
  test = df[df['group'] == 'testing']
256
  return train, test
257
 
258
+ # 8. Test and train datasets have been made
259
+
260
  smiles_index = 0 # Because smiles is in the first column
261
  realistic = realistic_split(newAA.copy(), smiles_index, 0.8, split_for_exact_frac=True, cluster_method="Auto")
262
  realistic_train, realistic_test = split_df_into_train_and_test_sets(realistic)
263
 
264
+ #9. Select columns and name the datasets
265
 
266
  selected_columns = realistic_train[['new SMILES', 'substance_id', 'aggref_index', 'logP', 'reference']]
267
  selected_columns.to_csv("AggregatorAdvisor_train.csv", index=False)