SlideShare uma empresa Scribd logo
1 de 30
Baixar para ler offline
Aiguille et botte de foin :
scikit-learn et joblib pour explorer des donn´es volumeuses
                                             e

                       G. Varoquaux
                       Neurospin + INRIA
Explosion de la quantit´ de donn´es
                       e        e
Explosion de la quantit´ de donn´es
                       e        e
Traitement statistique de donn´e (apprentissage)
                              e


  R´sumer l’information
   e


  Pr´dire de nouvelles informations
    e


  Statistiquement optimal


  Algorithmiquement rapide
1 Pr´dire – scikit-learn
    e


2 R´sumer – scikit-learn
   e


  ˆ
3 Etre fain´ant (et efficace) – joblib
           e
1 Pr´dire –
    e         scikit-learn
1 Reconnaissance de visage




   Andr´
       e      Bernard        Charles   Didier
1 Reconnaissance de visage




   Andr´
       e      Bernard        Charles   Didier




                        ?
1 M´thode na¨
   e        ıve



1 Estimer les visages typiques ` partir
                               a
 d’images connues (bruit´es).
                         e

2 A partir d’une photo (bruit´e aussi), trouver
                               e
 le visages typique qui lui ressemble le plus.
1 Une botte de foin


              La fraction d’information int´ressante est faible :
                                           e
                 Il y a du bruit
                 L’image est grande
                     1.0                                                  0.70
Taux de prediction




                                                     Taux de prediction
                     0.9                                                  0.65
                     0.8
                     0.7                                                  0.60
                     0.6                                                  0.55
                     0.5                                                  0.50
                     0.4
                     0.3                                                  0.45
                     0.2
                       0.0 0.5 1.0 1.5 2.0 2.5 3.0                        0.401    2    3   4    5    6     7
                            Niveau de bruit                                       Fraction utile du cadre
1 Les vrais donn´es sont pourries
                e
 http://cswww.essex.ac.uk/mv/allfaces
 100 individus, 10 photos par individu,
 ` peu pr`s align´es
 a       e       e
1 Validation crois´e
                  e

1 Choisir une fraction des photos pour les visages
  connus (jeu d’apprentissage).

2 Apprendre les visages typiques et la fonction de
  pr´diction dessus.
    e

3 Tester la pr´diction en essayant de nommer les
              e
  photos non utilis´es pour l’apprentissage (jeu de
                    e
  test) et en mesurant le taux d’erreur.
1 Du code : scikit-learn
Objets avec fit/predict prenant des tableaux numpy
e = E s t i m a t o r ()
e . f i t ( k n o w n f a c e s , known names )
guessed names = e. p r e d i c t ( unkown faces )


G´n´rateurs de validation crois´e renvoyant des masques
 e e                           e
from s c i k i t s . l e a r n import c r o s s v a l
c v = c r o s s v a l . S t r a t i f i e d K F o l d ( names )
for t r a i n , t e s t in c v :
     e . f i t ( f a c e s [ t r a i n ] , names [ t r a i n ])
     e . p r e d i c t ( f a c e s [ t e s t ])


Ingr´dients de base d’un framework d’apprentissage
    e
1 Au final : .5% d’erreur de pr´diction
                               e
   Utiliser les k plus proches voisin (kNN) :
import numpy a s np
from s c i k i t s . l e a r n import c r o s s v a l
from s c i k i t s . l e a r n . n e i g h b o r s import N e i g h b o r s

c v = c r o s s v a l . S t r a t i f i e d K F o l d ( l a b e l s , k =5)
e = N e i g h b o r s ( k =5)
e r r o r s = c r o s s v a l . c r o s s v a l s c o r e (e , data ,
                                                          l a b e l s , cv = cv )
print ’ score ’ , np . sum ( e r r o r s ) / f l o a t ( l e n ( d a t a ) )

   Choisir k pour optimiser le score.
   Attention 2 boucles imbriqu´es de validation crois´e
                                 e                   e
   1 choisir k
   2 ´valuer l’erreur sur des donn´es inconnues
     e                             e
2 R´sumer –
   e          scikit-learn
2 R´duire la taille des donn´es
   e                        e

Botte de foin : la taille des donn´es nuit ` la
                                  e        a
performance
Les images contiennent beaucoup
 d’information redondante
 Comment la r´duire de facon optimale ?
             e           ¸
