예제 #1
0
repeats = 10

iterations = 1000
init_UV = 'random'
I, J, K = 622,138,25

minimum_TN = 0.1

alpha, beta = 1., 1. #1., 1.
lambdaU = numpy.ones((I,K))/10.
lambdaV = numpy.ones((J,K))/10.
priors = { 'alpha':alpha, 'beta':beta, 'lambdaU':lambdaU, 'lambdaV':lambdaV }

# Load in data
(_,R,M,_,_,_,_) = load_gdsc(standardised=standardised)


# Run the VB algorithm, <repeats> times
times_repeats = []
performances_repeats = []
for i in range(0,repeats):
    # Set all the seeds
    numpy.random.seed(0)
    
    # Run the classifier
    nmf = nmf_icm(R,M,K,priors) 
    nmf.initialise(init_UV)
    nmf.run(iterations,minimum_TN=minimum_TN)

    # Extract the performances and timestamps across all iterations
예제 #2
0
sys.path.append(project_location)

from BNMTF.code.nmtf_np import NMTF
from BNMTF.drug_sensitivity.experiments_gdsc.load_data import load_gdsc

import matplotlib.pyplot as plt

##########

standardised = False #standardised Sanger or unstandardised

iterations = 1000
I, J, K, L = 622,138,5, 5

init_S = 'exponential'
init_FG = 'kmeans'
expo_prior = 1/10.

# Load in data
(_,X_min,M,_,_,_,_) = load_gdsc(standardised=standardised)

# Run the algorithm
nmtf = NMTF(X_min,M,K,L) 
nmtf.initialise(init_S,init_FG,expo_prior)
nmtf.run(iterations)

# Print the performances across iterations (MSE)
print "all_performances = %s" % nmtf.all_performances['MSE']

# Plot the performances (MSE)
plt.plot(nmtf.all_performances['MSE'])
예제 #3
0
standardised = False
train_config = {
    'iterations' : 1000,
    'init_UV' : 'exponential',
    'expo_prior' : 0.1
}
K_range = range(2,10+1,2)
no_folds = 10
output_file = "./results.txt"
files_nested_performances = ["./fold_%s.txt" % fold for fold in range(1,no_folds+1)]

# Construct the parameter search
parameter_search = [{'K':K} for K in K_range]

# Load in the Sanger dataset
(_,X_min,M,_,_,_,_) = load_gdsc(standardised=standardised,sep=',')

# Run the cross-validation framework
random.seed(42)
numpy.random.seed(9000)
nested_crossval = MatrixCrossValidation(
    method=NMF,
    X=X_min,
    M=M,
    K=no_folds,
    parameter_search=parameter_search,
    train_config=train_config,
    file_performance=output_file
)
nested_crossval.run()
예제 #4
0
standardised = False
train_config = {
    'iterations': 1000,
    'init_UV': 'exponential',
    'expo_prior': 0.1
}
K_range = range(2, 10 + 1, 2)
no_folds = 10
output_file = "./results.txt"
files_nested_performances = [
    "./fold_%s.txt" % fold for fold in range(1, no_folds + 1)
]

# Construct the parameter search
parameter_search = [{'K': K} for K in K_range]

# Load in the Sanger dataset
(_, X_min, M, _, _, _, _) = load_gdsc(standardised=standardised, sep=',')

# Run the cross-validation framework
random.seed(42)
numpy.random.seed(9000)
nested_crossval = MatrixCrossValidation(method=NMF,
                                        X=X_min,
                                        M=M,
                                        K=no_folds,
                                        parameter_search=parameter_search,
                                        train_config=train_config,
                                        file_performance=output_file)
nested_crossval.run()