示例#1
0
def train_svm_repeatedly(kernel,
                         train_X,
                         train_y,
                         valid_X,
                         valid_y,
                         test_X,
                         test_y,
                         masks_list=None):
    metrics_bundles = []
    for mask in masks_list:
        metrics_bundles.append(
            train_svm(kernel,
                      train_X,
                      train_y,
                      valid_X,
                      valid_y,
                      test_X,
                      test_y,
                      mask=mask))
    train_metrics, valid_metrics, test_metrics = zip(*metrics_bundles)
    valid_test_accs = zip(list(valid_metrics), list(test_metrics))
    valid_test_acc_curves(valid_test_accs)
    get_avg_metrics(train_metrics)
    get_avg_metrics(valid_metrics)
    get_avg_metrics(test_metrics)
def train_weighted_voting_repeatedly(train_X,
                                     train_y,
                                     valid_X,
                                     valid_y,
                                     test_X,
                                     test_y,
                                     threshold=0.5,
                                     masks_list=None):
    metrics_bundles = []
    for mask in masks_list:
        metrics_bundles.append(
            train_weighted_voting('f1score',
                                  train_X,
                                  train_y,
                                  valid_X,
                                  valid_y,
                                  test_X,
                                  test_y,
                                  mask=mask))
    train_metrics, valid_metrics, test_metrics = zip(*metrics_bundles)
    valid_test_accs = zip(list(valid_metrics), list(test_metrics))
    valid_test_acc_curves(valid_test_accs)
    get_avg_metrics(train_metrics)
    get_avg_metrics(valid_metrics)
    get_avg_metrics(test_metrics)
示例#3
0
def train_neural_net_repeatedly(train_X,
                                train_y,
                                valid_X,
                                valid_y,
                                test_X,
                                test_y,
                                iterations=100):
    metrics_bundles = []
    for i in range(iterations):
        metrics_bundles.append(
            train_neural_net(train_X, train_y, valid_X, valid_y, test_X,
                             test_y))

    train_metrics, valid_metrics, test_metrics = zip(*metrics_bundles)
    valid_test_accs = zip(list(valid_metrics), list(test_metrics))
    valid_test_acc_curves(valid_test_accs, "Artificial Neural Network")

    get_avg_metrics(train_metrics)
    get_avg_metrics(valid_metrics)
    get_avg_metrics(test_metrics)