2 Former des groupes




      Pays associ´s ` une devise majeure
                  e a
   La corr´lation des taux de changes fournit
          e
              une mesure d’affinit´e
2 Former des groupes




         Qui se ressemble s’assemble
2 Former des groupes sur une image




                    Lena




   4            8           16       32
2 Former des groupes sur les 1000 visages




 k=30         k=50        k=100          k=200
Choisir k pour maximiser la pr´diction
                              e
(encore une boucle de validation crois´e)
                                       e
2 scikit-learn

  Apprentissage statistique en Python
Efficace
 Bons algorithmes, numpy + scipy,
 C + Cython + Python

Pythonesque
 License BSD, objets simples,
 pas de d´pendences autres que numpy + scipy
         e

Facile ` utiliser
       a
  API uniforme, documentation,
  paramˆtres par d´fault
        e         e
ˆ
3 Etre fain´ant (et efficace) –
           e
  joblib
´
3 Evaluation fain´ante
                 e

On calcule toujours la mˆme chose
                         e
 Boucles de imbriqu´es avec transformations
                   e
 successives
  Calculs en variant les paramˆtres
                              e

Difficult´s
        e
 Connaˆ les d´pendances entre les ´tapes
       ıtre  e                    e
  Suivre les paramˆtres
                  e

  ´
  Evaluation fain´ante : ne pas recalculer ce
                 e
  qu’on a d´j` calcul´
           ea        e
3 pipeline/data flow programming
3 joblib
Philosophie

Simple              ne changez pas vos programmes
              n’apprenez pas de nouveau paradigmes

Minimal           pas de d´pendances, embarquable
                          e
                             peu de fonctionnalit´s
                                                 e

Performant                         grosses donn´es
                                                e
                                    calcul parall`le
                                                 e

Robuste                        tol´rant aux erreurs
                                  e
                                        debuggable
3 joblib
´
Evaluation fain´ante
               e
 >>>   from j o b l i b import Memory
 >>>   mem = Memory ( c a c h e d i r = ’/ tmp / joblib ’)
 >>>   import numpy a s np
 >>>   a = np . v a n d e r ( np . a r a n g e (3) )
 >>>   s q u a r e = mem. c a c h e ( np . s q u a r e )
 >>>   b = square (a)

 [ Memory ] C a l l i n g s q u a r e ...
 s q u a r e ( a r r a y ([[0 , 0 , 1] ,
               [1 , 1 , 1] ,
               [4 , 2 , 1]]) )
                                            s q u a r e - 0.0 s
 >>> c = s q u a r e ( a )
 >>> # Pas de re - evaluation
3 joblib
´
Evaluation fain´ante
               e

Hash MD5 des paramˆtres d’entr´es (efficace)
                   e          e
 ⇒ pas de mod`le de donn´es et d’ex´cution
              e         e          e

Stockage sur disk dans des r´pertoires s´par´s
                            e           e e
 (efficace – memmap)

Table globale sqlite (verrous :( )

Nettoyage de cache ` la vol´e (beta)
                   a       e
3 joblib
Calcul parall`le
             e
 >>> from j o b l i b import P a r a l l e l , d e l a y e d
 >>> from math import s q r t
 >>> P a r a l l e l ( n j o b s =1) ( d e l a y e d ( s q r t ) ( i **2)
 ...                   for i in r a n g e (7) )
 [0.0 , 1.0 , 2.0 , 3.0 , 4.0 , 5.0 , 6.0 , 7.0]

La syntaxe est importante

Le d´bugage aussi
    e

 ⇒ Fork agressif
3 joblib
Le futur

Meilleur branchement parall`le/memoire
                           e

Meilleurs bases de donn´es/datastore
                       e

2 niveaux de cache (m´moire/disk)
                     e

Suivit d’ex´cution
           e
3 Traitement de donn´es performant. . .
                    e
 Scikit Learn :
    Algorithmes ´tat de l’art
                 e
    Projet jeune

 joblib
    Mieux calculer
    Pas que scientifique

         http://scikits-learn.sf.net
      http://packages.python.org/joblib

Mais conteúdo relacionado

Destaque

SeSQL : un moteur de recherche en Python et PostgreSQL
SeSQL : un moteur de recherche en Python et PostgreSQLSeSQL : un moteur de recherche en Python et PostgreSQL
SeSQL : un moteur de recherche en Python et PostgreSQLParis, France
 
Presentation r markdown
Presentation r markdown Presentation r markdown
Presentation r markdown Cdiscount
 
Algorithmique_et_programmation_part2
Algorithmique_et_programmation_part2Algorithmique_et_programmation_part2
Algorithmique_et_programmation_part2Emeric Tapachès
 
Python et les bases de données non sql
Python et les bases de données non sqlPython et les bases de données non sql
Python et les bases de données non sqlbchesneau
 
pandas: a Foundational Python Library for Data Analysis and Statistics
pandas: a Foundational Python Library for Data Analysis and Statisticspandas: a Foundational Python Library for Data Analysis and Statistics
pandas: a Foundational Python Library for Data Analysis and StatisticsWes McKinney
 
