Showing
1 changed file
with
36 additions
and
36 deletions
... | @@ -157,38 +157,6 @@ if __name__ == "__main__": | ... | @@ -157,38 +157,6 @@ if __name__ == "__main__": |
157 | print(" Number of training class I: {}".format(y_train.count('I'))) | 157 | print(" Number of training class I: {}".format(y_train.count('I'))) |
158 | print(" Shape of training matrix: {}".format(X_train.shape)) | 158 | print(" Shape of training matrix: {}".format(X_train.shape)) |
159 | 159 | ||
160 | - print("Reading testing data and true classes...") | ||
161 | - X_test = None | ||
162 | - if args.saveData: | ||
163 | - y_test = [] | ||
164 | - testingData = [] | ||
165 | - with open(os.path.join(args.inputPath, args.inputTestingData), encoding='utf8', mode='r') \ | ||
166 | - as iFile: | ||
167 | - for line in iFile: | ||
168 | - line = line.strip('\r\n') | ||
169 | - listLine = line.split(',') | ||
170 | - testingData.append(listLine[1:]) | ||
171 | - X_test = csr_matrix(testingData, dtype='double') | ||
172 | - with open(os.path.join(args.inputPath, args.inputTestingClasses), encoding='utf8', mode='r') \ | ||
173 | - as iFile: | ||
174 | - for line in iFile: | ||
175 | - line = line.strip('\r\n') | ||
176 | - y_test.append(line) | ||
177 | - print(" Saving matrix and classes...") | ||
178 | - joblib.dump(X_test, os.path.join(args.outputModelPath, args.inputTestingData + '.jlb')) | ||
179 | - joblib.dump(y_test, os.path.join(args.outputModelPath, args.inputTestingClasses + '.class.jlb')) | ||
180 | - print(" Done!") | ||
181 | - else: | ||
182 | - print(" Loading matrix and classes...") | ||
183 | - X_test = joblib.load(os.path.join(args.outputModelPath, args.inputTestingData + '.jlb')) | ||
184 | - y_test = joblib.load(os.path.join(args.outputModelPath, args.inputTestingClasses + '.class.jlb')) | ||
185 | - print(" Done!") | ||
186 | - | ||
187 | - print(" Number of testing classes: {}".format(len(y_test))) | ||
188 | - print(" Number of testing class A: {}".format(y_test.count('A'))) | ||
189 | - print(" Number of testing class I: {}".format(y_test.count('I'))) | ||
190 | - print(" Shape of testing matrix: {}".format(X_test.shape)) | ||
191 | - | ||
192 | # Feature selection and dimensional reduction | 160 | # Feature selection and dimensional reduction |
193 | if args.reduction is not None: | 161 | if args.reduction is not None: |
194 | print('Performing dimensionality reduction or feature selection...', args.reduction) | 162 | print('Performing dimensionality reduction or feature selection...', args.reduction) |
... | @@ -252,12 +220,44 @@ if __name__ == "__main__": | ... | @@ -252,12 +220,44 @@ if __name__ == "__main__": |
252 | X_train, y_train = sm.fit_sample(X_train, y_train) | 220 | X_train, y_train = sm.fit_sample(X_train, y_train) |
253 | 221 | ||
254 | print(" After transformtion with {}".format(args.imbalanced)) | 222 | print(" After transformtion with {}".format(args.imbalanced)) |
255 | - print(" Number of testing classes: {}".format(len(y_test))) | 223 | + print(" Number of training classes: {}".format(len(y_train))) |
256 | - print(" Number of testing class A: {}".format(y_test.count('A'))) | 224 | + print(" Number of training class A: {}".format(y_train.count('A'))) |
257 | - print(" Number of testing class I: {}".format(y_test.count('I'))) | 225 | + print(" Number of training class I: {}".format(y_train.count('I'))) |
258 | - print(" Shape of testing matrix: {}".format(X_test.shape)) | 226 | + print(" Shape of training matrix: {}".format(X_train.shape)) |
259 | print(" Data transformation done in : %fs" % (time() - t1)) | 227 | print(" Data transformation done in : %fs" % (time() - t1)) |
260 | 228 | ||
229 | + print("Reading testing data and true classes...") | ||
230 | + X_test = None | ||
231 | + if args.saveData: | ||
232 | + y_test = [] | ||
233 | + testingData = [] | ||
234 | + with open(os.path.join(args.inputPath, args.inputTestingData), encoding='utf8', mode='r') \ | ||
235 | + as iFile: | ||
236 | + for line in iFile: | ||
237 | + line = line.strip('\r\n') | ||
238 | + listLine = line.split(',') | ||
239 | + testingData.append(listLine[1:]) | ||
240 | + X_test = csr_matrix(testingData, dtype='double') | ||
241 | + with open(os.path.join(args.inputPath, args.inputTestingClasses), encoding='utf8', mode='r') \ | ||
242 | + as iFile: | ||
243 | + for line in iFile: | ||
244 | + line = line.strip('\r\n') | ||
245 | + y_test.append(line) | ||
246 | + print(" Saving matrix and classes...") | ||
247 | + joblib.dump(X_test, os.path.join(args.outputModelPath, args.inputTestingData + '.jlb')) | ||
248 | + joblib.dump(y_test, os.path.join(args.outputModelPath, args.inputTestingClasses + '.class.jlb')) | ||
249 | + print(" Done!") | ||
250 | + else: | ||
251 | + print(" Loading matrix and classes...") | ||
252 | + X_test = joblib.load(os.path.join(args.outputModelPath, args.inputTestingData + '.jlb')) | ||
253 | + y_test = joblib.load(os.path.join(args.outputModelPath, args.inputTestingClasses + '.class.jlb')) | ||
254 | + print(" Done!") | ||
255 | + | ||
256 | + print(" Number of testing classes: {}".format(len(y_test))) | ||
257 | + print(" Number of testing class A: {}".format(y_test.count('A'))) | ||
258 | + print(" Number of testing class I: {}".format(y_test.count('I'))) | ||
259 | + print(" Shape of testing matrix: {}".format(X_test.shape)) | ||
260 | + | ||
261 | jobs = -1 | 261 | jobs = -1 |
262 | paramGrid = [] | 262 | paramGrid = [] |
263 | nIter = 20 | 263 | nIter = 20 | ... | ... |
-
Please register or login to post a comment