Beispiel #1
0
    def test_predict(self):
        thresh_vals_list = self.threshold_list
        y_pred_ref_list = self.y_pred_ref
        x_data = self.x_data
        alphas = self.alphas

        for thresh_vals, y_ref_file in zip(thresh_vals_list, y_pred_ref_list):
            y_pred_ref = np.load(os.path.join(INPUT_DIR, y_ref_file))

            # Create a list of untrained classifiers to verify
            # predict operation.
            classifiers = [
                ps6.WeakClassifier([], [], [], thresh=t) for t in thresh_vals
            ]

            ytrain = np.zeros(
                (x_data.shape[0], ))  # Doesn't matter for this test
            numIte = 0  # Doesn't matter for this test

            test = ps6.Boosting(x_data, ytrain, numIte)

            # Modifying object variables for testing
            test.weakClassifiers = classifiers
            test.alphas = alphas

            y_pred = test.predict(x_data)

            correct = np.allclose(y_pred, y_pred_ref)
            message = "Predictions do not match reference predictions."
            self.assertTrue(correct, message)
Beispiel #2
0
    def test_evaluate(self):
        thresh_vals_list = self.threshold_list

        x_data = self.x_data
        alphas = self.alphas

        corr_inc_list = [(277, 283), (279, 281), (274, 286)]
        y_data = np.load(os.path.join(INPUT_DIR, "y_boosting_1.npy"))

        iter_lists = zip(thresh_vals_list, corr_inc_list)
        for thresh_vals, corr_inc in iter_lists:

            # Create a list of untrained classifiers to verify
            # predict operation.
            classifiers = [
                ps6.WeakClassifier([], [], [], thresh=t) for t in thresh_vals
            ]

            ytrain = np.zeros(
                (x_data.shape[0], ))  # Doesn't matter for this test
            numIte = 0  # Doesn't matter for this test

            test = ps6.Boosting(x_data, ytrain, numIte)

            # Modifying object variables for testing
            test.weakClassifiers = classifiers
            test.alphas = alphas
            test.Xtrain = x_data
            test.ytrain = y_data

            correct, incorrect = test.evaluate()

            correct_test = np.allclose(correct, corr_inc[0])
            message = "Correct values do not match the reference."
            self.assertTrue(correct_test, message)

            incorrect_test = np.allclose(incorrect, corr_inc[1])
            message = "Incorrect values do not match the reference."
            self.assertTrue(incorrect_test, message)
Beispiel #3
0
def part_2a():
    y0 = 1
    y1 = 2

    X, y = ps6.load_images(FACES94_DIR)
    
    # Select only the y0 and y1 classes
    idx = y == y0
    idx |= y == y1

    X = X[idx,:]
    y = y[idx]

    # Label them 1 and -1
    y0_ids = y == y0
    y1_ids = y == y1
    y[y0_ids] = 1
    y[y1_ids] = -1

    p = 0.8
    Xtrain, ytrain, Xtest, ytest = ps6.split_dataset(X, y, p)

    # Picking random numbers
    rand_y = np.random.choice([-1, 1], (len(ytrain)))
    # TODO: find which of these labels match ytrain and report its accuracy
    #rand_accuracy = None
    
    rand_accuracy = 100. * helper_func(rand_y, ytrain) / len(ytrain)  
    
    #raise NotImplementedError
    print '(Random) Training accuracy: {0:.2f}%'.format(rand_accuracy)

    # Using Weak Classifier
    uniform_weights = np.ones((Xtrain.shape[0],)) / Xtrain.shape[0]
    wk_clf = ps6.WeakClassifier(Xtrain, ytrain, uniform_weights)
    wk_clf.train()
    wk_results = [wk_clf.predict(x) for x in Xtrain]
    # TODO: find which of these labels match ytrain and report its accuracy
    wk_accuracy = None
    #raise NotImplementedError
  
    wk_accuracy = 100. * helper_func(wk_results, ytrain) / len(ytrain)
    
    print '(Weak) Training accuracy {0:.2f}%'.format(wk_accuracy)

    num_iter = 5

    boost = ps6.Boosting(Xtrain, ytrain, num_iter)
    boost.train()
    good, bad = boost.evaluate()
    boost_accuracy = 100 * float(good) / (good + bad)
    print '(Boosting) Training accuracy {0:.2f}%'.format(boost_accuracy)

    # Picking random numbers
    rand_y = np.random.choice([-1, 1], (len(ytest)))
    # TODO: find which of these labels match ytest and report its accuracy
    rand_accuracy = None
    #raise NotImplementedError

    rand_accuracy = 100. * helper_func(rand_y, ytest) / len(ytest)
    
    print '(Random) Testing accuracy: {0:.2f}%'.format(rand_accuracy)

    # Using Weak Classifier
    wk_results = [wk_clf.predict(x) for x in Xtest]
    # TODO: find which of these labels match ytest and report its accuracy
    wk_accuracy = None
    #raise NotImplementedError

    wk_accuracy = 100.* helper_func(wk_results, ytest) / len(ytest)
    
    print '(Weak) Testing accuracy {0:.2f}%'.format(wk_accuracy)

    y_pred = boost.predict(Xtest)
    # TODO: find which of these labels match ytest and report its accuracy
    boost_accuracy = None
    #raise NotImplementedError   

    boost_accuracy = 100. * helper_func(y_pred, ytest) / len(ytest)
    
    print '(Boosting) Testing accuracy {0:.2f}%'.format(boost_accuracy)