pandas: Powerful data analysis tools for Python
pandas: Powerful data analysis tools for Pythonpandas: Powerful data analysis tools for Python
pandas: Powerful data analysis tools for PythonWes McKinney
 
Simple big data, in Python
Simple big data, in PythonSimple big data, in Python
Simple big data, in PythonGael Varoquaux
 
Scikit-learn: apprentissage statistique en Python. Créer des machines intelli...
Scikit-learn: apprentissage statistique en Python. Créer des machines intelli...Scikit-learn: apprentissage statistique en Python. Créer des machines intelli...
Scikit-learn: apprentissage statistique en Python. Créer des machines intelli...Gael Varoquaux
 
Chap XIII : calcul scientifique avec python
Chap XIII : calcul scientifique avec pythonChap XIII : calcul scientifique avec python
Chap XIII : calcul scientifique avec pythonMohammed TAMALI
 
Chapitre4 Les sondages à probabilité inégales
Chapitre4 Les sondages à probabilité inégalesChapitre4 Les sondages à probabilité inégales
Chapitre4 Les sondages à probabilité inégalesMahamadou Haro
 
Aux frontières du "Do It Yourself" : des Fab Labs à la nouvelle industrie ?
Aux frontières du "Do It Yourself" : des Fab Labs à la nouvelle industrie ?Aux frontières du "Do It Yourself" : des Fab Labs à la nouvelle industrie ?
Aux frontières du "Do It Yourself" : des Fab Labs à la nouvelle industrie ?Fing
 
S1 mq i - statistique descriptive i - résumés des chapitres
S1   mq i - statistique descriptive i - résumés des chapitresS1   mq i - statistique descriptive i - résumés des chapitres
S1 mq i - statistique descriptive i - résumés des chapitresAbdeslam ELMOUDEN
 
Django toolbox
Django toolboxDjango toolbox
Django toolboxxordoquy
 

Destaque (14)

SeSQL : un moteur de recherche en Python et PostgreSQL
SeSQL : un moteur de recherche en Python et PostgreSQLSeSQL : un moteur de recherche en Python et PostgreSQL
SeSQL : un moteur de recherche en Python et PostgreSQL
 
Presentation r markdown
Presentation r markdown Presentation r markdown
Presentation r markdown
 
Algorithmique_et_programmation_part2
Algorithmique_et_programmation_part2Algorithmique_et_programmation_part2
Algorithmique_et_programmation_part2
 
Python et les bases de données non sql
Python et les bases de données non sqlPython et les bases de données non sql
Python et les bases de données non sql
 
R versur Python
R versur PythonR versur Python
R versur Python
 
pandas: a Foundational Python Library for Data Analysis and Statistics
pandas: a Foundational Python Library for Data Analysis and Statisticspandas: a Foundational Python Library for Data Analysis and Statistics
pandas: a Foundational Python Library for Data Analysis and Statistics
 
pandas: Powerful data analysis tools for Python
pandas: Powerful data analysis tools for Pythonpandas: Powerful data analysis tools for Python
pandas: Powerful data analysis tools for Python
 
Simple big data, in Python
Simple big data, in PythonSimple big data, in Python
Simple big data, in Python
 
Scikit-learn: apprentissage statistique en Python. Créer des machines intelli...
Scikit-learn: apprentissage statistique en Python. Créer des machines intelli...Scikit-learn: apprentissage statistique en Python. Créer des machines intelli...
Scikit-learn: apprentissage statistique en Python. Créer des machines intelli...
 
Chap XIII : calcul scientifique avec python
Chap XIII : calcul scientifique avec pythonChap XIII : calcul scientifique avec python
Chap XIII : calcul scientifique avec python
 
Chapitre4 Les sondages à probabilité inégales
Chapitre4 Les sondages à probabilité inégalesChapitre4 Les sondages à probabilité inégales
Chapitre4 Les sondages à probabilité inégales
 
Aux frontières du "Do It Yourself" : des Fab Labs à la nouvelle industrie ?
Aux frontières du "Do It Yourself" : des Fab Labs à la nouvelle industrie ?Aux frontières du "Do It Yourself" : des Fab Labs à la nouvelle industrie ?
Aux frontières du "Do It Yourself" : des Fab Labs à la nouvelle industrie ?
 
S1 mq i - statistique descriptive i - résumés des chapitres
S1   mq i - statistique descriptive i - résumés des chapitresS1   mq i - statistique descriptive i - résumés des chapitres
S1 mq i - statistique descriptive i - résumés des chapitres
 
Django toolbox
Django toolboxDjango toolbox
Django toolbox
 

Semelhante a Aiguille dans botte de foin: scikit-learn et joblib

