annotate machine_learning.py @ 5:1dbf350629bf draft

Uploaded
author pedro_araujo
date Fri, 29 Jan 2021 16:07:29 +0000
parents e4b3fc88efe0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
1
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
2 class PredictInteraction:
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
3
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
4 def __init__(self, data = 'FeatureDataset'):
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
5 import pickle
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
6 from sklearn.preprocessing import LabelEncoder
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
7 with open('files/' + data, 'rb') as f:
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
8 self.dataset = pickle.load(f)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
9 self.dataset = self.dataset.dropna()
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
10 le = LabelEncoder()
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
11 le.fit(['Yes', 'No'])
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
12 self.output = le.transform(self.dataset['Infects'].values)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
13 self.dataset = self.dataset.drop('Infects', 1)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
14 self.__standardize()
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
15 self.__split_train_test()
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
16
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
17 def __standardize(self):
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
18 from sklearn.preprocessing import StandardScaler
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
19 self.scaler = StandardScaler()
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
20 self.scaler.fit(self.dataset)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
21 self.data_z = self.scaler.transform(self.dataset)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
22
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
23 def __cross_validation(self, method):
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
24 from sklearn.model_selection import cross_val_score
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
25 from sklearn.model_selection import StratifiedKFold
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
26 # from sklearn.model_selection import ShuffleSplit
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
27 # cv = ShuffleSplit(n_splits=4, test_size=0.3) # cross validation normal
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
28 skf = StratifiedKFold(5, shuffle=True)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
29 scores = cross_val_score(method, self.data_z, self.output, cv=skf, scoring='f1_weighted')
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
30 print(scores)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
31 return skf
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
32
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
33 def __split_train_test(self):
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
34 from sklearn.model_selection import train_test_split
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
35 self.data_z, self.X_val, self.output, self.y_val = train_test_split(self.data_z, self.output, test_size=0.2)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
36 self.X_train, self.X_test, self.y_train, self.y_test = train_test_split(self.data_z, self.output, test_size=0.3)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
37
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
38 def run_knn(self, n=2):
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
39 from sklearn.neighbors import KNeighborsClassifier
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
40 from sklearn.metrics import confusion_matrix
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
41 neigh = KNeighborsClassifier(n_neighbors=n, weights='distance', p=1, algorithm='brute')
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
42 neigh.fit(self.X_train, self.y_train)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
43 # print(neigh.score(self.X_test, self.y_test))
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
44 self.__score_metrics(neigh)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
45 # print(confusion_matrix(self.y_test, neigh.predict(self.X_test)))
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
46 import time
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
47 start_time = time.time()
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
48 cv = self.__cross_validation(neigh)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
49 print("--- %s seconds ---" % (time.time() - start_time))
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
50 # self.__plot_roc_cv(neigh, cv)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
51 # self.__auc_curve(neigh)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
52 self.__permutation_importance(self._hyperparameters_knn(neigh))
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
53
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
54 def _hyperparameters_knn(self, method):
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
55 from sklearn.model_selection import GridSearchCV
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
56 parameters = {'leaf_size': [5, 15, 30, 50], 'n_neighbors': [2, 3, 5, 7], 'weights': ['uniform', 'distance'], 'algorithm': ['auto', 'ball_tree', 'kd_tree', 'brute'], 'p': [1, 2]}
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
57 clf = GridSearchCV(method, parameters)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
58 clf.fit(self.X_val, self.y_val)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
59 self.__score_metrics(clf)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
60 print(clf.best_params_)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
61 return clf
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
62
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
63 def run_random_forest(self):
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
64 from sklearn.ensemble import RandomForestClassifier
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
65 from sklearn.metrics import confusion_matrix
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
66 clf = RandomForestClassifier(n_estimators=250, bootstrap=False, ccp_alpha=0.0, max_features='sqrt')
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
67 clf = clf.fit(self.X_train, self.y_train)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
68 # print(clf.score(self.X_test, self.y_test))
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
69 self.__score_metrics(clf)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
70 # print(confusion_matrix(self.y_test, clf.predict(self.X_test)))
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
71 # self.recursive_feature_elimination(clf)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
72 import time
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
73 start_time = time.time()
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
74 cv = self.__cross_validation(clf)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
75 print("--- %s seconds ---" % (time.time() - start_time))
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
76 # self.__plot_roc_cv(clf, cv)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
77 # self.__auc_curve(clf)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
78 # self.__permutation_importance(clf)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
79
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
80 def _hyperparameters_rf(self, method):
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
81 from sklearn.model_selection import GridSearchCV
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
82 parameters = {'n_estimators': [50, 100, 150, 200, 250], 'criterion': ['gini', 'entropy'], 'min_samples_split': [2, 4, 6], 'min_samples_leaf': [2, 4, 6], 'bootstrap': [True, False], 'oob_score': [True, False]}
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
83 clf = GridSearchCV(method, parameters)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
84 clf.fit(self.X_val, self.y_val)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
85 self.__score_metrics(clf)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
86 print(clf.best_params_)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
87 return clf
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
88
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
89 def run_svm(self, c=0.1):
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
90 from sklearn.svm import SVC
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
91 from sklearn.metrics import confusion_matrix
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
92 svm = SVC(C=c)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
93 svm = svm.fit(self.X_train, self.y_train)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
94 # print(svm.score(self.X_test, self.y_test))
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
95 self.__score_metrics(svm)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
96 # print(confusion_matrix(self.y_test, svm.predict(self.X_test)))
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
97 import time
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
98 start_time = time.time()
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
99 cv = self.__cross_validation(svm)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
100 print("--- %s seconds ---" % (time.time() - start_time))
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
101 # self.recursive_feature_elimination(svm)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
102 # self.__plot_roc_cv(svm, cv)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
103 # self.__auc_curve(svm)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
104 # self.__permutation_importance(svm)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
105
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
106 def _hyperparameters_svm(self, method):
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
107 from sklearn.model_selection import GridSearchCV
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
108 parameters = {'C': [0.01, 0.1, 1, 10], 'kernel': ['linear','rbf','poly','sigmoid', 'precomputed'], 'degree': [2, 3, 4], 'gamma': ['scale', 'auto']}
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
109 clf = GridSearchCV(method, parameters)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
110 clf.fit(self.X_val, self.y_val)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
111 self.__score_metrics(clf)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
112 print(clf.best_params_)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
113 return clf
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
114
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
115 def run_neural_networks(self, alpha=1):
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
116 from sklearn.neural_network import MLPClassifier
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
117 from sklearn.metrics import confusion_matrix
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
118 clf = MLPClassifier(alpha=alpha)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
119 clf.fit(self.X_train, self.y_train)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
120 self.__score_metrics(clf)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
121 # print(confusion_matrix(self.y_test, clf.predict(self.X_test)))
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
122 import time
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
123 start_time = time.time()
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
124 cv = self.__cross_validation(clf)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
125 print("--- %s seconds ---" % (time.time() - start_time))
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
126 # self.__plot_roc_cv(clf, cv)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
127 # self.__auc_curve(clf)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
128 # self.__permutation_importance(clf)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
129
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
130 def _hyperparameters_ann(self, method):
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
131 from sklearn.model_selection import GridSearchCV
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
132 parameters = {'hidden_layer_sizes': [50, 100, 200], 'activation': ['identity', 'logistic', 'tanh', 'relu'], 'solver': ['lbfgs', 'sgd', 'adam'], 'alpha': [0.0001, 0.05], 'learning_rate': ['constant', 'invscaling', 'adaptive']}
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
133 clf = GridSearchCV(method, parameters)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
134 clf.fit(self.X_val, self.y_val)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
135 self.__score_metrics(clf)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
136 print(clf.best_params_)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
137 return clf
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
138
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
139 def run_logistic_reg(self, c=1):
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
140 from sklearn.linear_model import LogisticRegression
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
141 from sklearn.metrics import confusion_matrix
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
142 clf = LogisticRegression(C=c)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
143 clf.fit(self.X_train, self.y_train)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
144 self.__score_metrics(clf)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
145 # print(confusion_matrix(self.y_test, clf.predict(self.X_test)))
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
146 import time
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
147 start_time = time.time()
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
148 cv = self.__cross_validation(clf)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
149 print("--- %s seconds ---" % (time.time() - start_time))
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
150 # self.__plot_roc_cv(clf, cv)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
151 # self.__auc_curve(clf)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
152 # self.__permutation_importance(clf)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
153
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
154 def _hyperparameters_lr(self, method):
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
155 from sklearn.model_selection import GridSearchCV
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
156 parameters = {'penalty': ['l1', 'l2', 'elasticnet', 'none'], 'C': [0.01, 0.1, 1, 10], 'solver': ['lbfgs', 'liblinear', 'newton-cg', 'sag', 'saga']}
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
157 clf = GridSearchCV(method, parameters)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
158 clf.fit(self.X_val, self.y_val)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
159 self.__score_metrics(clf)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
160 print(clf.best_params_)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
161 return clf
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
162
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
163 def hyperparameter_tuning(self): # Best Params: {'bootstrap': False, 'ccp_alpha': 0.0, 'criterion': 'gini', 'max_features': 'sqrt', 'n_estimators': 250}
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
164 from sklearn.model_selection import GridSearchCV
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
165 from sklearn.ensemble import RandomForestClassifier
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
166 clf = RandomForestClassifier()
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
167 n_estimators = [50, 100, 150, 200, 250]
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
168 criterion = ['gini', 'entropy']
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
169 max_features = ['auto', 'sqrt', 'log2']
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
170 bootstrap = [True, False]
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
171 ccp_alpha = [0.0, 0.01, 0.02]
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
172 param_grid = dict(n_estimators=n_estimators, criterion=criterion, max_features=max_features, bootstrap=bootstrap, ccp_alpha=ccp_alpha)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
173 grid = GridSearchCV(clf, param_grid, n_jobs=-1)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
174 grid_result = grid.fit(self.X_val, self.y_val)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
175 print('Best Score: ', grid_result.best_score_)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
176 print('Best Params: ', grid_result.best_params_)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
177
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
178 def __score_metrics(self, method):
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
179 from sklearn.metrics import matthews_corrcoef, f1_score, precision_score, recall_score
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
180 print(matthews_corrcoef(self.y_test, method.predict(self.X_test)))
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
181 print(f1_score(self.y_test, method.predict(self.X_test), average=None))
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
182
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
183 def __auc_curve(self, method):
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
184 import matplotlib.pyplot as plt
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
185 from sklearn import metrics
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
186 metrics.plot_roc_curve(method, self.X_test, self.y_test)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
187 plt.plot([0, 1], [0, 1], color='navy', lw=2, linestyle='--')
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
188 plt.xlim(0, 0.2)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
189 plt.show()
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
190
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
191 def __plot_roc_cv(self, method, cv):
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
192 import numpy as np
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
193 import matplotlib.pyplot as plt
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
194 from sklearn import datasets
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
195 from sklearn.metrics import auc
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
196 from sklearn.metrics import plot_roc_curve
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
197 tprs = []
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
198 aucs = []
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
199 mean_fpr = np.linspace(0, 1, 100)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
200 fig, ax = plt.subplots()
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
201 for i, (train, test) in enumerate(cv.split(self.data_z, self.output)):
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
202 method.fit(self.data_z[train], self.output[train])
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
203 viz = plot_roc_curve(method, self.data_z[test], self.output[test], name='ROC fold {}'.format(i), alpha=0.3, lw=1, ax=ax)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
204 interp_tpr = np.interp(mean_fpr, viz.fpr, viz.tpr)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
205 interp_tpr[0] = 0.0
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
206 tprs.append(interp_tpr)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
207 aucs.append(viz.roc_auc)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
208 ax.plot([0, 1], [0, 1], linestyle='--', lw=2, color='r', label='Chance', alpha=.8)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
209 mean_tpr = np.mean(tprs, axis=0)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
210 mean_tpr[-1] = 1.0
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
211 mean_auc = auc(mean_fpr, mean_tpr)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
212 std_auc = np.std(aucs)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
213 ax.plot(mean_fpr, mean_tpr, color='b', label=r'Mean ROC (AUC = %0.2f $\pm$ %0.2f)' % (mean_auc, std_auc), lw=2, alpha=.8)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
214 std_tpr = np.std(tprs, axis=0)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
215 tprs_upper = np.minimum(mean_tpr + std_tpr, 1)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
216 tprs_lower = np.maximum(mean_tpr - std_tpr, 0)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
217 ax.fill_between(mean_fpr, tprs_lower, tprs_upper, color='grey', alpha=.2, label=r'$\pm$ 1 std. dev.')
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
218 ax.set(xlim=[-0.05, 1.05], ylim=[-0.05, 1.05], title="Receiver operating characteristic example")
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
219 ax.legend(loc="lower right")
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
220 plt.show()
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
221
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
222 def __permutation_importance(self, method):
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
223 from sklearn.inspection import permutation_importance
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
224 r = permutation_importance(method, self.X_test, self.y_test, n_repeats=5)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
225 for i in r.importances_mean.argsort()[::-1]:
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
226 if r.importances_mean[i] - 2 * r.importances_std[i] > 0.001:
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
227 print(f"{self.dataset.columns[i]:<8}"
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
228 f" {r.importances_mean[i]:.3f}"
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
229 f" +/- {r.importances_std[i]:.3f}")
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
230
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
231 def recursive_feature_elimination(self, method):
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
232 from sklearn.feature_selection import RFECV
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
233 selector = RFECV(method, cv=5)#, min_features_to_select=200)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
234 selector.fit(self.data_z, self.output)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
235 print(selector.ranking_)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
236 self.data_reduced = selector.transform(self.data_z)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
237
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
238 def predict_interaction(self, phage, bacteria):
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
239 from sklearn.svm import LinearSVC
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
240 from sklearn.ensemble import RandomForestClassifier
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
241 import numpy as np
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
242 from feature_construction import FeatureConstruction
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
243
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
244 phageProts = self.__find_phage_proteins(phage) # dictionary
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
245 bactProts = self.__find_bact_proteins(bacteria)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
246 if not phageProts or not bactProts:
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
247 print('oops')
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
248 return None
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
249 list_carb = {}
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
250 list_prot = {}
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
251 for prot in phageProts.keys():
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
252 if any(z in phageProts[prot][0].lower() for z in ['lysin', 'collagen', 'glyco', 'galac', 'chitin', 'wall', 'pectin', 'glycan', 'sialidase', 'neuramin', 'amid', 'lysozyme', 'murami', 'pectate', 'sgnh']):
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
253 list_carb[prot] = phageProts[prot]
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
254 else:
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
255 list_prot[prot] = phageProts[prot]
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
256 inter = np.array([])
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
257 fc = FeatureConstruction()
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
258 grouping = fc.get_grouping(phage=list_prot, phage_carb=list_carb, bacteria=bactProts) # takes a list of protein sequences
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
259 inter = np.append(inter, grouping)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
260 composition = fc.get_composition(phage=list_prot, phage_carb=list_carb, bacteria=bactProts)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
261 inter = np.append(inter, composition)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
262 kmers = fc.get_kmers(phage=list_prot, phage_carb=list_carb, bacteria=bactProts)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
263 inter = np.append(inter, kmers)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
264 inter = inter.reshape(1, -1)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
265 inter = self.scaler.transform(inter)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
266 # svm = LinearSVC(C=0.01, tol=0.010, dual=False)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
267 clf = RandomForestClassifier(n_estimators=250, bootstrap=False, ccp_alpha=0.0, max_features='sqrt')
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
268 clf = clf.fit(self.data_z, self.output)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
269 pred = clf.predict(inter)[0]
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
270 print(pred)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
271 return pred
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
272
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
273 def __find_phage_proteins(self, phage):
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
274 import json
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
275 with open('files/phageTails.json', encoding='utf-8') as F:
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
276 phageTails = json.loads(F.read())
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
277 phageProts = {}
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
278 if phage in phageTails.keys():
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
279 for prot in phageTails[phage]:
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
280 phageProts[prot] = [phageTails[phage][prot][0], phageTails[phage][prot][1]]
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
281 else:
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
282 from domain_search import DomainSearch
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
283 phageProts = self.__find_proteins(phage)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
284 ds = DomainSearch()
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
285 phageProts = ds.find_domains_interpro(phageProts)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
286 phageProts = ds.find_domains_blast(phageProts)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
287 phageProts = ds.find_domains_uniprot(phageProts)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
288 return phageProts
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
289
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
290 def __find_bact_proteins(self, bacteria):
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
291 import os
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
292 import json
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
293 if bacteria + '.json' in os.listdir('files/bacteria'):
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
294 with open('files/bacteria/' + bacteria + '.json', encoding='utf-8') as F:
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
295 bactProts = json.loads(F.read())
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
296 else:
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
297 pass
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
298 # bactProts = self.__find_proteins(bacteria)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
299 # Implementar previsão de localização celular
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
300 return bactProts
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
301
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
302 def __find_proteins(self, id):
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
303 from Bio import Entrez
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
304 from Bio import SeqIO
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
305 Entrez.email = 'pedro_araujo97@hotmail.com'
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
306 prots = {}
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
307 with Entrez.efetch(db="nucleotide", rettype="gb", retmode="text", id=id) as handle:
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
308 genomeBac = SeqIO.read(handle, "gb")
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
309 for feat in genomeBac.features:
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
310 if feat.type == 'CDS':
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
311 try: prots[feat.qualifiers['protein_id'][0]] = [feat.qualifiers['product'][0], feat.qualifiers['translation'][0]]
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
312 except: pass
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
313 if len(genomeBac.features) <= 5:
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
314 with Entrez.efetch(db="nucleotide", rettype="gbwithparts", retmode="text", id=id) as handle:
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
315 genomeBac = handle.readlines()
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
316 for i in range(len(genomeBac)):
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
317 if ' CDS ' in genomeBac[i]:
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
318 j = i
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
319 protDone = False
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
320 while j < len(genomeBac):
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
321 if protDone:
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
322 break
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
323 if '/product=' in genomeBac[j]:
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
324 product = genomeBac[j].strip()[10:]
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
325 j += 1
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
326 elif '_id=' in genomeBac[j]:
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
327 protKey = genomeBac[j].strip()[13:-1]
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
328 j += 1
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
329 elif '/translation=' in genomeBac[j]:
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
330 protSeq = genomeBac[j].strip()[14:]
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
331 j += 1
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
332 for k in range(j, len(genomeBac)):
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
333 if genomeBac[k].islower():
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
334 j = k
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
335 protDone = True
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
336 break
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
337 else:
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
338 protSeq += genomeBac[k].strip()
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
339 else:
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
340 j += 1
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
341 prots[protKey] = [product, protSeq[:protSeq.find('"')]]
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
342 return prots
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
343
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
344
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
345 if __name__ == '__main__':
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
346 ml = PredictInteraction('dataset_reduced') # FeatureDataset
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
347 # ml.predict_interaction('NC_050143', 'NC_020524.1') # NC_010468.1 NC_013941.1 NZ_CP029060.1 NZ_CP027394.1 NZ_CP025089.1
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
348 ml.predict_interaction('KM607000', 'NC_020524') # NC_010468.1 NC_013941.1 NZ_CP029060.1 NZ_CP027394.1 NZ_CP025089.1
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
349 ml.run_knn(2)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
350 ml.run_random_forest()
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
351 ml.run_svm(0.001)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
352 ml.run_neural_networks(0.0001)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
353 ml.run_logistic_reg(0.01)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
354
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
355 import pandas as pd
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
356 import ast
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
357 data = pd.read_csv('files/NCBI_Phage_Bacteria_Data.csv', header=0, index_col=0)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
358 abaumannii = {}
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
359 for phage in data.index:
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
360 name = data.loc[phage, 'Host']
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
361 if 'acinetobacter' in name.lower():
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
362 for bact in ast.literal_eval(data.loc[phage, 'Host_ID']):
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
363 abaumannii[bact] = 0
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
364 list_yes = {}
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
365 list_yes['KT588074'] = []
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
366 for bact in abaumannii.keys():
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
367 predict = ml.predict_interaction('KT588074', bact)
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
368 if predict == 'Yes':
e4b3fc88efe0 Uploaded
pedro_araujo
parents:
diff changeset
369 list_yes['KT588074'].append(bact)