Exemplo n.º 1
0
def plot_toy_results(algo_name, thetas):
    try:
    	utils.plot_toy_data(algo_name, toy_features, toy_labels, thetas)
    except  Exception, e:
    	print 'Error in utils.plot_toy_data function'
    	type, value, tb = sys.exc_info()
        traceback.print_exc()
        pdb.post_mortem(tb)
Exemplo n.º 2
0
def plot_toy_results(algo_name, thetas):
    utils.plot_toy_data(algo_name, toy_features, toy_labels, thetas)
def plot_toy_results(algo_name, thetas):
    print('theta for', algo_name, 'is', ', '.join(map(str, list(thetas[0]))))
    print('theta_0 for', algo_name, 'is', str(thetas[1]))
    utils.plot_toy_data(algo_name, toy_features, toy_labels, thetas)
Exemplo n.º 4
0
def plot_toy_results(algo_name, thetas):
    utils.plot_toy_data(algo_name, toy_features, toy_labels, thetas)
Exemplo n.º 5
0
import project1 as p1
from project1 import perceptron, average_perceptron, pegasos
import utils
import numpy as np
import numpy.testing as npt
import re

toy_features, toy_labels = toy_data = utils.load_toy_data('toy_data.tsv')
T = 10
L = 0.2

thetas = perceptron(toy_features, toy_labels, T)
print(thetas)
utils.plot_toy_data("Perceptron", toy_features, toy_labels, thetas)

thetas = average_perceptron(toy_features, toy_labels, T)
print(thetas)
utils.plot_toy_data("Average Perceptron", toy_features, toy_labels, thetas)

thetas = pegasos(toy_features, toy_labels, T, L)
print(thetas)
utils.plot_toy_data("Pegasos", toy_features, toy_labels, thetas)
Exemplo n.º 6
0
"""
Comparison between convergence of perceptron, average perceptron,
and pegasos linear classifiers on a toy dataset
Created on Mon Sep  7 17:43:05 2020
@author: mohamad jalalimanesh
"""
import matplotlib.pyplot as plt
import matplotlib.animation as animation
import numpy as np
from utils import create_toy_data, plot_toy_data
from perceptron import perceptron
from averaged_perceptron import average_perceptron
from pegasos import pegasos

features, labels = create_toy_data(350)
fig, ax = plot_toy_data(features, labels)

xmin, xmax = plt.axis()[:2]
x = np.linspace(xmin, xmax)

lines = []
plotlabels = ['perceptron', 'average perceptron', 'pegasos']
plotcols = ["black", "m", "g"]

for index in range(3):
    lobj, = ax.plot(x, np.zeros(x.shape), lw=3, color=plotcols[index], \
                    label=plotlabels[index])
    lines.append(lobj)
    ax.set_title('epoch = {}'.format(str(0)))
    ax.legend(loc='upper right')