# Compose the training ( data & labels ) training_data = np.array(training_normal + training_dme) training_label = np.array([0] * len(training_normal) + [1] * len(training_dme), dtype=int) # Compose the testing testing_data = np.array([ current_cbook.get_BoF_descriptor( get_lbp_data(filename_normal[idx_test]))[0], current_cbook.get_BoF_descriptor( get_lbp_data(filename_dme[idx_test]))[0] ]) # Run the classification for this specific data pred_label, roc = Classify(training_data, training_label, testing_data, np.array([0, 1], dtype=int), **config_class) results_by_codebook.append((pred_label, roc)) return results_by_codebook ################################################################################################ ################################################################################################ ### Define the global variable regarding the classification config = [{ 'classifier_str': 'random-forest', 'n_estimators': 100, 'gs_n_jobs': 8
training_data = dmr.fit_transform(training_data) # Compose the testing testing_data = np.array([ get_lbp_data(filename_normal[idx_test]), get_lbp_data(filename_dme[idx_test]) ]) # Project the testing_data testing_data = dmr.transform(testing_data) # Run the classification for this specific data pred_label, roc = Classify(training_data, training_label, testing_data, np.array([0, 1], dtype=int), classifier_str='random-forest', n_estimators=100, n_jobs=60, max_features=None) results_cv.append((pred_label, roc)) # We have to store the final codebook path_to_save = '/work/le2i/gu5306le/OCT/lbp_r_' + str( radius) + '_hist_pca_results' if not os.path.exists(path_to_save): os.makedirs(path_to_save) from sklearn.externals import joblib joblib.dump(results_cv, join(path_to_save, 'hist.pkl'))
# OS library import os from os.path import join, isdir, isfile # sys library import sys from protoclass.classification.classification import Classify # Generate a vector label = np.array([-1] * 1000 + [1] * 200) data = np.random.random((label.shape[0], 5)) label2 = np.array([-1] * 100 + [1] * 20) data2 = np.random.random((label2.shape[0], 5)) balancing_criterion = 'balance-cascade' kind_smote = 'svm' version_nearmiss = 3 classifier_str = 'naive-bayes' pred_label, pred_prob, roc = Classify( data, label, data2, label2, classifier_str=classifier_str, class_prior=np.array([0.3, 0.7])) #, balancing_criterion=balancing_criterion) print pred_label print pred_prob print roc