Ejemplo n.º 1
0
def eval_func(space, space_fixed):
    try:
        space = {**space, **space_fixed}
        prince = diseaseslib.PrioritizationPRINCE(
            bipartite_network=bip_diseases,
            query_nodes_name="diseaseId",
            leave_p_out=priorization_params["leave_p_out"],
            max_evals=priorization_params["n_evaluations"],
            similarity_lower_threshold=space["threshold"],
            mode=space["mode"],
            to_undirected=space["to_directed"])
        l_seeds, l_seeds_weight, l_target_genes, l_true_target_genes = prince.generate_data_to_prioritize(
            bip_diseases, gl)

        localeval = evaluators.AUROClinkage(
            node_names=genes_in_data,
            l_seeds=l_seeds,
            l_targets=l_targets,
            l_true_targets=l_true_targets,
            l_seeds_weight=l_seeds_weight,
            alpha=priorization_params["alpha"],
            laplacian_exponent=priorization_params["lambda exponent"],
            tol=1e-08,
            max_iter=priorization_params["max_iter"],
            max_fpr=priorization_params["max_fpr"],
            auroc_normalized=priorization_params["auroc_normalize"])
        val = localeval.evaluate(dict_of_networks["PPI"])
        print(val)
        return val
    except AssertionError:
        print(space)
        return -1  # mark that something went wrong
def eval_func(space):
    return evaluators.AUROClinkage(node_names=genes_in_data,
                            l_seeds=l_seeds,
                            l_targets=l_targets,
                            l_true_targets=l_true_targets,
                            l_seeds_weight=l_seeds_weight,
                            alpha=space["alpha"],
                            laplacian_exponent=priorization_params["lambda exponent"],  # here is the varaible
                            tol=1e-08,
                            max_iter=priorization_params["max_iter"],
                            max_fpr=priorization_params["max_fpr"],
                            auroc_normalized=priorization_params["auroc_normalize"]).evaluate(dict_of_networks["PPI"])
gl.filter_genes(genes_in_data)

prioritize = diseaseslib.PreparePrioritization(leave_p_out=priorization_params["leave_p_out"],
                                               max_evals=priorization_params["n_evaluations"])
l_seeds, l_seeds_weight, l_targets, l_true_targets = prioritize.generate_data_to_prioritize(d, gl)


###############################################################################
#                       BP+PPI CC+PPI
###############################################################################
evaluator = evaluators.AUROClinkage(node_names=genes_in_data,
                                    l_seeds=l_seeds,
                                    l_targets=l_targets,
                                    l_true_targets=l_true_targets,
                                    l_seeds_weight=l_seeds_weight,
                                    alpha=priorization_params["alpha"],
                                    laplacian_exponent=priorization_params["lambda exponent"],
                                    tol=1e-08,
                                    max_iter=priorization_params["max_iter"],
                                    max_fpr=priorization_params["max_fpr"],
                                    auroc_normalized=priorization_params["auroc_normalize"])


############################################################
t0=time()
auc_ppi = evaluator.evaluate(dict_of_networks["PPI"])
print("Time: ", time()-t0)
print(auc_ppi)

t0 = time()
auc_bp = evaluator.evaluate(dict_of_networks["BP"])
Ejemplo n.º 4
0
    print(p)
    l_true_targets = [[int(np.random.choice(targets, size=1, p=p))]
                      for targets in l_targets]

    print("Target list:")
    print(l_targets)
    print("True targets")
    print(l_true_targets)

    # --------------------------
    evaluator = evaluators.AUROClinkage(node_names=list(range(N)),
                                        l_seeds_dict=l_seeds_dict,
                                        l_targets=l_targets,
                                        l_true_targets=l_true_targets,
                                        alpha=alpha,
                                        tol=1e-08,
                                        max_iter=max_iter,
                                        max_fpr=max_fpr,
                                        laplacian_exponent=laplacian_exponent,
                                        auroc_normalized=False,
                                        k_fold=3)
    print(evaluator.metric_name)

    optimizer = Optimizer(
        optimization_name=evaluator.metric_name + "_" + integrator.__name__,
        path2files="/home/crux/Downloads",
        space=Optimizer.get_integrator_space(integrator=integrator),
        objective_function=lambda sp: Optimizer.gamma_objective_function(
            sp, evaluator=evaluator, integrator=integrator),
        max_evals=max_evals,
        maximize=True)