Beispiel #4
0
def part_2a():
    y0 = 1
    y1 = 2

    X, y = ps6.load_images(FACES94_DIR)

    # Select only the y0 and y1 classes
    idx = y == y0
    idx |= y == y1   


    X = X[idx,:]
    y = y[idx]

    
    # Label them 1 and -1
    y0_ids = y == y0
    y1_ids = y == y1
    y[y0_ids] = 1
    y[y1_ids] = -1



    p = 0.9
    Xtrain, ytrain, Xtest, ytest = ps6.split_dataset(X, y, p)

    # Picking random numbers
    rand_y = np.random.choice([-1, 1], (len(ytrain)))

    # TODO: find which of these labels match ytrain and report its accuracy

    good = 0
    bad = 0
    for i in range(0, len(ytrain)):
        if(ytrain[i] == rand_y[i]):
            good += 1

        else:
            bad += 1


    rand_accuracy = 100 * float(good) / (good + bad)

    print '(Random) Training accuracy: {0:.2f}%'.format(rand_accuracy)

    # Using Weak Classifier
    uniform_weights = np.ones((Xtrain.shape[0],)) / Xtrain.shape[0]
    wk_clf = ps6.WeakClassifier(Xtrain, ytrain, uniform_weights)
    wk_clf.train()
    wk_results = [wk_clf.predict(x) for x in Xtrain]
    # TODO: find which of these labels match ytrain and report its accuracy
    wk_accuracy = None

    good = 0
    bad = 0
    for i in range(0, len(ytrain)):
        if(ytrain[i] == wk_results[i]):
            good += 1

        else:
            bad += 1


    wk_accuracy = 100* float(good) / (good + bad)
    print '(Weak) Training accuracy {0:.2f}%'.format(wk_accuracy)

    num_iter = 2

    boost = ps6.Boosting(Xtrain, ytrain, num_iter)
    boost.train()
    good, bad = boost.evaluate()
    boost_accuracy = 100 * float(good) / (good + bad)
    print '(Boosting) Training accuracy {0:.2f}%'.format(boost_accuracy)

    # Picking random numbers
    rand_y = np.random.choice([-1, 1], (len(ytest)))
    # TODO: find which of these labels match ytest and report its accuracy
    rand_accuracy = None

    good = 0
    bad = 0
    for i in range(0, len(ytest)):
        if(ytest[i] == rand_y[i]):
            good += 1

        else:
            bad += 1


    rand_accuracy = 100 * float(good) / (good + bad)
    print '(Random) Testing accuracy: {0:.2f}%'.format(rand_accuracy)

    # Using Weak Classifier
    wk_results = [wk_clf.predict(x) for x in Xtest]
    # TODO: find which of these labels match ytest and report its accuracy
    wk_accuracy = None

    good = 0
    bad = 0
    for i in range(0, len(ytest)):
        if(ytest[i] == wk_results[i]):
            good += 1

        else:
            bad += 1

    wk_accuracy = 100* float(good) / (good + bad)
    print '(Weak) Testing accuracy {0:.2f}%'.format(wk_accuracy)

    y_pred = boost.predict(Xtest)
    # TODO: find which of these labels match ytest and report its accuracy
    boost_accuracy = None

    good = 0
    bad = 0

    for i in range(0, len(ytest)):
        if(ytest[i] == y_pred[i]):
            good += 1

        else:
            bad += 1
    
    boost_accuracy = 100* float(good) / (good + bad)
    print '(Boosting) Testing accuracy {0:.2f}%'.format(boost_accuracy)
