예제 #1
0
##########

#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)
        

        
예제 #2
0
파일: linearTest.py 프로젝트: guomk/CMSC422
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))