def store(output_dir, cv_method): ''' INPUT output_dir: is the directory where to store the keymetrics (ranking, weights and accuracies dataframes) cv_method : 5_fold , 10_fold or LOO OUTPUT stored pickle dataframes in the given directory ''' # Initialize empty dataframes pool_FS = [ reliefF ] #,lap_score,ll_l21,ls_l21,UDFS,fisher_score,chi_square,gini_index,SPEC] labels = [ 'reliefF' ] #,'lap_score','ll_l21','ls_l21','UDFS','fisher_score','chi_square','gini_index','SPEC']#,'Boratapy'] dataframe_ranking = pd.DataFrame(index=num_fea, columns=labels) dataframe_weights = pd.DataFrame(index=num_fea, columns=labels) dataframe_accuracies = pd.DataFrame(index=num_fea, columns=labels) #matrix_=np.zeros((50,589*3)) for i in range(len(pool_FS)): for k in num_fea: ranking__, acc__, weight__ = training(cv_method, k, pool_FS[i], X, y) #ranking__,acc__=training(kf5,k,pool_FS[i],X,y) #ranking__,acc__,=training(kf5,k,pool_FS[i]) dataframe_ranking[labels[i]][k] = ranking__ dataframe_weights[labels[i]][k] = weight__ dataframe_accuracies[labels[i]][k] = acc__ #dataframe_ranking_5fold=dataframe_ranking.copy() #dataframe_weights_5fold=dataframe_weights.copy() #dataframe_accuracies_5fold=dataframe_accuracies.copy() name1, name2, name3 = name_dataframe(X, cv_method) dataframe_accuracies.to_pickle(output_dir + name1) dataframe_ranking.to_pickle(output_dir + name2) dataframe_weights.to_pickle(output_dir + name3)
# You should have received a copy of the GNU General Public License # along with Foobar. If not, see <http://www.gnu.org/licenses/>. # # (c) Junya Kaneko <*****@*****.**> from matplotlib import pyplot as plt from nn.networks import Classifier from dataset import MnistTrainingDataset, MnistTestDataset from helpers import training, test, draw_W_histories, draw_mean_se_history, draw_cpr_history if __name__ == '__main__': # Load MNIST dataset training_dataset = MnistTrainingDataset('./mnist', 1, 0) test_dataset = MnistTestDataset('./mnist', 1, 0) # Create Deep Neural Network classifier = Classifier('rectifier', training_dataset.img_size, 'se', 0.15) classifier.add_layer('rectifier', 200) classifier.add_layer('rectifier', 10) W_histories, mean_se_history, cpr_history = training(classifier, training_dataset, 400) draw_W_histories(W_histories, classifier.name, training_dataset.name) draw_mean_se_history(mean_se_history, classifier.name, training_dataset.name) draw_cpr_history(cpr_history, classifier.name, training_dataset.name) print(test(classifier, test_dataset)) plt.show()