Computer Vision - Classification automatique des races de chien à partir de p...
Computer Vision - Classification automatique des races de chien à partir de p...Computer Vision - Classification automatique des races de chien à partir de p...
Computer Vision - Classification automatique des races de chien à partir de p...FUMERY Michael
 
Introduction à la Data Science l data business
Introduction à la Data Science l data businessIntroduction à la Data Science l data business
Introduction à la Data Science l data businessVincent de Stoecklin
 
resampling_evaluation.pdf
resampling_evaluation.pdfresampling_evaluation.pdf
resampling_evaluation.pdfSidiAbdallah1
 
Introduction to Machine learning
Introduction to Machine learningIntroduction to Machine learning
Introduction to Machine learningQuentin Ambard
 
IBM Paris Bluemix Meetup #12 - Ecole 42 - 9 décembre 2015
IBM Paris Bluemix Meetup #12 - Ecole 42 - 9 décembre 2015IBM Paris Bluemix Meetup #12 - Ecole 42 - 9 décembre 2015
IBM Paris Bluemix Meetup #12 - Ecole 42 - 9 décembre 2015IBM France Lab
 
Tutoriel pour dresser une courbe de lumière d'un transit d'exoplanète avec Ir...
Tutoriel pour dresser une courbe de lumière d'un transit d'exoplanète avec Ir...Tutoriel pour dresser une courbe de lumière d'un transit d'exoplanète avec Ir...
Tutoriel pour dresser une courbe de lumière d'un transit d'exoplanète avec Ir...Didier Walliang
 
Tutoriel de traitement d'images CCD cométaire avec Iris
Tutoriel de traitement d'images CCD cométaire avec IrisTutoriel de traitement d'images CCD cométaire avec Iris
Tutoriel de traitement d'images CCD cométaire avec IrisDidier Walliang
 
TP_Réseaux_de_neurones_Safae_ElOmari.pdf
TP_Réseaux_de_neurones_Safae_ElOmari.pdfTP_Réseaux_de_neurones_Safae_ElOmari.pdf
TP_Réseaux_de_neurones_Safae_ElOmari.pdfSafaeElOmari
 
TP Fouille de données (Data Mining) et Apprentissage Machine
TP Fouille de données (Data Mining) et Apprentissage MachineTP Fouille de données (Data Mining) et Apprentissage Machine
TP Fouille de données (Data Mining) et Apprentissage MachineBoubaker KHMILI
 
INF120 - Algo DUT SRC1 - Cours 3
INF120 - Algo DUT SRC1 - Cours 3INF120 - Algo DUT SRC1 - Cours 3
INF120 - Algo DUT SRC1 - Cours 3PGambette
 
Ch6 Introduction à la Science de Données.pdf
Ch6 Introduction à la Science de Données.pdfCh6 Introduction à la Science de Données.pdf
Ch6 Introduction à la Science de Données.pdfnesrinetaamallah
 
Fondements du machine learning
Fondements du machine learningFondements du machine learning
Fondements du machine learningFrederic Simard
 
Cours acp mehdi_aman
Cours acp mehdi_amanCours acp mehdi_aman
Cours acp mehdi_amanMehdi Aman
 
Algorythmes et programmation
Algorythmes et programmationAlgorythmes et programmation
Algorythmes et programmationMohamed Latifi
 
Présentation Alt.net - Tests unitaires automatisés
Présentation Alt.net - Tests unitaires automatisésPrésentation Alt.net - Tests unitaires automatisés
Présentation Alt.net - Tests unitaires automatisésDjamel Zouaoui
 
Apprentissage_Supervise.pdf
Apprentissage_Supervise.pdfApprentissage_Supervise.pdf
Apprentissage_Supervise.pdfSidiAbdallah1
 

Semelhante a Aiguille dans botte de foin: scikit-learn et joblib (20)

Computer Vision - Classification automatique des races de chien à partir de p...
Computer Vision - Classification automatique des races de chien à partir de p...Computer Vision - Classification automatique des races de chien à partir de p...
Computer Vision - Classification automatique des races de chien à partir de p...
 
Introduction à la Data Science l data business
Introduction à la Data Science l data businessIntroduction à la Data Science l data business
Introduction à la Data Science l data business
 
Mise en oeuvre des framework de machines et deep learning v1
Mise en oeuvre des framework de machines et deep learning v1 Mise en oeuvre des framework de machines et deep learning v1
Mise en oeuvre des framework de machines et deep learning v1
 
resampling_evaluation.pdf
resampling_evaluation.pdfresampling_evaluation.pdf
resampling_evaluation.pdf
 
Introduction to Machine learning
Introduction to Machine learningIntroduction to Machine learning
Introduction to Machine learning
 
