Exemplo n.º 1
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()
Exemplo n.º 2
0
    learning_rate=0.1,
    corruption_level=0.1,
    cost_measure="cross_entropy",
    rng=rng)  # cost_measure can be either "cross_entropy" or "euclidean"

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

# classification
# train classifier
logistic_trained, training_time_logistic = logistic_sgd.train_model(
    learning_rate=0.1,
    n_epochs=1000,
    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=200)

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

# 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()
Exemplo n.º 3
0
            # 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:
                perf=numpy.vstack((perf,perf_i))
                conf_mat=conf_mat+conf_mat_i
                training_times=training_times + training_time
                test_times=test_times + test_time
Exemplo n.º 4
0
# train, and extract features from training set
model_trained, train_set_x_extr, training_time = rbm.train_model(rng=rng,train_set_x_org=train_set_x_org, 
                                                  training_epochs=10, batch_size=100,
                                                  n_hidden=93, learning_rate=0.1, persistent_chain_k=30)
    
# 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
logistic_trained,training_time_logistic=logistic_sgd.train_model(learning_rate=0.1, n_epochs=1000, 
                         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=200)

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

# 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

# sample from RBM
samples_vis, samples_vis_mf=rbm.sample_model(rng, model_trained, test_set_x_org, n_chains=20,n_samples=10,sample_gap=1000)

# collect garbage
gc_collect()
Exemplo n.º 5
0
            # 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:
                perf = numpy.vstack((perf, perf_i))
                conf_mat = conf_mat + conf_mat_i
                training_times = training_times + training_time