Upload
nicola-fanizzi
View
214
Download
1
Tags:
Embed Size (px)
DESCRIPTION
The field of machine learning is concerned The field of machine learning is concerned with the question of how to construct with the question of how to construct computer programs that automatically computer programs that automatically improve with experience. improve with experience. (Tom Mitchell) (Tom Mitchell) L' L'apprendimento induttivo apprendimento induttivo scaturisce dalle scaturisce dalle osservazioni osservazioni
Citation preview
IntroduzioneIntroduzione
corso di:Apprendimento Automatico
modulo Amodulo ANicola Fanizzi
Dipartimento di InformaticaUniversità degli studi di Bari
aggiornamento: 18/11/08
Apprendimento automatico (mod. A) - N.FanizziApprendimento automatico (mod. A) - N.Fanizzi 22
DefinizioneDefinizione
The field of machine learning is concerned The field of machine learning is concerned with the question of how to construct with the question of how to construct computer programs that automatically computer programs that automatically improve with experience.improve with experience. (Tom Mitchell)(Tom Mitchell)
Capire come far apprendere le macchine Capire come far apprendere le macchine apre nuove possibilità d'apre nuove possibilità d'uso del calcolatoreuso del calcolatore, , nuovi livelli di competenza e adattabilitànuovi livelli di competenza e adattabilità
... analogamente ...... analogamente ...Capire a fondo gli algoritmi di apprendimento Capire a fondo gli algoritmi di apprendimento
automatico può portare ad una migliore automatico può portare ad una migliore comprensione delle (in)capacità umanecomprensione delle (in)capacità umane
Apprendimento automatico (mod. A) - N.FanizziApprendimento automatico (mod. A) - N.Fanizzi 33
Apprendimento InduttivoApprendimento Induttivo● Le percezioni Le percezioni
servono all'agente a prendere decisioni servono all'agente a prendere decisioni ma anche a migliorare la capacita futura ma anche a migliorare la capacita futura
● L'agente L'agente – osserva le proprie interazioni con il mondoosserva le proprie interazioni con il mondo– le sue decisionile sue decisioni– puo' memorizzarlepuo' memorizzarle
● L'L'apprendimento induttivoapprendimento induttivo scaturisce dalle scaturisce dalle osservazioniosservazioni
Apprendimento automatico (mod. A) - N.FanizziApprendimento automatico (mod. A) - N.Fanizzi 44
Progetto di Elementi di ApprendimentoProgetto di Elementi di Apprendimento
1) componenticomponenti dell'elemento di apprendimento dell'elemento di apprendimento che vanno appreseche vanno apprese
2) tipo di tipo di feedbackfeedback disponibile per disponibile per l'apprendimentol'apprendimento
3) tipo di tipo di rappresentazionerappresentazione utilizzata utilizzata
Apprendimento automatico (mod. A) - N.FanizziApprendimento automatico (mod. A) - N.Fanizzi 55
Componenti da ApprendereComponenti da Apprendere
1) meccanismo di meccanismo di associazioneassociazione tra stato corrente e tra stato corrente e azioniazioni
2) deduzionededuzione di proprietà dalle percezioni sullo di proprietà dalle percezioni sullo stato corrente stato corrente
3) informazioni sull'informazioni sull'evoluzioneevoluzione degli stati del degli stati del mondo e i risultati delle possibili azionimondo e i risultati delle possibili azioni
4) informazioni sull'informazioni sull'utilitàutilità dei vari stati del mondo dei vari stati del mondo5) informazioni sul informazioni sul valorevalore delle azioni delle azioni
(desiderabilità)(desiderabilità)6) obiettiviobiettivi: classi di stati che massimizzano : classi di stati che massimizzano
l'utilitàl'utilità
Apprendimento automatico (mod. A) - N.FanizziApprendimento automatico (mod. A) - N.Fanizzi 66
Feedback e Tipologie di ApprendimentoFeedback e Tipologie di Apprendimento
supervisionatosupervisionato– casi 1), 2), 3)casi 1), 2), 3)– si apprende una funzione si apprende una funzione – partendo da esempi di input e outputpartendo da esempi di input e output
non supervisionatonon supervisionato– riconoscere pattern o schemi nell'inputriconoscere pattern o schemi nell'input– senza indicazione specifica dei valori in uscitasenza indicazione specifica dei valori in uscita
per rinforzoper rinforzo– rinforzo = ricompensa (condizionamento)rinforzo = ricompensa (condizionamento)– imparare come “funziona” l'ambiente in cui l'agente imparare come “funziona” l'ambiente in cui l'agente
è immersoè immerso
Apprendimento automatico (mod. A) - N.FanizziApprendimento automatico (mod. A) - N.Fanizzi 77
RappresentazioneRappresentazione
LogicaLogica– proposizionale – ordine 0proposizionale – ordine 0– predicati – primo ordine predicati – primo ordine
Funzioni matematicheFunzioni matematiche– a valori realia valori reali
es. polinomies. polinomi– a valori discretia valori discreti
Apprendimento automatico (mod. A) - N.FanizziApprendimento automatico (mod. A) - N.Fanizzi 88
Conoscenza PregressaConoscenza Pregressa
background knowledgebackground knowledge● tabula rasa ?tabula rasa ?● presente anche nei neonatipresente anche nei neonatimostra (anche) come mostra (anche) come compilarecompilare la conoscenza la conoscenza
in modo da accelerare il processo decisionalein modo da accelerare il processo decisionale
Apprendimento automatico (mod. A) - N.FanizziApprendimento automatico (mod. A) - N.Fanizzi 99
Apprendimento InduttivoApprendimento Induttivo
Funzione sconosciuta Funzione sconosciuta ff da apprendere da apprendere● inputinput: :
coppie coppie (x,f(x))(x,f(x)) dette dette esempiesempi● outputoutput: :
funzione funzione hh (ipotesi) che approssima bene (ipotesi) che approssima bene ff
● bontà dell'ipotesi bontà dell'ipotesi hh: generalità: generalità– predice correttamente il comportamento della f predice correttamente il comportamento della f
sconosciuta anche per altri esempi futuri sconosciuta anche per altri esempi futuri ((problema dell'induzioneproblema dell'induzione))
Apprendimento automatico (mod. A) - N.FanizziApprendimento automatico (mod. A) - N.Fanizzi 1010
Spazio delle IpotesiSpazio delle Ipotesi● Ipotesi tratte da uno spazio H che dipende dalla Ipotesi tratte da uno spazio H che dipende dalla
rappresentazione scelta rappresentazione scelta ● ProblemaProblema: spesso ci sono : spesso ci sono moltemolte ipotesi che si ipotesi che si
comportano bene sugli esempi in inputcomportano bene sugli esempi in input(ipotesi (ipotesi consistenticonsistenti rispetto ai dati) rispetto ai dati)
● Criteri di sceltaCriteri di scelta– Rasoio di Occam (XIV sec.): Rasoio di Occam (XIV sec.):
preferire l'ipotesi più semplicepreferire l'ipotesi più semplice “ “entia non sunt multiplicanda prentia non sunt multiplicanda prææter necessitatem”ter necessitatem” ● ipotesi troppo complesse non estraggono pattern generali ipotesi troppo complesse non estraggono pattern generali
dai datidai dati
Apprendimento automatico (mod. A) - N.FanizziApprendimento automatico (mod. A) - N.Fanizzi 1111
Scelta della FunzioneScelta della Funzione● Rette (iperpiani)Rette (iperpiani)● PolinomiPolinomi● ax + b + c sin(x)ax + b + c sin(x)● ......
Apprendimento automatico (mod. A) - N.FanizziApprendimento automatico (mod. A) - N.Fanizzi 1212
Spazi delle IpotesiSpazi delle Ipotesi● Spazi molto estesi: Spazi molto estesi:
– H = {mdT} ?H = {mdT} ?
● Compromesso tra Compromesso tra espressivitàespressività dello spazio dello spazio
es. polinomi di grado n ?es. polinomi di grado n ?complessitàcomplessità della ricerca di ipotesi in tale spazio della ricerca di ipotesi in tale spazio
più facile cercare tra rette che tra polinomipiù facile cercare tra rette che tra polinomi
Apprendimento automatico (mod. A) - N.FanizziApprendimento automatico (mod. A) - N.Fanizzi 1313
Descrizioni StrutturaliDescrizioni Strutturali
● Esempio: regole if-then Esempio: regole if-then
…………………………
HardHardNormalNormalYesYesMyopeMyopePresbyopicPresbyopic
NoneNoneReducedReducedNoNoHypermetropeHypermetropePre-Pre-presbyopicpresbyopic
SoftSoftNormalNormalNoNoHypermetropeHypermetropeYoungYoung
NoneNoneReducedReducedNoNoMyopeMyopeYoungYoung
Recommended Recommended lenseslenses
Tear Tear production production
raterate
AstigmatismAstigmatismSpectacle Spectacle prescriptionprescription
AgeAge
If tear production rate = reducedIf tear production rate = reducedthen recommendation = nonethen recommendation = none
Otherwise, if age = young and astigmatic = no Otherwise, if age = young and astigmatic = no then recommendation = softthen recommendation = soft
Apprendimento automatico (mod. A) - N.FanizziApprendimento automatico (mod. A) - N.Fanizzi 1414
Le Macchine Possono Imparare Davvero ?Le Macchine Possono Imparare Davvero ?● Definizioni di Definizioni di “imparare” “imparare” tratte da un tratte da un
dizionario:dizionario:– Acquisire conoscenza dallo studio, dall'esperienza, o Acquisire conoscenza dallo studio, dall'esperienza, o
dall'insegnamentodall'insegnamento– Prendere conoscenza mediante informazione od Prendere conoscenza mediante informazione od
osservazioneosservazioneDifficili da misurareDifficili da misurare
– Mandare a memoriaMandare a memoriaEssere informato di qualcosa, accertare Essere informato di qualcosa, accertare Ricevere istruzioni su qualcosaRicevere istruzioni su qualcosa
Banale per i computerBanale per i computer
Apprendimento automatico (mod. A) - N.FanizziApprendimento automatico (mod. A) - N.Fanizzi 1515
Le Macchine Possono Imparare Davvero ?Le Macchine Possono Imparare Davvero ?● Definizione Operazionale:Definizione Operazionale:
Si impara quando si cambia il proprio comportamento in Si impara quando si cambia il proprio comportamento in modo da avere migliori prestazioni in futuromodo da avere migliori prestazioni in futuro
Può imparare una pantofola ?Può imparare una pantofola ?● Imparare implica inventiva ?Imparare implica inventiva ?
Apprendimento automatico (mod. A) - N.FanizziApprendimento automatico (mod. A) - N.Fanizzi 1616
Problema: Giocare a Tennis?Problema: Giocare a Tennis?● Condizioni per giocare ad un certo giocoCondizioni per giocare ad un certo gioco
…………………………
YesYesFalseFalseNormalNormalMildMildRainyRainy
YesYesFalseFalseHighHighHot Hot Overcast Overcast
NoNoTrueTrueHigh High Hot Hot SunnySunny
NoNoFalseFalseHighHighHotHotSunnySunny
PlayPlayWindyWindyHumidityHumidityTemperatureTemperatureOutlookOutlook
If outlook = sunny and humidity = high then play = noIf outlook = sunny and humidity = high then play = noIf outlook = rainy and windy = true then play = noIf outlook = rainy and windy = true then play = no
If outlook = overcast then play = yesIf outlook = overcast then play = yesIf humidity = normal then play = yesIf humidity = normal then play = yesIf none of the above then play = yesIf none of the above then play = yes
Apprendimento automatico (mod. A) - N.FanizziApprendimento automatico (mod. A) - N.Fanizzi 1717
Regole: Classificazione / AssociazioneRegole: Classificazione / Associazione● Regola di classificazione:Regola di classificazione:
– predice il valore di un dato attributo predice il valore di un dato attributo (la classificazione di un esempio)(la classificazione di un esempio)
● Regola di Associazione:Regola di Associazione:– predice il valore di attributi arbitrari predice il valore di attributi arbitrari
(o di una loro combinazione(o di una loro combinazione))
If outlook = sunny and humidity = highIf outlook = sunny and humidity = highthen play = nothen play = no
If temperature = cool then humidity = normalIf temperature = cool then humidity = normalIf humidity = normal and windy = falseIf humidity = normal and windy = false
then play = yesthen play = yesIf outlook = sunny and play = no If outlook = sunny and play = no
then humidity = highthen humidity = highIf windy = false and play = no If windy = false and play = no
then outlook = sunny and humidity = highthen outlook = sunny and humidity = high
Apprendimento automatico (mod. A) - N.FanizziApprendimento automatico (mod. A) - N.Fanizzi 1818
Es. Dati Meteo: Attributi di Tipo DiversoEs. Dati Meteo: Attributi di Tipo Diverso
● Alcuni attributi hanno valori numerici Alcuni attributi hanno valori numerici
…………………………
YesYesFalseFalse80807575RainyRainy
YesYesFalseFalse86868383Overcast Overcast
NoNoTrueTrue90908080SunnySunny
NoNoFalseFalse85858585SunnySunny
PlayPlayWindyWindyHumidityHumidityTemperatureTemperatureOutlookOutlook
If outlook = sunny and humidity > 83 then play = noIf outlook = sunny and humidity > 83 then play = noIf outlook = rainy and windy = true then play = noIf outlook = rainy and windy = true then play = noIf outlook = overcast then play = yesIf outlook = overcast then play = yesIf humidity < 85 then play = yesIf humidity < 85 then play = yesIf none of the above then play = yesIf none of the above then play = yes
Apprendimento automatico (mod. A) - N.FanizziApprendimento automatico (mod. A) - N.Fanizzi 1919
Problema: Scelta Lenti a ContattoProblema: Scelta Lenti a Contatto
NoneNoneReducedReducedYesYesHypermetropeHypermetropePre-presbyopic Pre-presbyopic NoneNoneNormalNormalYesYesHypermetropeHypermetropePre-presbyopicPre-presbyopicNoneNoneReducedReducedNoNoMyopeMyopePresbyopicPresbyopicNoneNoneNormalNormalNoNoMyopeMyopePresbyopicPresbyopicNoneNoneReducedReducedYesYesMyopeMyopePresbyopicPresbyopicHardHardNormalNormalYesYesMyopeMyopePresbyopicPresbyopicNoneNoneReducedReducedNoNoHypermetropeHypermetropePresbyopicPresbyopicSoftSoftNormalNormalNoNoHypermetropeHypermetropePresbyopicPresbyopicNoneNoneReducedReducedYesYesHypermetropeHypermetropePresbyopicPresbyopicNoneNoneNormalNormalYesYesHypermetropeHypermetropePresbyopicPresbyopic
SoftSoftNormalNormalNoNoHypermetropeHypermetropePre-presbyopicPre-presbyopicNoneNoneReducedReducedNoNoHypermetropeHypermetropePre-presbyopicPre-presbyopicHardHardNormalNormalYesYesMyopeMyopePre-presbyopicPre-presbyopicNoneNoneReducedReducedYesYesMyopeMyopePre-presbyopicPre-presbyopicSoftSoftNormalNormalNoNoMyopeMyopePre-presbyopicPre-presbyopicNoneNoneReducedReducedNoNoMyopeMyopePre-presbyopicPre-presbyopichardhardNormalNormalYesYesHypermetropeHypermetropeYoungYoungNoneNoneReducedReducedYesYesHypermetropeHypermetropeYoungYoungSoftSoftNormalNormalNoNoHypermetropeHypermetropeYoungYoungNoneNoneReducedReducedNoNoHypermetropeHypermetropeYoungYoungHardHardNormalNormalYesYesMyopeMyopeYoungYoungNoneNoneReducedReducedYesYesMyopeMyopeYoung Young SoftSoftNormalNormalNoNoMyopeMyopeYoungYoungNoneNoneReducedReducedNoNoMyopeMyopeYoungYoung
Recommended Recommended lenseslenses
Tear production Tear production raterate
AstigmatismAstigmatismSpectacle Spectacle prescriptionprescription
AgeAge
Apprendimento automatico (mod. A) - N.FanizziApprendimento automatico (mod. A) - N.Fanizzi 2020
Insieme di Regole Corretto e CompletoInsieme di Regole Corretto e CompletoIf tear production rate = reduced then recommendation = noneIf tear production rate = reduced then recommendation = none
If age = young and astigmatic = noIf age = young and astigmatic = noand tear production rate = normal then recommendation = softand tear production rate = normal then recommendation = soft
If age = pre-presbyopic and astigmatic = noIf age = pre-presbyopic and astigmatic = noand tear production rate = normal then recommendation = softand tear production rate = normal then recommendation = soft
If age = presbyopic and spectacle prescription = myopeIf age = presbyopic and spectacle prescription = myopeand astigmatic = no then recommendation = noneand astigmatic = no then recommendation = none
If spectacle prescription = hypermetrope and astigmatic = noIf spectacle prescription = hypermetrope and astigmatic = noand tear production rate = normal then recommendation = softand tear production rate = normal then recommendation = soft
If spectacle prescription = myope and astigmatic = yesIf spectacle prescription = myope and astigmatic = yesand tear production rate = normal then recommendation = hardand tear production rate = normal then recommendation = hard
If age young and astigmatic = yes If age young and astigmatic = yes and tear production rate = normal then recommendation = hardand tear production rate = normal then recommendation = hard
If age = pre-presbyopicIf age = pre-presbyopicand spectacle prescription = hypermetropeand spectacle prescription = hypermetropeand astigmatic = yes then recommendation = noneand astigmatic = yes then recommendation = none
If age = presbyopic and spectacle prescription = hypermetropeIf age = presbyopic and spectacle prescription = hypermetropeand astigmatic = yes then recommendation = noneand astigmatic = yes then recommendation = none
Apprendimento automatico (mod. A) - N.FanizziApprendimento automatico (mod. A) - N.Fanizzi 2121
Albero di DecisioneAlbero di Decisione
Apprendimento automatico (mod. A) - N.FanizziApprendimento automatico (mod. A) - N.Fanizzi 2222
● Esempi: 209 diverse configurazioni di PCEsempi: 209 diverse configurazioni di PC
● Funzione di Regressione LineareFunzione di Regressione Lineare
Predizione delle Prestazioni di una CPUPredizione delle Prestazioni di una CPU
00
00
3232
128128
CHMAXCHMAX
00
00
88
1616
CHMINCHMIN
ChannelsChannels PerformancePerformanceCache Cache (Kb)(Kb)
Main memory Main memory (Kb)(Kb)
Cycle Cycle time (ns)time (ns)
4545004000400010001000480480209209
6767323280008000512512480480208208
……
2692693232320003200080008000292922
1981982562566000600025625612512511
PRPPRPCACHCACHMMAXMMAXMMINMMINMYCTMYCT
PRP =PRP =-55.9 + 0.0489 MYCT + 0.0153 MMIN + 0.0056 MMAX-55.9 + 0.0489 MYCT + 0.0153 MMIN + 0.0056 MMAX+ 0.6410 CACH - 0.2700 CHMIN + 1.480 CHMAX+ 0.6410 CACH - 0.2700 CHMIN + 1.480 CHMAX
Apprendimento automatico (mod. A) - N.FanizziApprendimento automatico (mod. A) - N.Fanizzi 2323
Conoscenza sul DominioConoscenza sul Dominio
If leaf condition is normalIf leaf condition is normaland stem condition is abnormaland stem condition is abnormaland stem cankers is below soil lineand stem cankers is below soil lineand canker lesion color is brownand canker lesion color is brown
thenthendiagnosis is rhizoctonia root rotdiagnosis is rhizoctonia root rot
If leaf malformation is absentIf leaf malformation is absentand stem condition is abnormaland stem condition is abnormaland stem cankers is below soil lineand stem cankers is below soil lineand canker lesion color is brownand canker lesion color is brown
thenthendiagnosis is rhizoctonia root rotdiagnosis is rhizoctonia root rot
Ma in questo dominio, Ma in questo dominio, leaf conditionleaf condition normale implica normale implica leaf malformationleaf malformation assente !assente !
Apprendimento automatico (mod. A) - N.FanizziApprendimento automatico (mod. A) - N.Fanizzi 2424
RiferimentiRiferimenti● S.Russell & P.Norvig: S.Russell & P.Norvig:
Intelligenza Artificiale - Un approccio modernoIntelligenza Artificiale - Un approccio moderno,,vol.2 Pearson, 3^ ed. vol.2 Pearson, 3^ ed.
● I. Witten & E. Frank: I. Witten & E. Frank: Data Mining: Practical Machine Learning Tools Data Mining: Practical Machine Learning Tools and Techniquesand Techniques, , Morgan KaufmannMorgan Kaufmann