def evaluate_faces_94(p):
    y0 = 1
    y1 = 2

    X, y = ps6.load_images(FACES94_DIR)

    # Select only the y0 and y1 classes
    idx = y == y0
    idx |= y == y1

    X = X[idx, :]
    y = y[idx]

    # Label them 1 and -1
    y0_ids = y == y0
    y1_ids = y == y1
    y[y0_ids] = 1
    y[y1_ids] = -1

    Xtrain, ytrain, Xtest, ytest = ps6.split_dataset(X, y, p)

    results = []

    # Picking random numbers
    rand_y = np.random.choice([-1, 1], (len(ytrain)))
    matching_indices = np.where(rand_y == ytrain)[0]
    rand_train_accuracy = matching_indices.shape[0] / ytrain.shape[0]
    # print('(Random) Training accuracy: {0:.2f}%'.format(rand_train_accuracy))

    # Using Weak Classifier
    uniform_weights = np.ones((Xtrain.shape[0], )) / Xtrain.shape[0]
    wk_clf = ps6.WeakClassifier(Xtrain, ytrain, uniform_weights)
    wk_clf.train()
    wk_results = [wk_clf.predict(x) for x in Xtrain]
    matching_indices = np.where(wk_results == ytrain)[0]
    wk__train_accuracy = matching_indices.shape[0] / ytrain.shape[0]
    results.append(wk__train_accuracy)
    # print('(Weak) Training accuracy {0:.2f}%'.format(wk__train_accuracy))

    num_iter = 4
    boost = ps6.Boosting(Xtrain, ytrain, num_iter)
    boost.train()
    good, bad = boost.evaluate()
    boost_train_accuracy = float(good) / (good + bad)
    results.append(boost_train_accuracy)
    # print('(Boosting) Training accuracy {0:.2f}%'.format(boost_train_accuracy))

    num_iter = 12
    boost_12 = ps6.Boosting(Xtrain, ytrain, num_iter)
    boost_12.train()
    good, bad = boost_12.evaluate()
    boost_train_accuracy_12 = float(good) / (good + bad)
    results.append(boost_train_accuracy_12)

    # Picking random numbers
    rand_y = np.random.choice([-1, 1], (len(ytest)))
    matching_indices = np.where(rand_y == ytest)[0]
    rand_test_accuracy = matching_indices.shape[0] / ytest.shape[0]
    # print('(Random) Testing accuracy: {0:.2f}%'.format(rand_test_accuracy))

    # Using Weak Classifier
    wk_results = [wk_clf.predict(x) for x in Xtest]
    matching_indices = np.where(wk_results == ytest)[0]
    wk_test_accuracy = matching_indices.shape[0] / ytest.shape[0]
    results.append(wk_test_accuracy)
    # print('(Weak) Testing accuracy {0:.2f}%'.format(wk_test_accuracy))

    y_pred = boost.predict(Xtest)
    matching_indices = np.where(y_pred == ytest)[0]
    boost_test_accuracy = matching_indices.shape[0] / ytest.shape[0]
    results.append(boost_test_accuracy)
    # print('(Boosting) Testing accuracy {0:.2f}%'.format(boost_test_accuracy))

    y_pred = boost_12.predict(Xtest)
    matching_indices = np.where(y_pred == ytest)[0]
    boost_test_accuracy_12 = matching_indices.shape[0] / ytest.shape[0]
    results.append(boost_test_accuracy_12)

    return results
