Пример #1
0
def collect_svc(name, most_similar_name, indices):
    svc_results = []

    data = dataTools.AuthorshipOneVsOne(name, most_similar_name, ratioTrain,
                                        ratioValid, dataPath)
    logging.info('Training SVM on {0} v.s. {1}'.format(name,
                                                       most_similar_name))

    for split_n in range(NO_OF_SPLITS):
        data.get_split(name, most_similar_name, ratioTrain, ratioValid)

        data.reduce_dim(indices)

        start = time.perf_counter()

        svc = linear_class.train_svc(data)
        end = time.perf_counter()

        svc_result = evaluate_svc(svc, data)
        svc_result['time'] = start - end

        svc_results.append(svc_result)

        logging.info(
            'SPLIT {0}: SVM results successfully collected: {1}'.format(
                split_n, svc_result))

    return svc_results
Пример #2
0
def collect_gcnn(name, most_similar_name, phi, ind):
    gcnn_results = []

    data = dataTools.AuthorshipOneVsOne(name, most_similar_name, ratioTrain,
                                        ratioValid, dataPath)
    logging.info('Training GCNN on {0} v.s. {1}'.format(
        name, most_similar_name))
    h_params = ClusterUtils.load_best_hyperparams(name)

    for split_n in range(NO_OF_SPLITS):
        data.get_split(name, most_similar_name, ratioTrain, ratioValid)

        data.reduce_dim(ind)

        start = time.perf_counter()

        gcnn = train_helper.train_net(data, h_params, phi=phi)

        end = time.perf_counter()

        gcnn_eval = evaluate_gcnn(gcnn, data)
        gcnn_eval['time'] = start - end
        gcnn_results.append(gcnn_eval)

        logging.info(
            'SPLIT {0}: GCNN results successfully collected: {1}'.format(
                split_n, gcnn_results[split_n]))

    return gcnn_results
Пример #3
0
def collect_gcnn(name, most_similar_name):
    gcnn_results = []

    data = dataTools.AuthorshipOneVsOne(name, most_similar_name, ratioTrain, ratioValid, dataPath)
    logging.info('Training GCNN on {0} v.s. {1}'.format(name, most_similar_name))
    h_params = ClusterUtils.load_best_hyperparams(name)

    for split_n in range(NO_OF_SPLITS):
        data.get_split(name, most_similar_name, ratioTrain, ratioValid)
        gcnn = train_helper.train_net(data, h_params)

        gcnn_results.append(evaluate_gcnn(gcnn, data))

        logging.info('SPLIT {0}: GCNN results successfully collected: {1}'.format(split_n, gcnn_results[split_n]))

    return gcnn_results