perceptrons - university of texas at · pdf fileall cs188 materials are available at .]...

35
CS 343: Artificial Intelligence Perceptrons Prof. Scott Niekum — The University of Texas at Austin [These slides based on those of Dan Klein and Pieter Abbeel for CS188 Intro to AI at UC Berkeley. All CS188 materials are available at http://ai.berkeley.edu.]

Upload: ngocong

Post on 16-Mar-2018

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Perceptrons - University of Texas at · PDF fileAll CS188 materials are available at .] Error-Driven Classification. ... Properties of Perceptrons ... Problems with the Perceptron

CS343:ArtificialIntelligencePerceptrons

Prof.ScottNiekum—TheUniversityofTexasatAustin[TheseslidesbasedonthoseofDanKleinandPieterAbbeelforCS188IntrotoAIatUCBerkeley.AllCS188materialsareavailableathttp://ai.berkeley.edu.]

Page 2: Perceptrons - University of Texas at · PDF fileAll CS188 materials are available at .] Error-Driven Classification. ... Properties of Perceptrons ... Problems with the Perceptron

Error-DrivenClassification

Page 3: Perceptrons - University of Texas at · PDF fileAll CS188 materials are available at .] Error-Driven Classification. ... Properties of Perceptrons ... Problems with the Perceptron

Errors,andWhattoDo

▪ ExamplesoferrorsDear GlobalSCAPE Customer,

GlobalSCAPE has partnered with ScanSoft to offer you the latest version of OmniPage Pro, for just $99.99* - the regular list price is $499! The most common question we've received about this offer is - Is this genuine? We would like to assure you that this offer is authorized by ScanSoft, is genuine and valid. You can get the . . .

. . . To receive your $30 Amazon.com promotional certificate, click through to

http://www.amazon.com/apparel

and see the prominent link for the $30 offer. All details are there. We hope you enjoyed receiving this message. However, if you'd rather not receive future e-mails announcing new store launches, please click . . .

Page 4: Perceptrons - University of Texas at · PDF fileAll CS188 materials are available at .] Error-Driven Classification. ... Properties of Perceptrons ... Problems with the Perceptron

WhattoDoAboutErrors

▪ Problem:there’sstillspaminyourinbox

▪ Needmorefeatures–wordsaren’tenough!▪ Haveyouemailedthesenderbefore?▪ Have1Motherpeoplejustgottenthesameemail?▪ Isthesendinginformationconsistent?▪ IstheemailinALLCAPS?▪ DoinlineURLspointwheretheysaytheypoint?▪ Doestheemailaddressyouby(your)name?

▪ NaïveBayesmodelscanincorporateavarietyoffeatures,buttendtodobestinhomogeneouscases(e.g.allfeaturesarewordoccurrences)

Page 5: Perceptrons - University of Texas at · PDF fileAll CS188 materials are available at .] Error-Driven Classification. ... Properties of Perceptrons ... Problems with the Perceptron

LinearClassifiers

Page 6: Perceptrons - University of Texas at · PDF fileAll CS188 materials are available at .] Error-Driven Classification. ... Properties of Perceptrons ... Problems with the Perceptron

FeatureVectors

Hello,

Do you want free printr cartriges? Why pay more when you can get them ABSOLUTELY FREE! Just

# free : 2 YOUR_NAME : 0 MISSPELLED : 2 FROM_FRIEND : 0 ...

SPAMor+

PIXEL-7,12 : 1 PIXEL-7,13 : 0 ... NUM_LOOPS : 1 ...

“2”

Page 7: Perceptrons - University of Texas at · PDF fileAll CS188 materials are available at .] Error-Driven Classification. ... Properties of Perceptrons ... Problems with the Perceptron

Some(Simplified)Biology

▪ Verylooseinspiration:humanneurons

Page 8: Perceptrons - University of Texas at · PDF fileAll CS188 materials are available at .] Error-Driven Classification. ... Properties of Perceptrons ... Problems with the Perceptron

LinearClassifiers

▪ Inputsarefeaturevalues▪ Eachfeaturehasaweight▪ Sumistheactivation

▪ Iftheactivationis:▪ Positive,output+1▪ Negative,output-1

Σf1f2f3

w1w2w3

>0?

Page 9: Perceptrons - University of Texas at · PDF fileAll CS188 materials are available at .] Error-Driven Classification. ... Properties of Perceptrons ... Problems with the Perceptron

Weights▪ Binarycase:comparefeaturestoaweightvector▪ Learning:figureouttheweightvectorfromexamples

# free : 2 YOUR_NAME : 0 MISSPELLED : 2 FROM_FRIEND : 0 ...

# free : 4 YOUR_NAME :-1 MISSPELLED : 1 FROM_FRIEND :-3 ...

# free : 0 YOUR_NAME : 1 MISSPELLED : 1 FROM_FRIEND : 1 ...

Dot product positive means the positive class

Page 10: Perceptrons - University of Texas at · PDF fileAll CS188 materials are available at .] Error-Driven Classification. ... Properties of Perceptrons ... Problems with the Perceptron