def part_2a():
    y0 = 1
    y1 = 2

    X, y = ps6.load_images(FACES94_DIR)

    # Select only the y0 and y1 classes
    idx = y == y0
    idx |= y == y1

    X = X[idx, :]
    y = y[idx]

    # Label them 1 and -1
    y0_ids = y == y0
    y1_ids = y == y1
    y[y0_ids] = 1
    y[y1_ids] = -1

    p = 0.8
    Xtrain, ytrain, Xtest, ytest = ps6.split_dataset(X, y, p)

    # Picking random numbers
    rand_y = np.random.choice([-1, 1], (len(ytrain)))
    random_correctness = np.zeros_like(rand_y)
    random_correctness[rand_y == ytrain] = 1
    rand_accuracy = 100 * float(np.sum(random_correctness)) / (len(ytrain))
    print('(Random) Training accuracy: {0:.2f}%'.format(rand_accuracy))

    # Using Weak Classifier
    uniform_weights = np.ones((Xtrain.shape[0], )) / Xtrain.shape[0]
    wk_clf = ps6.WeakClassifier(Xtrain, ytrain, uniform_weights)
    wk_clf.train()
    wk_results = [wk_clf.predict(x) for x in Xtrain]
    wk_correctness = np.zeros_like(wk_results)
    wk_correctness[wk_results == ytrain] = 1
    wk_accuracy = 100 * float(np.sum(wk_correctness)) / (len(ytrain))

    print('(Weak) Training accuracy {0:.2f}%'.format(wk_accuracy))

    num_iter = 5

    boost = ps6.Boosting(Xtrain, ytrain, num_iter)
    boost.train()
    good, bad = boost.evaluate()
    boost_accuracy = 100 * float(good) / (good + bad)
    print('(Boosting) Training accuracy {0:.2f}%'.format(boost_accuracy))

    # Picking random numbers
    rand_y = np.random.choice([-1, 1], (len(ytest)))
    random_correctness = np.zeros_like(rand_y)
    random_correctness[rand_y == ytest] = 1
    rand_accuracy = 100 * float(np.sum(random_correctness)) / (len(ytest))
    print('(Random) Testing accuracy: {0:.2f}%'.format(rand_accuracy))

    # Using Weak Classifier
    wk_results = [wk_clf.predict(x) for x in Xtest]
    wk_correctness = np.zeros_like(wk_results)
    wk_correctness[wk_results == ytest] = 1
    wk_accuracy = 100 * float(np.sum(wk_correctness)) / (len(ytest))
    print('(Weak) Testing accuracy {0:.2f}%'.format(wk_accuracy))

    y_pred = boost.predict(Xtest)
    boost_correctness = np.zeros_like(y_pred)
    boost_correctness[y_pred == ytest] = 1
    boost_accuracy = 100 * float(np.sum(boost_correctness)) / (len(ytest))
    print('(Boosting) Testing accuracy {0:.2f}%'.format(boost_accuracy))
