コード例 #1
0
    'expo_prior': 0.1
}
predict_config = {}
''' Settings nested cross-validation. '''
K_range = [1, 2, 3]
no_folds = 10
no_threads = 5
parallel = False
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 dataset. '''
R, M = load_ccle_ic50()
''' Run the cross-validation framework. '''
nested_crossval = MatrixNestedCrossValidation(
    method=nmf_np,
    R=R,
    M=M,
    K=no_folds,
    P=no_threads,
    parameter_search=parameter_search,
    train_config=train_config,
    predict_config=predict_config,
    file_performance=output_file,
    files_nested_performances=files_nested_performances,
)
nested_crossval.run(parallel=parallel)
コード例 #2
0
project_location = "/home/tab43/Documents/Projects/libraries/"  # "/Users/thomasbrouwer/Documents/Projects/libraries/"
import sys
sys.path.append(project_location)

from BNMTF_ARD.data.drug_sensitivity.load_data import load_gdsc_ic50
from BNMTF_ARD.data.drug_sensitivity.load_data import load_ctrp_ec50
from BNMTF_ARD.data.drug_sensitivity.load_data import load_ccle_ic50
from BNMTF_ARD.data.drug_sensitivity.load_data import load_ccle_ec50

import itertools
import matplotlib.pyplot as plt
''' Load in the data. '''
R_gdsc, M_gdsc = load_gdsc_ic50()
R_ctrp, M_ctrp = load_ctrp_ec50()
R_ccle_ic, M_ccle_ic = load_ccle_ic50()
R_ccle_ec, M_ccle_ec = load_ccle_ec50()


def extract_values(R, M):
    I, J = R.shape
    return [
        R[i, j] for i, j in itertools.product(range(I), range(J)) if M[i, j]
    ]


values_plotnames_bins = [
    (extract_values(R_gdsc, M_gdsc), 'distribution_gdsc_ic50.pdf',
     [v - 0.5 for v in range(0, 100 + 10, 5)]),
    (extract_values(R_ctrp, M_ctrp), 'distribution_ctrp_ec50.pdf',
     [v - 0.5 for v in range(0, 100 + 10, 5)]),