DecisionRules

Page 11: Perceptrons - University of Texas at · PDF fileAll CS188 materials are available at .] Error-Driven Classification. ... Properties of Perceptrons ... Problems with the Perceptron

BinaryDecisionRule

▪ Inthespaceoffeaturevectors▪ Examplesarepoints▪ Anyweightvectorisahyperplane▪ OnesidecorrespondstoY=+1▪ OthercorrespondstoY=-1

BIAS : -3 free : 4 money : 2 ...

0 10

1

2

freemon

ey

+1=SPAM

-1=HAM

Page 12: Perceptrons - University of Texas at · PDF fileAll CS188 materials are available at .] Error-Driven Classification. ... Properties of Perceptrons ... Problems with the Perceptron

WeightUpdates

Page 13: Perceptrons - University of Texas at · PDF fileAll CS188 materials are available at .] Error-Driven Classification. ... Properties of Perceptrons ... Problems with the Perceptron

Learning:BinaryPerceptron

▪ Startwithweights=0▪ Foreachtraininginstance:

▪ Classifywithcurrentweights

▪ Ifcorrect(i.e.,y=y*),nochange!

▪ Ifwrong:adjusttheweightvector

Page 14: Perceptrons - University of Texas at · PDF fileAll CS188 materials are available at .] Error-Driven Classification. ... Properties of Perceptrons ... Problems with the Perceptron

Learning:BinaryPerceptron

▪ Startwithweights=0▪ Foreachtraininginstance:▪ Classifywithcurrentweights

▪ Ifcorrect(i.e.,y=y*),nochange!▪ Ifwrong:adjusttheweightvectorbyaddingorsubtractingthefeaturevector.Subtractify*is-1.

Page 15: Perceptrons - University of Texas at · PDF fileAll CS188 materials are available at .] Error-Driven Classification. ... Properties of Perceptrons ... Problems with the Perceptron

Examples:Perceptron

▪ SeparableCase

Page 16: Perceptrons - University of Texas at · PDF fileAll CS188 materials are available at .] Error-Driven Classification. ... Properties of Perceptrons ... Problems with the Perceptron

MulticlassDecisionRule

▪ Ifwehavemultipleclasses:▪ Aweightvectorforeachclass:

▪ Score(activation)ofaclassy:

▪ Predictionhighestscorewins

Binary=multiclasswherethenegativeclasshasweightzero

Page 17: Perceptrons - University of Texas at · PDF fileAll CS188 materials are available at .] Error-Driven Classification. ... Properties of Perceptrons ... Problems with the Perceptron

Learning:MulticlassPerceptron

▪ Startwithallweights=0▪ Pickuptrainingexamplesonebyone▪ Predictwithcurrentweights

▪ Ifcorrect,nochange!▪ Ifwrong:lowerscoreofwronganswer,

raisescoreofrightanswer

Page 18: Perceptrons - University of Texas at · PDF fileAll CS188 materials are available at .] Error-Driven Classification. ... Properties of Perceptrons ... Problems with the Perceptron

Example:MulticlassPerceptron

BIAS : 1 win : 0 game : 0 vote : 0 the : 0 ...

BIAS : 0 win : 0 game : 0 vote : 0 the : 0 ...

BIAS : 0 win : 0 game : 0 vote : 0 the : 0 ...

“winthevote”

Page 19: Perceptrons - University of Texas at · PDF fileAll CS188 materials are available at .] Error-Driven Classification. ... Properties of Perceptrons ... Problems with the Perceptron

PropertiesofPerceptrons

▪ Separability:trueifsomeparametersgetthetrainingsetperfectlycorrect

▪ Convergence:ifthetrainingisseparable,perceptronwilleventuallyconverge(binarycase)

▪ MistakeBound:themaximumnumberofmistakes(binarycase)relatedtothemarginordegreeofseparability

Separable

Non-Separable

Page 20: Perceptrons - University of Texas at · PDF fileAll CS188 materials are available at .] Error-Driven Classification. ... Properties of Perceptrons ... Problems with the Perceptron

Examples:Perceptron

▪ Non-SeparableCase

Page 21: Perceptrons - University of Texas at · PDF fileAll CS188 materials are available at .] Error-Driven Classification. ... Properties of Perceptrons ... Problems with the Perceptron

ImprovingthePerceptron

Page 22: Perceptrons - University of Texas at · PDF fileAll CS188 materials are available at .] Error-Driven Classification. ... Properties of Perceptrons ... Problems with the Perceptron

ProblemswiththePerceptron

▪ Noise:ifthedataisn’tseparable,weightsmightthrash▪ Averagingweightvectorsovertimecan

help(averagedperceptron)

▪ Mediocregeneralization:findsa“barely”separatingsolution

▪ Overtraining:test/held-outaccuracyusuallyrises,thenfalls▪ Overtrainingisakindofoverfitting

