Exemple #1
0
            # train, and extract features from training set
            model_trained, train_set_x_extr, training_time = rbm.train_model(train_set_x_org=train_set_x_org, 
                                                                            training_epochs=n_epochs, batch_size=batch_size,
                                                                            n_hidden=n_hidden, learning_rate=learning_rate, persistent_chain_k=persistent_chain_k, rng=rng)
            
            # extract features from test set and validation set
            test_set_x_extr = rbm.test_model(model_trained, test_set_x_org)
            valid_set_x_extr =rbm.test_model(model_trained, valid_set_x_org)
    
            # classification
            # train classifier
            learning_rate=0.1
            n_epochs=100
            batch_size=100
            logistic_trained,training_time_logistic=logistic_sgd.train_model(learning_rate=learning_rate, n_epochs=n_epochs, 
                                                                             train_set_x_org=train_set_x_extr, train_set_y_org=train_set_y_org, 
                                                                             valid_set_x_org=valid_set_x_extr, valid_set_y_org=valid_set_y_org, 
                                                                             batch_size=batch_size)

            # test classifier       
            test_set_y_pred,test_set_y_pred_prob,test_time=logistic_sgd.test_model(logistic_trained,test_set_x_extr)
                        
            # evaluate classification performance
            perf_i,conf_mat_i=cl.perform(test_set_y_org,test_set_y_pred,numpy.unique(train_set_y_org))
            print perf_i
            print conf_mat_i
            if i==0:
                perf=perf_i
                conf_mat=conf_mat_i
                training_times=training_time
                test_times=test_time
            else:
Exemple #2
0
valid_set_y_org=numpy.loadtxt(filename,delimiter='\t',dtype=object)
prev,valid_set_y_org=cl.change_class_labels(valid_set_y_org)
# test set
filename=data_dir + "GM12878_200bp_Data_3Cl_l2normalized_TestSet.txt";
test_set_x_org=numpy.loadtxt(filename,delimiter='\t',dtype='float32')
filename=data_dir + "GM12878_200bp_Classes_3Cl_l2normalized_TestSet.txt";
test_set_y_org=numpy.loadtxt(filename,delimiter='\t',dtype=object)
prev,test_set_y_org=cl.change_class_labels(test_set_y_org)

filename=data_dir + "GM12878_Features_Unique.txt";
features=numpy.loadtxt(filename,delimiter='\t',dtype=object)  

rng=numpy.random.RandomState(1000)

# train
classifier_trained,training_time=logistic_sgd.train_model(learning_rate=0.1, n_epochs=1000,
            train_set_x_org=train_set_x_org,train_set_y_org=train_set_y_org,
            valid_set_x_org=valid_set_x_org,valid_set_y_org=valid_set_y_org, 
            batch_size=200)
# test
test_set_y_pred,test_set_y_pred_prob,test_time=logistic_sgd.test_model(classifier_trained,test_set_x_org)
print test_set_y_pred
print test_set_y_pred_prob
print test_time
# evaluate classification performance
perf,conf_mat=cl.perform(test_set_y_org,test_set_y_pred,numpy.unique(train_set_y_org))
print perf
print conf_mat

gc_collect()
Exemple #3
0
                persistent_chain_k=persistent_chain_k,
                rng=rng)

            # extract features from test set and validation set
            test_set_x_extr = rbm.test_model(model_trained, test_set_x_org)
            valid_set_x_extr = rbm.test_model(model_trained, valid_set_x_org)

            # classification
            # train classifier
            learning_rate = 0.1
            n_epochs = 100
            batch_size = 100
            logistic_trained, training_time_logistic = logistic_sgd.train_model(
                learning_rate=learning_rate,
                n_epochs=n_epochs,
                train_set_x_org=train_set_x_extr,
                train_set_y_org=train_set_y_org,
                valid_set_x_org=valid_set_x_extr,
                valid_set_y_org=valid_set_y_org,
                batch_size=batch_size)

            # test classifier
            test_set_y_pred, test_set_y_pred_prob, test_time = logistic_sgd.test_model(
                logistic_trained, test_set_x_extr)

            # evaluate classification performance
            perf_i, conf_mat_i = cl.perform(test_set_y_org, test_set_y_pred,
                                            numpy.unique(train_set_y_org))
            print perf_i
            print conf_mat_i
            if i == 0:
                perf = perf_i