Beispiel #7
0
def part_2a(p = 0.8, num_iter = 5, seed = 1, verbose = True):
    
    y0 = 1
    y1 = 2

    X, y = ps6.load_images(FACES94_DIR)

    # Select only the y0 and y1 classes
    idx = y == y0
    idx |= y == y1

    X = X[idx.flatten(),:]
    y = y[idx]

    # Label them 1 and -1
    y0_ids = y == y0
    y1_ids = y == y1
    y[y0_ids] = 1
    y[y1_ids] = -1

    Xtrain, ytrain, Xtest, ytest = ps6.split_dataset(X, y, p, seed = seed)

    # Picking random numbers
    rand_y = np.random.choice([-1, 1], (len(ytrain)))
    # TODO: find which of these labels match ytrain and report its accuracy
    rand_accuracy =  100*sum(ytrain==rand_y)*1./ytrain.shape[0]
    # raise NotImplementedError
    if verbose:
        print '(Random) Training accuracy: {0:.2f}%'.format(rand_accuracy)

    # Using Weak Classifier
    uniform_weights = np.ones((Xtrain.shape[0],)) / Xtrain.shape[0]
    wk_clf = ps6.WeakClassifier(Xtrain, ytrain, uniform_weights)
    wk_clf.train()
    wk_results = [wk_clf.predict(x) for x in Xtrain]
    # TODO: find which of these labels match ytrain and report its accuracy
    wk_accuracy = 100*sum(ytrain==wk_results)*1./ytrain.shape[0]
    #raise NotImplementedError
    if verbose:
        print '(Weak) Training accuracy {0:.2f}%'.format(wk_accuracy)

    boost = ps6.Boosting(Xtrain, ytrain, num_iter)
    boost.train()
    good, bad = boost.evaluate()
    boost_accuracy = 100 * float(good) / (good + bad)
    if verbose:
        print '(Boosting) Training accuracy {0:.2f}%'.format(boost_accuracy)
    results = [p, num_iter, rand_accuracy, wk_accuracy, boost_accuracy ]

    # Picking random numbers
    rand_y = np.random.choice([-1, 1], (len(ytest)))
    # TODO: find which of these labels match ytest and report its accuracy
    rand_accuracy = 100*sum(ytest==rand_y)*1./ytest.shape[0]
    if verbose:
        print '(Random) Testing accuracy: {0:.2f}%'.format(rand_accuracy)

    # Using Weak Classifier
    wk_results = [wk_clf.predict(x) for x in Xtest]
    # TODO: find which of these labels match ytest and report its accuracy
    wk_accuracy = 100*sum(ytest==wk_results)*1./ytest.shape[0]
    if verbose:
        print '(Weak) Testing accuracy {0:.2f}%'.format(wk_accuracy)

    y_pred = boost.predict(Xtest)
    # TODO: find which of these labels match ytest and report its accuracy
    boost_accuracy = 100*sum(ytest==y_pred)*1./ytest.shape[0]
    if verbose:
        print '(Boosting) Testing accuracy {0:.2f}%'.format(boost_accuracy)
    results += [rand_accuracy, wk_accuracy, boost_accuracy ]
    return results
Beispiel #8
0
def part_2a():
    y0 = 1
    y1 = 2

    X, y = ps6.load_images(FACES94_DIR)

    # Select only the y0 and y1 classes
    idx = y == y0
    idx |= y == y1

    X = X[idx, :]
    y = y[idx]

    # Label them 1 and -1
    y0_ids = y == y0
    y1_ids = y == y1
    y[y0_ids] = 1
    y[y1_ids] = -1

    p = 0.8
    Xtrain, ytrain, Xtest, ytest = ps6.split_dataset(X, y, p)

    # Picking random numbers
    rand_y = np.random.choice([-1, 1], (len(ytrain)))
    matches = [rand_y[i] == ytrain[i] for i in range(0, len(rand_y))]
    corr = np.sum([int(x) for x in matches])
    rand_accuracy = float(corr) / float(len(ytrain)) * 100
    print '(Random) Training accuracy: {0:.2f}%'.format(rand_accuracy)

    # Using Weak Classifier
    uniform_weights = np.ones((Xtrain.shape[0], )) / Xtrain.shape[0]
    wk_clf = ps6.WeakClassifier(Xtrain, ytrain, uniform_weights)
    wk_clf.train()
    wk_results = [wk_clf.predict(x) for x in Xtrain]
    matches = [ytrain[i] == wk_results[i] for i in range(0, len(ytrain))]
    corr = np.sum([int(x) for x in matches])
    wk_accuracy = float(corr) / float(len(ytrain)) * 100
    print '(Weak) Training accuracy {0:.2f}%'.format(wk_accuracy)

    # num_iter = 5
    for i in range(5, 10):
        print i
        num_iter = i
        boost = ps6.Boosting(Xtrain, ytrain, num_iter)
        boost.train()
        good, bad = boost.evaluate()
        # print good, bad
        boost_accuracy = 100 * float(good) / (good + bad)
        print '(Boosting) Training accuracy {0:.2f}%'.format(boost_accuracy)

        y_pred = boost.predict(Xtest)
        matches = [y_pred[i] == ytest[i] for i in range(0, len(ytest))]
        corr = np.sum(np.array([int(x) for x in matches]))
        boost_accuracy = corr / float(len(ytest)) * 100
        print '(Boosting) Testing accuracy {0:.2f}%'.format(boost_accuracy)

    # Picking random numbers
    rand_y = np.random.choice([-1, 1], (len(ytest)))
    matches = [rand_y[i] == ytest[i] for i in range(0, len(ytest))]
    # print matches
    corr = np.sum(np.array([int(x) for x in matches]))
    rand_accuracy = corr / float(len(ytest)) * 100
    print '(Random) Testing accuracy: {0:.2f}%'.format(rand_accuracy)

    # Using Weak Classifier
    wk_results = [wk_clf.predict(x) for x in Xtest]
    matches = [ytest[i] == wk_results[i] for i in range(0, len(Xtest))]
    # print matches
    corr = np.sum(np.array([int(x) for x in matches]))
    # print corr
    wk_accuracy = corr / float(len(ytest)) * 100
    print '(Weak) Testing accuracy {0:.2f}%'.format(wk_accuracy)