IBM Paris Bluemix Meetup #12 - Ecole 42 - 9 décembre 2015
IBM Paris Bluemix Meetup #12 - Ecole 42 - 9 décembre 2015IBM Paris Bluemix Meetup #12 - Ecole 42 - 9 décembre 2015
IBM Paris Bluemix Meetup #12 - Ecole 42 - 9 décembre 2015
 
Tutoriel pour dresser une courbe de lumière d'un transit d'exoplanète avec Ir...
Tutoriel pour dresser une courbe de lumière d'un transit d'exoplanète avec Ir...Tutoriel pour dresser une courbe de lumière d'un transit d'exoplanète avec Ir...
Tutoriel pour dresser une courbe de lumière d'un transit d'exoplanète avec Ir...
 
Analyzing a churn data set
Analyzing a churn data set Analyzing a churn data set
Analyzing a churn data set
 
Tutoriel de traitement d'images CCD cométaire avec Iris
Tutoriel de traitement d'images CCD cométaire avec IrisTutoriel de traitement d'images CCD cométaire avec Iris
Tutoriel de traitement d'images CCD cométaire avec Iris
 
TP_Réseaux_de_neurones_Safae_ElOmari.pdf
TP_Réseaux_de_neurones_Safae_ElOmari.pdfTP_Réseaux_de_neurones_Safae_ElOmari.pdf
TP_Réseaux_de_neurones_Safae_ElOmari.pdf
 
TP Fouille de données (Data Mining) et Apprentissage Machine
TP Fouille de données (Data Mining) et Apprentissage MachineTP Fouille de données (Data Mining) et Apprentissage Machine
TP Fouille de données (Data Mining) et Apprentissage Machine
 
INF120 - Algo DUT SRC1 - Cours 3
INF120 - Algo DUT SRC1 - Cours 3INF120 - Algo DUT SRC1 - Cours 3
INF120 - Algo DUT SRC1 - Cours 3
 
Ch6 Introduction à la Science de Données.pdf
Ch6 Introduction à la Science de Données.pdfCh6 Introduction à la Science de Données.pdf
Ch6 Introduction à la Science de Données.pdf
 
Fondements du machine learning
Fondements du machine learningFondements du machine learning
Fondements du machine learning
 
Cours acp mehdi_aman
Cours acp mehdi_amanCours acp mehdi_aman
Cours acp mehdi_aman
 
Algorythmes et programmation
Algorythmes et programmationAlgorythmes et programmation
Algorythmes et programmation
 
Présentation Alt.net - Tests unitaires automatisés
Présentation Alt.net - Tests unitaires automatisésPrésentation Alt.net - Tests unitaires automatisés
Présentation Alt.net - Tests unitaires automatisés
 
Apprentissage_Supervise.pdf
Apprentissage_Supervise.pdfApprentissage_Supervise.pdf
Apprentissage_Supervise.pdf
 
Rapport
RapportRapport
Rapport
 
Mathématiques et Python
Mathématiques et PythonMathématiques et Python
Mathématiques et Python
 

Mais de Gael Varoquaux

Evaluating machine learning models and their diagnostic value
Evaluating machine learning models and their diagnostic valueEvaluating machine learning models and their diagnostic value
Evaluating machine learning models and their diagnostic valueGael Varoquaux
 
Measuring mental health with machine learning and brain imaging
Measuring mental health with machine learning and brain imagingMeasuring mental health with machine learning and brain imaging
Measuring mental health with machine learning and brain imagingGael Varoquaux
 
Machine learning with missing values
Machine learning with missing valuesMachine learning with missing values
Machine learning with missing valuesGael Varoquaux
 
Dirty data science machine learning on non-curated data
Dirty data science machine learning on non-curated dataDirty data science machine learning on non-curated data
Dirty data science machine learning on non-curated dataGael Varoquaux
 
Representation learning in limited-data settings
Representation learning in limited-data settingsRepresentation learning in limited-data settings
Representation learning in limited-data settingsGael Varoquaux
 
Better neuroimaging data processing: driven by evidence, open communities, an...
Better neuroimaging data processing: driven by evidence, open communities, an...Better neuroimaging data processing: driven by evidence, open communities, an...
Better neuroimaging data processing: driven by evidence, open communities, an...Gael Varoquaux
 
Functional-connectome biomarkers to meet clinical needs?
Functional-connectome biomarkers to meet clinical needs?Functional-connectome biomarkers to meet clinical needs?
Functional-connectome biomarkers to meet clinical needs?Gael Varoquaux
 
Atlases of cognition with large-scale human brain mapping
Atlases of cognition with large-scale human brain mappingAtlases of cognition with large-scale human brain mapping
Atlases of cognition with large-scale human brain mappingGael Varoquaux
 
