########## #For linear import linear h = linear.LinearClassifier({'lossFunction': linear.SquaredLoss(), 'lambda': 0, 'numIter': 100, 'stepSize': 0.5}) runClassifier.trainTestSet(h, datasets.TwoDAxisAligned) X = datasets.TwoDAxisAligned.X Y = datasets.TwoDAxisAligned.Y #mlGraphics.plotLinearClassifier(h, X, Y) h = linear.LinearClassifier({'lossFunction': linear.SquaredLoss(), 'lambda': 10, 'numIter': 100, 'stepSize': 0.5}) runClassifier.trainTestSet(h, datasets.TwoDAxisAligned) h = linear.LinearClassifier({'lossFunction': linear.SquaredLoss(), 'lambda': 10, 'numIter': 100, 'stepSize': 0.5}) runClassifier.trainTestSet(h, datasets.TwoDDiagonal) h = linear.LinearClassifier({'lossFunction': linear.HingeLoss(), 'lambda': 1, 'numIter': 100, 'stepSize': 0.5}) runClassifier.trainTestSet(h, datasets.TwoDDiagonal) log = linear.LinearClassifier({'lossFunction': linear.LogisticLoss(), 'lambda': 1, 'numIter': 100, 'stepSize': 0.5}) runClassifier.trainTestSet(log, datasets.TwoDDiagonal)
import runClassifier import linear import datasets import mlGraphics from matplotlib.pyplot import show f = linear.LinearClassifier({ 'lossFunction': linear.HingeLoss(), 'lambda': 1, 'numIter': 1000, 'stepSize': 0.5 }) runClassifier.trainTestSet(f, datasets.WineDataBinary) # print(f) print(datasets.WineDataBinary.Yte.reshape(-1, 1))