Beispiel #9
0
def part_2a():
    y0 = 1
    y1 = 2

    X, y = ps6.load_images(FACES94_DIR)

    # Select only the y0 and y1 classes
    idx = y == y0
    idx |= y == y1

    X = X[idx, :]
    y = y[idx]

    # Label them 1 and -1
    y0_ids = y == y0
    y1_ids = y == y1
    y[y0_ids] = 1
    y[y1_ids] = -1

    p = 0.8
    Xtrain, ytrain, Xtest, ytest = ps6.split_dataset(X, y, p)

    # Picking random numbers
    rand_y = np.random.choice([-1, 1], (len(ytrain)))
    # the accuracy is the percent of correct answer. Loop over the lenght
    correct = 0
    for i in range(len(ytrain)):
        if rand_y[i] == ytrain[i]:
            correct += 1
    # convert to a %
    rand_accuracy = 100 * (float(correct) / float(len(ytrain)))
    print '(Random) Training accuracy: {0:.2f}%'.format(rand_accuracy)

    # Picking random numbers
    rand_y = np.random.choice([-1, 1], (len(ytest)))
    correct = 0
    for i in range(len(ytest)):
        if rand_y[i] == ytest[i]:
            correct += 1
    rand_accuracy = 100 * (float(correct) / float(len(ytest)))
    print '(Random) Testing accuracy: {0:.2f}%'.format(rand_accuracy)

    # Using Weak Classifier
    uniform_weights = np.ones((Xtrain.shape[0],)) / Xtrain.shape[0]
    wk_clf = ps6.WeakClassifier(Xtrain, ytrain, uniform_weights)
    wk_clf.train()
    wk_results = [wk_clf.predict(x) for x in Xtrain]
    correct = 0
    for i in range(len(ytrain)):
        if wk_results[i] == ytrain[i]:
            correct += 1
    # convert to a %
    wk_accuracy = 100 * (float(correct) / float(len(ytrain)))
    print '(Weak) Training accuracy {0:.2f}%'.format(wk_accuracy)

    # Using Weak Classifier
    wk_results = [wk_clf.predict(x) for x in Xtest]
    correct = 0
    for i in range(len(ytest)):
        if wk_results[i] == ytest[i]:
            correct += 1
    wk_accuracy = 100 * (float(correct) / float(len(ytest)))
    print '(Weak) Testing accuracy {0:.2f}%'.format(wk_accuracy)

    num_iter = 5
    # for num_iter in range(1, 11):
    boost = ps6.Boosting(Xtrain, ytrain, num_iter)
    boost.train()
    good, bad = boost.evaluate()
    boost_accuracy = 100 * float(good) / (good + bad)
    print '(Boosting) Training accuracy {0:.2f}%'.format(boost_accuracy)

    y_pred = boost.predict(Xtest)
    correct = 0
    for i in range(len(ytest)):
        if y_pred[i] == ytest[i]:
            correct += 1
    boost_accuracy = 100 * (float(correct) / float(len(ytest)))
    print '(Boosting) Testing accuracy {0:.2f}%'.format(boost_accuracy)