Similarity encoding for learning on dirty categorical variables
Similarity encoding for learning on dirty categorical variablesSimilarity encoding for learning on dirty categorical variables
Similarity encoding for learning on dirty categorical variablesGael Varoquaux
 
Machine learning for functional connectomes
Machine learning for functional connectomesMachine learning for functional connectomes
Machine learning for functional connectomesGael Varoquaux
 
Towards psychoinformatics with machine learning and brain imaging
Towards psychoinformatics with machine learning and brain imagingTowards psychoinformatics with machine learning and brain imaging
Towards psychoinformatics with machine learning and brain imagingGael Varoquaux
 
Simple representations for learning: factorizations and similarities
Simple representations for learning: factorizations and similarities Simple representations for learning: factorizations and similarities
Simple representations for learning: factorizations and similarities Gael Varoquaux
 
A tutorial on Machine Learning, with illustrations for MR imaging
A tutorial on Machine Learning, with illustrations for MR imagingA tutorial on Machine Learning, with illustrations for MR imaging
A tutorial on Machine Learning, with illustrations for MR imagingGael Varoquaux
 
Scikit-learn and nilearn: Democratisation of machine learning for brain imaging
Scikit-learn and nilearn: Democratisation of machine learning for brain imagingScikit-learn and nilearn: Democratisation of machine learning for brain imaging
Scikit-learn and nilearn: Democratisation of machine learning for brain imagingGael Varoquaux
 
Computational practices for reproducible science
Computational practices for reproducible scienceComputational practices for reproducible science
Computational practices for reproducible scienceGael Varoquaux
 
Coding for science and innovation
Coding for science and innovationCoding for science and innovation
Coding for science and innovationGael Varoquaux
 
Estimating Functional Connectomes: Sparsity’s Strength and Limitations
Estimating Functional Connectomes: Sparsity’s Strength and LimitationsEstimating Functional Connectomes: Sparsity’s Strength and Limitations
Estimating Functional Connectomes: Sparsity’s Strength and LimitationsGael Varoquaux
 
On the code of data science
On the code of data scienceOn the code of data science
On the code of data scienceGael Varoquaux
 
Scientist meets web dev: how Python became the language of data
Scientist meets web dev: how Python became the language of dataScientist meets web dev: how Python became the language of data
Scientist meets web dev: how Python became the language of dataGael Varoquaux
 
Machine learning and cognitive neuroimaging: new tools can answer new questions
Machine learning and cognitive neuroimaging: new tools can answer new questionsMachine learning and cognitive neuroimaging: new tools can answer new questions
Machine learning and cognitive neuroimaging: new tools can answer new questionsGael Varoquaux
 

Mais de Gael Varoquaux (20)

Evaluating machine learning models and their diagnostic value
Evaluating machine learning models and their diagnostic valueEvaluating machine learning models and their diagnostic value
Evaluating machine learning models and their diagnostic value
 
Measuring mental health with machine learning and brain imaging
Measuring mental health with machine learning and brain imagingMeasuring mental health with machine learning and brain imaging
Measuring mental health with machine learning and brain imaging
 
Machine learning with missing values
Machine learning with missing valuesMachine learning with missing values
Machine learning with missing values
 
Dirty data science machine learning on non-curated data
Dirty data science machine learning on non-curated dataDirty data science machine learning on non-curated data
Dirty data science machine learning on non-curated data
 
Representation learning in limited-data settings
Representation learning in limited-data settingsRepresentation learning in limited-data settings
Representation learning in limited-data settings
 
Better neuroimaging data processing: driven by evidence, open communities, an...
Better neuroimaging data processing: driven by evidence, open communities, an...Better neuroimaging data processing: driven by evidence, open communities, an...
Better neuroimaging data processing: driven by evidence, open communities, an...
 
Functional-connectome biomarkers to meet clinical needs?
Functional-connectome biomarkers to meet clinical needs?Functional-connectome biomarkers to meet clinical needs?
Functional-connectome biomarkers to meet clinical needs?
 
Atlases of cognition with large-scale human brain mapping
Atlases of cognition with large-scale human brain mappingAtlases of cognition with large-scale human brain mapping
Atlases of cognition with large-scale human brain mapping
 
Similarity encoding for learning on dirty categorical variables
Similarity encoding for learning on dirty categorical variablesSimilarity encoding for learning on dirty categorical variables
Similarity encoding for learning on dirty categorical variables
 
Machine learning for functional connectomes
Machine learning for functional connectomesMachine learning for functional connectomes
Machine learning for functional connectomes
 
Towards psychoinformatics with machine learning and brain imaging
Towards psychoinformatics with machine learning and brain imagingTowards psychoinformatics with machine learning and brain imaging
Towards psychoinformatics with machine learning and brain imaging
 
