mgyigit commited on
Commit
57f433d
·
verified ·
1 Parent(s): b59bcc0

Update src/bin/function_predictor.py

Browse files
Files changed (1) hide show
  1. src/bin/function_predictor.py +9 -24
src/bin/function_predictor.py CHANGED
@@ -86,14 +86,11 @@ def MultiLabelSVC_cross_val_predict(representation_name, dataset, X, y, classifi
86
  means = list(np.mean([acc_cv, f1_mi_cv, f1_ma_cv, f1_we_cv, pr_mi_cv, pr_ma_cv, pr_we_cv, rc_mi_cv, rc_ma_cv, rc_we_cv, hamm_cv], axis=1))
87
  means = [np.round(i, decimals=5) for i in means]
88
 
89
- stds = list(np.std([acc_cv, f1_mi_cv, f1_ma_cv, f1_we_cv, pr_mi_cv, pr_ma_cv, pr_we_cv, rc_mi_cv, rc_ma_cv, rc_we_cv, hamm_cv], axis=1))
90
- stds = [np.round(i, decimals=5) for i in stds]
91
 
92
  return {
93
- "cv_results": [representation_name + "_" + dataset, acc_cv, f1_mi_cv, f1_ma_cv, f1_we_cv, pr_mi_cv, pr_ma_cv, pr_we_cv, rc_mi_cv, rc_ma_cv, rc_we_cv, hamm_cv],
94
  "means": [representation_name + "_" + dataset] + means,
95
- "stds": [representation_name + "_" + dataset] + stds,
96
- "predictions": y_pred
97
  }
98
 
99
  def ProtDescModel():
@@ -108,9 +105,9 @@ def ProtDescModel():
108
  else:
109
  filtered_datasets = [dataset for dataset in datasets if aspect_type in dataset and dataset_type in dataset]
110
 
111
- cv_results = []
112
  cv_mean_results = []
113
- cv_std_results = []
114
 
115
  for dt in tqdm(filtered_datasets, total=len(filtered_datasets)):
116
  print(f"Protein function prediction is started for the dataset: {dt.split('.')[0]}")
@@ -128,28 +125,16 @@ def ProtDescModel():
128
  classifier=BinaryRelevance(SGDClassifier(n_jobs=cpu_number, random_state=42)))
129
 
130
  if model is not None:
131
- cv_results.append(model["cv_results"])
132
  cv_mean_results.append(model["means"])
133
- cv_std_results.append(model["stds"])
134
 
135
- return {
136
- "cv_results": cv_results,
137
- "cv_mean_results": cv_mean_results,
138
- "cv_std_results": cv_std_results
139
- }
140
 
141
  def pred_output():
142
- model = ProtDescModel()
143
- cv_result = model["cv_results"]
144
-
145
- cv_mean_result = model["cv_mean_results"]
146
- cv_std_result = model["cv_std_results"]
147
 
148
- return {
149
- "cv_result": cv_result,
150
- "cv_mean_result": cv_mean_result,
151
- "cv_std_result": cv_std_result
152
- }
153
 
154
  # Example call to the function
155
  # result = pred_output()
 
86
  means = list(np.mean([acc_cv, f1_mi_cv, f1_ma_cv, f1_we_cv, pr_mi_cv, pr_ma_cv, pr_we_cv, rc_mi_cv, rc_ma_cv, rc_we_cv, hamm_cv], axis=1))
87
  means = [np.round(i, decimals=5) for i in means]
88
 
89
+ #stds = list(np.std([acc_cv, f1_mi_cv, f1_ma_cv, f1_we_cv, pr_mi_cv, pr_ma_cv, pr_we_cv, rc_mi_cv, rc_ma_cv, rc_we_cv, hamm_cv], axis=1))
90
+ #stds = [np.round(i, decimals=5) for i in stds]
91
 
92
  return {
 
93
  "means": [representation_name + "_" + dataset] + means,
 
 
94
  }
95
 
96
  def ProtDescModel():
 
105
  else:
106
  filtered_datasets = [dataset for dataset in datasets if aspect_type in dataset and dataset_type in dataset]
107
 
108
+ #cv_results = []
109
  cv_mean_results = []
110
+ #cv_std_results = []
111
 
112
  for dt in tqdm(filtered_datasets, total=len(filtered_datasets)):
113
  print(f"Protein function prediction is started for the dataset: {dt.split('.')[0]}")
 
125
  classifier=BinaryRelevance(SGDClassifier(n_jobs=cpu_number, random_state=42)))
126
 
127
  if model is not None:
128
+ #cv_results.append(model["cv_results"])
129
  cv_mean_results.append(model["means"])
130
+ #cv_std_results.append(model["stds"])
131
 
132
+ return cv_mean_results
 
 
 
 
133
 
134
  def pred_output():
135
+ result = ProtDescModel()
 
 
 
 
136
 
137
+ return result
 
 
 
 
138
 
139
  # Example call to the function
140
  # result = pred_output()