Page 23: Perceptrons - University of Texas at · PDF fileAll CS188 materials are available at .] Error-Driven Classification. ... Properties of Perceptrons ... Problems with the Perceptron

FixingthePerceptron

▪ Idea:adjusttheweightupdatetomitigatetheseeffects

▪ MIRA*:chooseanupdatesizethatfixesthecurrentmistake…▪ …but,minimizesthechangetow

▪ The+1helpstogeneralize

*MarginInfusedRelaxedAlgorithm

Page 24: Perceptrons - University of Texas at · PDF fileAll CS188 materials are available at .] Error-Driven Classification. ... Properties of Perceptrons ... Problems with the Perceptron

MinimumCorrectingUpdate

minnotτ=0,orwouldnothavemadeanerror,sominwillbewhereequalityholds

Page 25: Perceptrons - University of Texas at · PDF fileAll CS188 materials are available at .] Error-Driven Classification. ... Properties of Perceptrons ... Problems with the Perceptron

MaximumStepSize

▪ Inpractice,it’salsobadtomakeupdatesthataretoolarge▪ Examplemaybelabeledincorrectly▪ Youmaynothaveenoughfeatures▪ Solution:capthemaximumpossiblevalueofτ withsomeconstant

C

▪ Correspondstoanoptimizationthatassumesnon-separabledata▪ Usuallyconvergesfasterthanperceptron▪ Usuallybetter,especiallyonnoisydata

Page 26: Perceptrons - University of Texas at · PDF fileAll CS188 materials are available at .] Error-Driven Classification. ... Properties of Perceptrons ... Problems with the Perceptron

LinearSeparators

▪ Whichoftheselinearseparatorsisoptimal?

Page 27: Perceptrons - University of Texas at · PDF fileAll CS188 materials are available at .] Error-Driven Classification. ... Properties of Perceptrons ... Problems with the Perceptron

SupportVectorMachines

▪ Maximizingthemargin:goodaccordingtointuition,theory,practice▪ Onlysupportvectorsmatter;othertrainingexamplesareignorable▪ Supportvectormachines(SVMs)findtheseparatorwithmaxmargin▪ Basically,SVMsareMIRAwhereyouoptimizeoverallexamplesatonce

MIRA

SVM

Page 28: Perceptrons - University of Texas at · PDF fileAll CS188 materials are available at .] Error-Driven Classification. ... Properties of Perceptrons ... Problems with the Perceptron

Classification:Comparison

▪ NaïveBayes▪ Buildsamodeltrainingdata▪ Givespredictionprobabilities▪ Strongassumptionsaboutfeatureindependence▪ Onepassthroughdata(counting)

▪ Perceptrons/MIRA:▪ Makeslessassumptionsaboutdata▪ Mistake-drivenlearning▪ Multiplepassesthroughdata(prediction)▪ Oftenmoreaccurate

Page 29: Perceptrons - University of Texas at · PDF fileAll CS188 materials are available at .] Error-Driven Classification. ... Properties of Perceptrons ... Problems with the Perceptron

Apprenticeship

Page 30: Perceptrons - University of Texas at · PDF fileAll CS188 materials are available at .] Error-Driven Classification. ... Properties of Perceptrons ... Problems with the Perceptron

PacmanApprenticeship!

▪ Examplesarestatess

▪ Candidatesarepairs(s,a)▪ “Correct”actions:thosetakenbyexpert▪ Featuresdefinedover(s,a)pairs:f(s,a)▪ Scoreofaq-state(s,a)givenby:

▪ HowisthisVERYdifferentfromreinforcementlearning?

“correct”actiona*

Page 31: Perceptrons - University of Texas at · PDF fileAll CS188 materials are available at .] Error-Driven Classification. ... Properties of Perceptrons ... Problems with the Perceptron

VideoofPacmanApprentice

Page 32: Perceptrons - University of Texas at · PDF fileAll CS188 materials are available at .] Error-Driven Classification. ... Properties of Perceptrons ... Problems with the Perceptron

WebSearch

Page 33: Perceptrons - University of Texas at · PDF fileAll CS188 materials are available at .] Error-Driven Classification. ... Properties of Perceptrons ... Problems with the Perceptron

Extension:WebSearch

▪ Informationretrieval:▪ Giveninformationneeds,produceinformation▪ Includes,e.g.websearch,questionanswering,andclassicIR

▪ Websearch:notexactlyclassification,butratherranking

x=“AppleComputers”

Page 34: Perceptrons - University of Texas at · PDF fileAll CS188 materials are available at .] Error-Driven Classification. ... Properties of Perceptrons ... Problems with the Perceptron

Feature-BasedRanking

x=“AppleComputer”

x,

x,

Page 35: Perceptrons - University of Texas at · PDF fileAll CS188 materials are available at .] Error-Driven Classification. ... Properties of Perceptrons ... Problems with the Perceptron

PerceptronforRanking

▪ Inputs▪ Candidates▪ Manyfeaturevectors:▪ Oneweightvector:▪ Prediction:

▪ Update(ifwrong):