Simple representations for learning: factorizations and similarities
Simple representations for learning: factorizations and similarities Simple representations for learning: factorizations and similarities
Simple representations for learning: factorizations and similarities
 
A tutorial on Machine Learning, with illustrations for MR imaging
A tutorial on Machine Learning, with illustrations for MR imagingA tutorial on Machine Learning, with illustrations for MR imaging
A tutorial on Machine Learning, with illustrations for MR imaging
 
Scikit-learn and nilearn: Democratisation of machine learning for brain imaging
Scikit-learn and nilearn: Democratisation of machine learning for brain imagingScikit-learn and nilearn: Democratisation of machine learning for brain imaging
Scikit-learn and nilearn: Democratisation of machine learning for brain imaging
 
Computational practices for reproducible science
Computational practices for reproducible scienceComputational practices for reproducible science
Computational practices for reproducible science
 
Coding for science and innovation
Coding for science and innovationCoding for science and innovation
Coding for science and innovation
 
Estimating Functional Connectomes: Sparsity’s Strength and Limitations
Estimating Functional Connectomes: Sparsity’s Strength and LimitationsEstimating Functional Connectomes: Sparsity’s Strength and Limitations
Estimating Functional Connectomes: Sparsity’s Strength and Limitations
 
On the code of data science
On the code of data scienceOn the code of data science
On the code of data science
 
Scientist meets web dev: how Python became the language of data
Scientist meets web dev: how Python became the language of dataScientist meets web dev: how Python became the language of data
Scientist meets web dev: how Python became the language of data
 
Machine learning and cognitive neuroimaging: new tools can answer new questions
Machine learning and cognitive neuroimaging: new tools can answer new questionsMachine learning and cognitive neuroimaging: new tools can answer new questions
Machine learning and cognitive neuroimaging: new tools can answer new questions
 

