Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Introduzione ai Big Data e alla scienza dei dati - Machine Learning

1,762 views

Published on

Lezione 3 del corso di analisi dati tenuto al Palazzolo Digital Hub (Palazzolo sull'Oglio, Brescia) nel 2014. In questa terza lezione si introducono alcuni algoritmi di machine learning.

Published in: Data & Analytics
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download Full EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download Full doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THIS can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THIS is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THIS Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THIS the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THIS Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download Full EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download Full doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THIS can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THIS is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THIS Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THIS the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THIS Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download Full EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download Full doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THIS can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THIS is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THIS Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THIS the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THIS Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download Full EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download Full doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THIS can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THIS is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THIS Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THIS the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THIS Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (2019 Update) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download Full EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download Full doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download PDF EBOOK here { https://soo.gd/irt2 } ......................................................................................................................... Download EPUB Ebook here { https://soo.gd/irt2 } ......................................................................................................................... Download doc Ebook here { https://soo.gd/irt2 } ......................................................................................................................... ......................................................................................................................... ................................................................................................................................... eBook is an electronic version of a traditional print book THIS can be read by using a personal computer or by using an eBook reader. (An eBook reader can be a software application for use on a computer such as Microsoft's free Reader application, or a book-sized computer THIS is used solely as a reading device such as Nuvomedia's Rocket eBook.) Users can purchase an eBook on diskette or CD, but the most popular method of getting an eBook is to purchase a downloadable file of the eBook (or other reading material) from a Web site (such as Barnes and Noble) to be read from the user's computer or reading device. Generally, an eBook can be downloaded in five minutes or less ......................................................................................................................... .............. Browse by Genre Available eBooks .............................................................................................................................. Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, ......................................................................................................................... ......................................................................................................................... .....BEST SELLER FOR EBOOK RECOMMEND............................................................. ......................................................................................................................... Blowout: Corrupted Democracy, Rogue State Russia, and the Richest, Most Destructive Industry on Earth,-- The Ride of a Lifetime: Lessons Learned from 15 Years as CEO of the Walt Disney Company,-- Call Sign Chaos: Learning to Lead,-- StrengthsFinder 2.0,-- Stillness Is the Key,-- She Said: Breaking the Sexual Harassment Story THIS Helped Ignite a Movement,-- Atomic Habits: An Easy & Proven Way to Build Good Habits & Break Bad Ones,-- Everything Is Figureoutable,-- What It Takes: Lessons in the Pursuit of Excellence,-- Rich Dad Poor Dad: What the Rich Teach Their Kids About Money THIS the Poor and Middle Class Do Not!,-- The Total Money Makeover: Classic Edition: A Proven Plan for Financial Fitness,-- Shut Up and Listen!: Hard Business Truths THIS Will Help You Succeed, ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

Introduzione ai Big Data e alla scienza dei dati - Machine Learning

  1. 1. INTRODUZIONE AI BIG DATA E ALLA SCIENZA DEI DATI Vincenzo Manzoni vincenzomanzoni.com | me@vincenzomanzoni.com Lezione 3 Machine Learning; Regressione; Classificazione supervisionata e non supervisionata (clustering); Sistemi di raccomandazione.
  2. 2. Introduzione ai Big Data e alla scienza dei dati, Palazzolo Digital Hub, 2014. Copyright: Vincenzo Manzoni ESERCIZIO 2.3 CONSEGNA • Il dataset Orange (per informazioni, ?Orange) contiene la misura della circonferenza di 5 alberi di arancia nel tempo. Verificare graficamente se esiste una relazione tra età in giorni e circonferenza. • Il dataset movies (per informazioni, ?movies) contiene informazioni sui film. • Individuare in che anno è stato girato il primo film in catalogo. • Qual è la media di durata. • Visualizzare il numero di film per anno. 2
  3. 3. Introduzione ai Big Data e alla scienza dei dati, Palazzolo Digital Hub, 2014. Copyright: Vincenzo Manzoni ESERCIZIO 2.3 SOLUZIONE 3 library(ggplot2)   ! qplot(x=age,  y=circumference,  data=Orange)   qplot(x=age,  y=circumference,  data=Orange,  geom=c("point",  "smooth"),  
            method="lm")   ! #  Anno  del  primo  film   min(movies$year)   ! #  Durata  media   mean(movies$length)   ! #  Numero  di  film  per  anno   qplot(x=year,  data=movies)
  4. 4. Introduzione ai Big Data e alla scienza dei dati, Palazzolo Digital Hub, 2014. Copyright: Vincenzo Manzoni MACHINE LEARNING 4
  5. 5. Introduzione ai Big Data e alla scienza dei dati, Palazzolo Digital Hub, 2014. Copyright: Vincenzo Manzoni WORKFLOW 5 Dati grezzi (raw) Processing Dataset Modelli statistici (Analisi) Machine Learning (Previsione) Data driven products Report, visualizzazioni, post su blog Acquisizione Elaborazione Output
  6. 6. Introduzione ai Big Data e alla scienza dei dati, Palazzolo Digital Hub, 2014. Copyright: Vincenzo Manzoni MACHINE LEARNING DEFINIZIONE 6 • In italiano, apprendimento automatico • Area dell’Intelligenza Artificiale (AI, Artificial Intelligence) che studia gli algoritmi che permettono alle macchine di apprendere. • Gli algoritmi si basano su osservazioni - dati - per fare la sintesi della conoscenza.
  7. 7. Introduzione ai Big Data e alla scienza dei dati, Palazzolo Digital Hub, 2014. Copyright: Vincenzo Manzoni MACHINE LEARNING PROCESSO DI ADDESTRAMENTO 7 Creazione degli insieme di addestramento e di test Dataset Insieme di addestramento Insieme di test Creazione del modello Validazione del modello Modello validato Modello
  8. 8. Introduzione ai Big Data e alla scienza dei dati, Palazzolo Digital Hub, 2014. Copyright: Vincenzo Manzoni MACHINE LEARNING PRINCIPALITIPOLOGIE DI ALGORITMI 8 • Apprendimento supervisionato • Apprendimento non supervisionato
  9. 9. Introduzione ai Big Data e alla scienza dei dati, Palazzolo Digital Hub, 2014. Copyright: Vincenzo Manzoni MACHINE LEARNING APPRENDIMENTO SUPERVISIONATO 9
  10. 10. Introduzione ai Big Data e alla scienza dei dati, Palazzolo Digital Hub, 2014. Copyright: Vincenzo Manzoni APPRENDIMENTO SUPERVISIONATO CLASSE DISCRETA 10 x1 x2 ? A priori ho informazioni sulla classe (grigia o arancione) a cui appartengono le osservazioni. A quale classe appartiene un nuovo punto, mai osservato, di cui non conosco a priori la classe? Problema di classificazione
  11. 11. Introduzione ai Big Data e alla scienza dei dati, Palazzolo Digital Hub, 2014. Copyright: Vincenzo Manzoni APPRENDIMENTO SUPERVISIONATO CLASSE DISCRETA 11 x1 x2 Con un primo separatore, la nuova istanza viene attribuita alla classe arancione.
  12. 12. Introduzione ai Big Data e alla scienza dei dati, Palazzolo Digital Hub, 2014. Copyright: Vincenzo Manzoni APPRENDIMENTO SUPERVISIONATO CLASSE DISCRETA 12 x1 x2 Con un secondo separatore, la nuova istanza viene attribuita alla classe grigia. Esiste un separatore ottimo?
  13. 13. Introduzione ai Big Data e alla scienza dei dati, Palazzolo Digital Hub, 2014. Copyright: Vincenzo Manzoni APPRENDIMENTO SUPERVISIONATO CLASSE DISCRETA 13 x1 x2 Gli algoritmi di apprendimento supervisionato permettono, dato un insieme di addestramento (training) di determinare il separatore ottimo secondo una certa funzione di costo. Separatore ottimo secondo una certa funzione di costo
  14. 14. Introduzione ai Big Data e alla scienza dei dati, Palazzolo Digital Hub, 2014. Copyright: Vincenzo Manzoni APPRENDIMENTO SUPERVISIONATO CLASSE CONTINUA 14 Per un certo numero di punti, conosco la relazione che c’è tra la variabile indipendente x e la variabile dipendente y. Quanto vale la y di un punto, di cui conosco solo la x? Problema di regressione x y x1 ?
  15. 15. Introduzione ai Big Data e alla scienza dei dati, Palazzolo Digital Hub, 2014. Copyright: Vincenzo Manzoni APPRENDIMENTO SUPERVISIONATO CLASSE CONTINUA 15 Gli algoritmi di regressione permettono, dato un insieme di addestramento, di determinare un modello dei dati (generalizzazione) con cui predire il valore della variabile dipendente associata a una nuova variabile indipendente. x y x1 y1
  16. 16. Introduzione ai Big Data e alla scienza dei dati, Palazzolo Digital Hub, 2014. Copyright: Vincenzo Manzoni APPRENDIMENTO SUPERVISIONATO DEFINIZIONI E ALGORITMI 16 • L’insieme di addestramento è costituito da esempi di cui si conoscono gli input e gli output. • Durante la fase di addestramento, l’algoritmo impara ad associare agli input agli output, generalizzando la regola che li lega. • Quando l’algoritmo vede un esempio di input che non ha mai visto, restituisce l’output più probabile. • Algoritmi • Regressione lineare ai minimi quadrati • Alberi di decisione • k-NN (k-Nearest Neighbors)
  17. 17. Introduzione ai Big Data e alla scienza dei dati, Palazzolo Digital Hub, 2014. Copyright: Vincenzo Manzoni MACHINE LEARNING APPRENDIMENTO NON SUPERVISIONATO 17
  18. 18. Introduzione ai Big Data e alla scienza dei dati, Palazzolo Digital Hub, 2014. Copyright: Vincenzo Manzoni APPRENDIMENTO NON SUPERVISIONATO 18 x1 x2 A priori, non ho informazioni sulla classe a cui appartengono le mie osservazioni.
  19. 19. Introduzione ai Big Data e alla scienza dei dati, Palazzolo Digital Hub, 2014. Copyright: Vincenzo Manzoni APPRENDIMENTO NON SUPERVISIONATO 19 Anche in questo caso, si possono raggruppare i punti secondo criteri diversi. x1 x2 x1 x2 Esiste un raggruppamento ottimo?
  20. 20. Introduzione ai Big Data e alla scienza dei dati, Palazzolo Digital Hub, 2014. Copyright: Vincenzo Manzoni APPRENDIMENTO NON SUPERVISIONATO DEFINIZIONI E ALGORITMI 20 • Trovare struttura nascoste in dati non pre-classificati. • Determina gruppi di dati. • Possono essere gerarchici o piatti (flat) • Algoritmi • k-means
  21. 21. Introduzione ai Big Data e alla scienza dei dati, Palazzolo Digital Hub, 2014. Copyright: Vincenzo Manzoni APPRENDIMENTO AUTOMATICO VISIONE D’INSIEME 21 Apprendimento Supervisionato Non supervisionato Uscita da stimare Continua Regressione lineare k-NN Discreta k-NN Alberi di decisione k-means
  22. 22. Introduzione ai Big Data e alla scienza dei dati, Palazzolo Digital Hub, 2014. Copyright: Vincenzo Manzoni APPRENDIMENTO SUPERVISIONATO REGRESSIONE LINEARE 22
  23. 23. Introduzione ai Big Data e alla scienza dei dati, Palazzolo Digital Hub, 2014. Copyright: Vincenzo Manzoni UN NUOVO DATASET: IRIS 23 install.packages('GGally',  dependencies=TRUE)
 library(GGally)
 ggpairs(data=iris,  colour='Species') str(iris)
 'data.frame':   150  obs.  of    5  variables:    $  Sepal.Length:  num    5.1  4.9  4.7  4.6  5  5.4  4.6  5  4.4  4.9  ...    $  Sepal.Width  :  num    3.5  3  3.2  3.1  3.6  3.9  3.4  3.4  2.9  3.1  ...    $  Petal.Length:  num    1.4  1.4  1.3  1.5  1.4  1.7  1.4  1.5  1.4  1.5  ...    $  Petal.Width  :  num    0.2  0.2  0.2  0.2  0.2  0.4  0.3  0.2  0.2  0.1  ...    $  Species          :  Factor  w/  3  levels  "setosa","versicolor",..:  1  1  1  ... Dataset compilato da Anderson che contiene i dati in centimetri di petali e sepali di tre diverse specie di iris. Guardiamo le relazioni tra le variabili con il comando ggpairs.
  24. 24. Introduzione ai Big Data e alla scienza dei dati, Palazzolo Digital Hub, 2014. Copyright: Vincenzo Manzoni IRIS RELAZIONETRA LEVARIABILI 24
  25. 25. Introduzione ai Big Data e alla scienza dei dati, Palazzolo Digital Hub, 2014. Copyright: Vincenzo Manzoni IRIS RELAZIONETRA LARGHEZZA E LUNGHEZZA PETALO 25
  26. 26. Introduzione ai Big Data e alla scienza dei dati, Palazzolo Digital Hub, 2014. Copyright: Vincenzo Manzoni REGRESSIONE LINEARE 26 Petal.Width = a + b x Petal.Length Come si stimano in modo ottimo a e b?
  27. 27. Introduzione ai Big Data e alla scienza dei dati, Palazzolo Digital Hub, 2014. Copyright: Vincenzo Manzoni REGRESSIONE LINEARE IN R 27 >  lm_model  <-­‐  lm(Petal.Width  ~  Petal.Length,  data=iris)   >  summary(lm_model)   ! ! ! ! ! ! ! ! ! ! >  coefficients(lm_model) Residuals:            Min              1Q      Median              3Q            Max     -­‐0.56515  -­‐0.12358  -­‐0.01898    0.13288    0.64272     ! Coefficients:                              Estimate  Std.  Error  t  value  Pr(>|t|)           (Intercept)    -­‐0.363076      0.039762    -­‐9.131    4.7e-­‐16  ***   Petal.Length    0.415755      0.009582    43.387    <  2e-­‐16  ***   -­‐-­‐-­‐   Signif.  codes:    0  ‘***’  0.001  ‘**’  0.01  ‘*’  0.05  ‘.’  0.1  ‘  ’  1   ! Residual  standard  error:  0.2065  on  148  degrees  of  freedom   Multiple  R-­‐squared:    0.9271,   Adjusted  R-­‐squared:    0.9266     F-­‐statistic:    1882  on  1  and  148  DF,    p-­‐value:  <  2.2e-­‐16   
 (Intercept)  Petal.Length        -­‐0.3630755        0.4157554  
  28. 28. Introduzione ai Big Data e alla scienza dei dati, Palazzolo Digital Hub, 2014. Copyright: Vincenzo Manzoni ESERCIZIO 3.1 Usando il dataset mtcars, determinare il modello lineare che descrive il consumo (mpg) in funzione della potenza (hp). 28 Durata esercizio: 15 minuti
  29. 29. Introduzione ai Big Data e alla scienza dei dati, Palazzolo Digital Hub, 2014. Copyright: Vincenzo Manzoni REGRESSIONE LINEARE WEKA 29 www.cs.waikato.ac.nz/ml/weka/
  30. 30. Introduzione ai Big Data e alla scienza dei dati, Palazzolo Digital Hub, 2014. Copyright: Vincenzo Manzoni REGRESSIONE LINEARE RWEKA:WEKAVISTO DA R • Il pacchetto RWeka permette di usare gli algoritmi di machine learning disponibili in Weka in R e di applicare facilmente i modelli a nuovi dati. 30 Weka Explorer per determinare il modello migliore Calcolo del modello con RWeka Calcolo del modello con RWeka Insieme di addestramento ModelloNuovi dati Predizione
  31. 31. Introduzione ai Big Data e alla scienza dei dati, Palazzolo Digital Hub, 2014. Copyright: Vincenzo Manzoni USO DI RWEKA REGRESSIONE LINEARE 31 Algoritmo (regressione lineare) Variabile da stimare / dipendente Variabile indipendente Predizione del modello applicato alla prima riga del dataset #  Al  primo  uso,  installare  il  pacchetto  RWeka
 install.packages('RWeka',  dependencies=TRUE)
 
 library(RWeka)
 
 iris_rl  <-­‐  LinearRegression(Petal.Width  ~  Petal.Length,  data=iris)
 
 predict(iris_rl,  iris[1,],  type=c(“class"))   [1]  0.2189821   !    Sepal.Length  Sepal.Width  Petal.Length  Petal.Width  Species   1                    5.1                  3.5                    1.4                  0.2    setosa
  32. 32. Introduzione ai Big Data e alla scienza dei dati, Palazzolo Digital Hub, 2014. Copyright: Vincenzo Manzoni APPRENDIMENTO SUPERVISIONATO K-NEAREST NEIGHBORS 32
  33. 33. Introduzione ai Big Data e alla scienza dei dati, Palazzolo Digital Hub, 2014. Copyright: Vincenzo Manzoni K-NEAREST NEIGHBORS • Il riconoscimento avviene sulla base degli oggetti vicini a quello considerato. • Il parametro k indica quanti vicini considerare. • Può essere usato per stimare classi discrete
 (classificazione) o variabili 
 continue (regressione) • In Weka, è classificato come IBk 33 x1 x2 k=1 k=5 k=2
  34. 34. Introduzione ai Big Data e alla scienza dei dati, Palazzolo Digital Hub, 2014. Copyright: Vincenzo Manzoni ESERCIZIO 3.2 Problema di classificazione Attraverso Weka e l’algoritmo k-NN, creare un modello che stimi la specie dai dati del sepalo e petalo. Cosa cambia al variare di k? ! Problema di regressione Attraverso Weka e l’algoritmo k-NN, che stimi la larghezza dei petali. Cosa cambia al variare di k? 34 Durata esercizio: 20 minuti
  35. 35. Introduzione ai Big Data e alla scienza dei dati, Palazzolo Digital Hub, 2014. Copyright: Vincenzo Manzoni LA MATRICE DI CONFUSIONE 35 Predetti Setosa Versicolor Virginica Reali Setosa 50 0 0 Versicolor 0 47 3 Virginica 0 4 46 47Versicolor sono state classificate correttamente. ! 3 sono state classificate comeVirginica.
  36. 36. Introduzione ai Big Data e alla scienza dei dati, Palazzolo Digital Hub, 2014. Copyright: Vincenzo Manzoni APPRENDIMENTO SUPERVISIONATO ALBERI DI DECISIONE 36
  37. 37. Introduzione ai Big Data e alla scienza dei dati, Palazzolo Digital Hub, 2014. Copyright: Vincenzo Manzoni ALBERI DI DECISIONE • E’ un algoritmo di classificazione trasparente. Una volta addestrato, è rappresentabile con una serie di se, allora, altrimenti. • In Weka, gli algoritmi che implementano gli alberi di decisione sono J48 e SimpleCart. 37
  38. 38. Introduzione ai Big Data e alla scienza dei dati, Palazzolo Digital Hub, 2014. Copyright: Vincenzo Manzoni ESERCIZIO 3.3 Attraverso Weka, applicare gli alberi di decisione per creare un modello che stimi la classe della pianta dai suoi attributi. ! Analizzare la qualità del modello e le regole che usa per classificare le piante. 38 Durata esercizio: 20 minuti
  39. 39. Introduzione ai Big Data e alla scienza dei dati, Palazzolo Digital Hub, 2014. Copyright: Vincenzo Manzoni APPRENDIMENTO NON SUPERVISIONATO K-MEANS 39
  40. 40. Introduzione ai Big Data e alla scienza dei dati, Palazzolo Digital Hub, 2014. Copyright: Vincenzo Manzoni CLUSTERING K-MEANS • Suddivide un insieme di oggetti in k classi sulla base dei loro attributi. • E’ necessario specificare il numero di classi a cui appartengono gli oggetti. Il più delle volte, è un’informazione nota. • E’ un algoritmo iterativo. 40
  41. 41. Introduzione ai Big Data e alla scienza dei dati, Palazzolo Digital Hub, 2014. Copyright: Vincenzo Manzoni ESERCIZIO 3.4 Applicare l’algoritmo k-means al data set iris. Le tre classi di Iris definiscono 3 cluster? 41 Durata esercizio: 20 minuti
  42. 42. Introduzione ai Big Data e alla scienza dei dati, Palazzolo Digital Hub, 2014. Copyright: Vincenzo Manzoni ESERCIZIO 3.5 Usando in dataset titanic, determinare un modello che predica quando un passeggero sopravviverà applicando uno dei modelli che abbiamo visto stamattina. L’obiettivo è trovare il modello che meglio predica la sopravvivenza. 42 Durata esercizio: 15 minuti
  43. 43. Introduzione ai Big Data e alla scienza dei dati, Palazzolo Digital Hub, 2014. Copyright: Vincenzo Manzoni LIBRO DI RIFERIMENTO 43
  44. 44. Introduzione ai Big Data e alla scienza dei dati, Palazzolo Digital Hub, 2014. Copyright: Vincenzo Manzoni LA PROSSIMA LEZIONE AGENDA 1. I sistemi di raccomandazione. 2. Analisi di Big Data: Map Reduce, Hadoop, Pig, Hive. 44

×