def part_2a():
    y0 = 1
    y1 = 2

    X, y = ps6.load_images(FACES94_DIR)

    # Select only the y0 and y1 classes
    idx = y == y0
    idx |= y == y1

    # print(np.shape(X))
    X = X[idx, :]
    y = y[idx]
    # print(np.shape(y))

    # Label them 1 and -1
    y0_ids = y == y0
    y1_ids = y == y1
    # print(np.shape(y))
    y[y0_ids] = 1
    y[y1_ids] = -1

    p = 0.1
    Xtrain, ytrain, Xtest, ytest = ps6.split_dataset(X, y, p)

    # Picking random numbers
    rand_y = np.random.choice([-1, 1], (len(ytrain)))
    # TODO: find which of these labels match ytrain and report its accuracy
    temp_y = np.zeros_like(rand_y)
    temp_y[rand_y == ytrain] = 1
    rand_accuracy = 100 * float(np.sum(temp_y)) / (len(ytrain))  #None
    # raise NotImplementedError
    print('(Random) Training accuracy: {0:.2f}%'.format(rand_accuracy))

    # Using Weak Classifier
    uniform_weights = np.ones((Xtrain.shape[0], )) / Xtrain.shape[0]
    wk_clf = ps6.WeakClassifier(Xtrain, ytrain, uniform_weights)
    wk_clf.train()
    wk_results = [wk_clf.predict(x) for x in Xtrain]
    temp_wk = np.zeros_like(wk_results)
    temp_wk[wk_results == ytrain] = 1
    # TODO: find which of these labels match ytrain and report its accuracy
    wk_accuracy = 100 * float(np.sum(temp_wk)) / (len(ytrain))  #None
    # raise NotImplementedError
    print('(Weak) Training accuracy {0:.2f}%'.format(wk_accuracy))

    num_iter = 20

    # print(np.shape(Xtrain))

    boost = ps6.Boosting(Xtrain, ytrain, num_iter)
    boost.train()
    good, bad = boost.evaluate()
    boost_accuracy = 100 * float(good) / (good + bad)
    print('(Boosting) Training accuracy {0:.2f}%'.format(boost_accuracy))

    # Picking random numbers
    rand_y = np.random.choice([-1, 1], (len(ytest)))
    # TODO: find which of these labels match ytest and report its accuracy
    temp_y = np.zeros_like(rand_y)
    temp_y[rand_y == ytest] = 1
    rand_accuracy = 100 * float(np.sum(temp_y)) / (len(ytest))
    # raise NotImplementedError
    print('(Random) Testing accuracy: {0:.2f}%'.format(rand_accuracy))

    # Using Weak Classifier
    wk_results = [wk_clf.predict(x) for x in Xtest]
    # TODO: find which of these labels match ytest and report its accuracy
    temp_wk = np.zeros_like(wk_results)
    temp_wk[wk_results == ytest] = 1
    wk_accuracy = 100 * float(np.sum(temp_wk)) / (len(ytest))
    # raise NotImplementedError
    print('(Weak) Testing accuracy {0:.2f}%'.format(wk_accuracy))

    y_pred = boost.predict(Xtest)
    # TODO: find which of these labels match ytest and report its accuracy
    temp_b = np.zeros_like(y_pred)
    temp_b[y_pred == ytest] = 1
    boost_accuracy = 100 * float(np.sum(temp_b)) / (len(ytest))
    # raise NotImplementedError
    print('(Boosting) Testing accuracy {0:.2f}%'.format(boost_accuracy))