Aiguille dans botte de foin: scikit-learn et joblib

  • 1. Aiguille et botte de foin : scikit-learn et joblib pour explorer des donn´es volumeuses e G. Varoquaux Neurospin + INRIA
  • 2. Explosion de la quantit´ de donn´es e e
  • 3. Explosion de la quantit´ de donn´es e e
  • 4. Traitement statistique de donn´e (apprentissage) e R´sumer l’information e Pr´dire de nouvelles informations e Statistiquement optimal Algorithmiquement rapide
  • 5. 1 Pr´dire – scikit-learn e 2 R´sumer – scikit-learn e ˆ 3 Etre fain´ant (et efficace) – joblib e
  • 6. 1 Pr´dire – e scikit-learn
  • 7. 1 Reconnaissance de visage Andr´ e Bernard Charles Didier
  • 8. 1 Reconnaissance de visage Andr´ e Bernard Charles Didier ?
  • 9. 1 M´thode na¨ e ıve 1 Estimer les visages typiques ` partir a d’images connues (bruit´es). e 2 A partir d’une photo (bruit´e aussi), trouver e le visages typique qui lui ressemble le plus.
  • 10. 1 Une botte de foin La fraction d’information int´ressante est faible : e Il y a du bruit L’image est grande 1.0 0.70 Taux de prediction Taux de prediction 0.9 0.65 0.8 0.7 0.60 0.6 0.55 0.5 0.50 0.4 0.3 0.45 0.2 0.0 0.5 1.0 1.5 2.0 2.5 3.0 0.401 2 3 4 5 6 7 Niveau de bruit Fraction utile du cadre
  • 11. 1 Les vrais donn´es sont pourries e http://cswww.essex.ac.uk/mv/allfaces 100 individus, 10 photos par individu, ` peu pr`s align´es a e e
  • 12. 1 Validation crois´e e 1 Choisir une fraction des photos pour les visages connus (jeu d’apprentissage). 2 Apprendre les visages typiques et la fonction de pr´diction dessus. e 3 Tester la pr´diction en essayant de nommer les e photos non utilis´es pour l’apprentissage (jeu de e test) et en mesurant le taux d’erreur.
  • 13. 1 Du code : scikit-learn Objets avec fit/predict prenant des tableaux numpy e = E s t i m a t o r () e . f i t ( k n o w n f a c e s , known names ) guessed names = e. p r e d i c t ( unkown faces ) G´n´rateurs de validation crois´e renvoyant des masques e e e from s c i k i t s . l e a r n import c r o s s v a l c v = c r o s s v a l . S t r a t i f i e d K F o l d ( names ) for t r a i n , t e s t in c v : e . f i t ( f a c e s [ t r a i n ] , names [ t r a i n ]) e . p r e d i c t ( f a c e s [ t e s t ]) Ingr´dients de base d’un framework d’apprentissage e
  • 14. 1 Au final : .5% d’erreur de pr´diction e Utiliser les k plus proches voisin (kNN) : import numpy a s np from s c i k i t s . l e a r n import c r o s s v a l from s c i k i t s . l e a r n . n e i g h b o r s import N e i g h b o r s c v = c r o s s v a l . S t r a t i f i e d K F o l d ( l a b e l s , k =5) e = N e i g h b o r s ( k =5) e r r o r s = c r o s s v a l . c r o s s v a l s c o r e (e , data , l a b e l s , cv = cv ) print ’ score ’ , np . sum ( e r r o r s ) / f l o a t ( l e n ( d a t a ) ) Choisir k pour optimiser le score. Attention 2 boucles imbriqu´es de validation crois´e e e 1 choisir k 2 ´valuer l’erreur sur des donn´es inconnues e e
  • 15. 2 R´sumer – e scikit-learn
  • 16. 2 R´duire la taille des donn´es e e Botte de foin : la taille des donn´es nuit ` la e a performance Les images contiennent beaucoup d’information redondante Comment la r´duire de facon optimale ? e ¸
  • 17. 2 Former des groupes Pays associ´s ` une devise majeure e a La corr´lation des taux de changes fournit e une mesure d’affinit´e
  • 18. 2 Former des groupes Qui se ressemble s’assemble
  • 19. 2 Former des groupes sur une image Lena 4 8 16 32
  • 20. 2 Former des groupes sur les 1000 visages k=30 k=50 k=100 k=200 Choisir k pour maximiser la pr´diction e (encore une boucle de validation crois´e) e
  • 21. 2 scikit-learn Apprentissage statistique en Python Efficace Bons algorithmes, numpy + scipy, C + Cython + Python Pythonesque License BSD, objets simples, pas de d´pendences autres que numpy + scipy e Facile ` utiliser a API uniforme, documentation, paramˆtres par d´fault e e
  • 22. ˆ 3 Etre fain´ant (et efficace) – e joblib
  • 23. ´ 3 Evaluation fain´ante e On calcule toujours la mˆme chose e Boucles de imbriqu´es avec transformations e successives Calculs en variant les paramˆtres e Difficult´s e Connaˆ les d´pendances entre les ´tapes ıtre e e Suivre les paramˆtres e ´ Evaluation fain´ante : ne pas recalculer ce e qu’on a d´j` calcul´ ea e
  • 24. 3 pipeline/data flow programming
  • 25. 3 joblib Philosophie Simple ne changez pas vos programmes n’apprenez pas de nouveau paradigmes Minimal pas de d´pendances, embarquable e peu de fonctionnalit´s e Performant grosses donn´es e calcul parall`le e Robuste tol´rant aux erreurs e debuggable
  • 26. 3 joblib ´ Evaluation fain´ante e >>> from j o b l i b import Memory >>> mem = Memory ( c a c h e d i r = ’/ tmp / joblib ’) >>> import numpy a s np >>> a = np . v a n d e r ( np . a r a n g e (3) ) >>> s q u a r e = mem. c a c h e ( np . s q u a r e ) >>> b = square (a) [ Memory ] C a l l i n g s q u a r e ... s q u a r e ( a r r a y ([[0 , 0 , 1] , [1 , 1 , 1] , [4 , 2 , 1]]) ) s q u a r e - 0.0 s >>> c = s q u a r e ( a ) >>> # Pas de re - evaluation
  • 27. 3 joblib ´ Evaluation fain´ante e Hash MD5 des paramˆtres d’entr´es (efficace) e e ⇒ pas de mod`le de donn´es et d’ex´cution e e e Stockage sur disk dans des r´pertoires s´par´s e e e (efficace – memmap) Table globale sqlite (verrous :( ) Nettoyage de cache ` la vol´e (beta) a e
  • 28. 3 joblib Calcul parall`le e >>> from j o b l i b import P a r a l l e l , d e l a y e d >>> from math import s q r t >>> P a r a l l e l ( n j o b s =1) ( d e l a y e d ( s q r t ) ( i **2) ... for i in r a n g e (7) ) [0.0 , 1.0 , 2.0 , 3.0 , 4.0 , 5.0 , 6.0 , 7.0] La syntaxe est importante Le d´bugage aussi e ⇒ Fork agressif
  • 29. 3 joblib Le futur Meilleur branchement parall`le/memoire e Meilleurs bases de donn´es/datastore e 2 niveaux de cache (m´moire/disk) e Suivit d’ex´cution e
  • 30. 3 Traitement de donn´es performant. . . e Scikit Learn : Algorithmes ´tat de l’art e Projet jeune joblib Mieux calculer Pas que scientifique http://scikits-learn.sf.net http://packages.python.org/joblib