The Vision, The Tool, and The Project: Scikit
The Vision, The Tool, and The Project: Scikit
scikit
G Varoquaux 2
1 Scikit-learn: the vision
An enabler
G Varoquaux 2
1 Scikit-learn: the vision
An enabler
Machine learning
for everybody and
for everything
Machine learning
without learning the
machinery
G Varoquaux 2
Machine learning in a nutshell
G Varoquaux 3
1 Machine learning: a historical perspective
Artificial Intelligence The 80s
Building decision rules
Eatable?
Tall?
Mobile?
G Varoquaux 4
1 Machine learning: a historicalperspective
Artificial Intelligence The 80s
Building decision rules
Machine learning The 90s
Learn these from observations
G Varoquaux 4
1 Machine learning: a historicalperspective
Artificial Intelligence The 80s
Building decision rules
Machine learning The 90s
Learn these from observations
Statistical learning 2000s
Model the noise in the observations
G Varoquaux 4
1 Machine learning: a historicalperspective
Artificial Intelligence The 80s
Building decision rules
Machine learning The 90s
Learn these from observations
Statistical learning 2000s
Model the noise in the observations
Big data today
Many observations,
simple rules
G Varoquaux 4
1 Machine learning: a historicalperspective
Artificial Intelligence The 80s
Building decision rules
Machine learning The 90s
Learn these from observations
Statistical learning 2000s
Model the noise in the observations
Big data today
Many observations,
simple rules
“Big data isn’t actually interesting without machine
learning”
Steve Jurvetson, VC, SiliconValley
G Varoquaux 4
1 Machine learning in a nutshell: anexample
Face recognition
G Varoquaux 5
1 Machine learning in a nutshell: anexample
Face recognition
G Varoquaux
? 5
1 Machine learning in a nutshell
A simple method:
1 Store all the known (noisy) images and the names
that go with them.
2 From a new (noisy) images, find the image that is
most similar.
G Varoquaux 6
1 Machine learning in a nutshell
A simple method:
1 Store all the known (noisy) images and the names
that go with them.
2 From a new (noisy) images, find the image that is
most similar.
G Varoquaux 6
1 Machine learning in a nutshell: regression
A single descriptor:
one dimension
y
G Varoquaux 7
1 Machine learning in a nutshell: regression
A single descriptor:
one dimension
y
y
x x
G Varoquaux 7
1 Machine learning in a nutshell: regression
A single descriptor:
one dimension
y
y
x x
Problem of “over-fitting”
Minimizing error is not always the best strategy
(learning noise)
Test data ƒ= train data
G Varoquaux 7
1 Machine learning in a nutshell: regression
A single descriptor:
one dimension
y
y
x x
y
Bias variance tradeoff
x x
y
y
X_2
x
X_1
More parameters
G Varoquaux 7
1 Machine learning in a nutshell: regression
A single descriptor: Two descriptors:
one dimension 2 dimensions
y
y
X_2
x
X_1
More parameters
⇒ need moredata
“curse of dimensionality”
G Varoquaux 7
1 Machine learning in a nutshell: classification
Example:
recognizing hand-written digits
G Varoquaux 8
1 Machine learning in a nutshell: classification
X1
Example:
recognizing hand-written digits
X2
G Varoquaux 8
1 Machine learning in a nutshell: classification
X1
X2
G Varoquaux 8
1 Machine learning in a nutshell: classification
X1
X2
G Varoquaux 8
1 Machine learning in a nutshell: models
1 staircase
G Varoquaux 9
1 Machine learning in a nutshell: models
1 staircase
2 staircases c o m b i n e d
G Varoquaux 9
1 Machine learning in a nutshell: models
1 staircase
2 staircases c o m b i n e d
3 staircases c o m b i n e d
G Varoquaux 9
1 Machine learning in a nutshell: models
1 staircase
2 staircases c o m b i n e d
3 staircases c o m b i n e d
3 0 0 staircases c o m b i n e d
G Varoquaux 10
1 Machine learning in a nutshell: unsupervised
G Varoquaux 10
Machine learning
Regression Classification
y
Unsupervised...
x
Image recognition
Medical data
Language translation
G Varoquaux 12
Why another machine learning package?
G Varoquaux 13
Real statisticians use R
And real astronomers use IRAF
G Varoquaux 15
1 My stack
G Varoquaux 15
1 My stack
G Varoquaux 15
1 My stack
G Varoquaux 15
1 scikit-learn vision
Community-driven development
BSD licensed, very diverse contributors
http://scikit-learn.org
G Varoquaux 16
1 Between research and applications
In the field
Tried and tested (aka boring) is good
Little sophistication from the user
API is more important than maths
§cTheodore W. Gray
G Varoquaux 18
2 A Python library
As easy as py
f r om s k l e a r n i mpor t svm
c l a s s i f i e r = svm.SVC()
c l a s s i f i e r . f i t ( X t r a i n , Y t r a i n)
Y t e s t = c l a s s i f i e r . p r e d i c t ( X t es t )
G Varoquaux 19
2 API: specifying a model
from s k l ea r n . n ei g h b o r s import
K N ea r es t N ei g h b o r s
es t i m a t o r = K N ea res t N ei g h b o rs (
n n ei g h b o r s =2)
G Varoquaux 20
2 API: training a model
with:
X a numpy array with shape
nsamples ×nfeatures
y a numpy 1D array, of ints or float, with shape
nsamples
G Varoquaux 21
2 API: using a model
G Varoquaux 22
2 Vectorizing
G Varoquaux 23
2 Vectorizing
From raw data to a sample matrix X
X = h a s h er . f i t t r a n s f o r m (documents )
G Varoquaux 23
2 Scikit-learn: very rich feature set
Supervised learning
Decision trees (Random-Forest, Boosted Tree)
Linear models
SVM
Unsupervised Learning
Clustering
Dictionary learning
Outlier detection
Model selection
Built in cross-validation
Parameter optimization
G Varoquaux 24
2 Computational performance
Algorithmic optimizations
G Varoquaux 25
2 Computational performance
Random Forest fit time
scikit-learn mlpy pybrain pymvpa mdp shogun
14000
Scikit-Learn-RF 13427. 06
SVM 12000
Scikit-Learn-ETs randomForest
5.2
OpenCV-RF
OpenCV-ETs
9.47 17.5 11.52
R, Fortran 40.48 5.63
LARS OK3-RF
1.17
OK3-ETs 105.3 - 37.35 -
10941. 72 -
Elastic Net -
We ka -RF Orange
10000
0.52
R-RF
Orange-RF
73.7 - 1.44 -Python
kNN 0.57 1.41 - 0.56 0.58 1.36
8000
Fit tim e (s)
Algorithmic
4000 optimizations 3342.83
OK3
C Weka
Mi nimizing
2000
data copies
Scikit-Learn 1518.14 1711.94 Java
1027.91
Python, Cython
203.01 211.53
0
Figure: Gilles Louppe
G Varoquaux 25
What if the data does not fit in memory?
“Big data”:
Petabytes...
Distributed storage
Computing cluster
G Varoquaux 26
What if the data does not fit in memory?
“Big data”:
Petabytes... Mere mortals:
Distributed storage Gigabytes...
Computing cluster Python programming
Off-the-self computers
G Varoquaux 27
2 On-line algorithms
es t i m a t o r . p a r t i a l f i t ( X t r a i n , Y t r a i n )
Linear models
sklearn.linear model.SGDRegressor
sklearn.linear model.SGDClassifier
Clustering
sklearn.cluster.MiniBatchKMeans
sklearn.cluster.Birch (new in 0.16)
PCA (new in 0.16)
sklearn.decompositions.IncrementalPCA
G Varoquaux 27
2 On-the-fly data reduction
Many features
X s m a l l = es t i m a t o r . t r a n s fo r m ( X big , y)
G Varoquaux 28
2 On-the-fly data reduction
Random projections (will average features)
sklearn.random projection
random linear combinations of the features
G Varoquaux 28
3 Scikit-learn: the project
G Varoquaux 29
3 Having an impact
G Varoquaux 30
3 Having an impact
G Varoquaux 30
3 Having an impact
G Varoquaux 30
3 Having an impact
1% of Debian installs
1200 job offers on stackoverflow
G Varoquaux 30
3 Having an impact
1% of Debian installs
1200 job offers on stackoverflow
G Varoquaux 30
3 Community-based development inscikit-learn
Huge feature set:
benefits of a large team
Project growth:
G Varoquaux 31
3 Many eyes makes code fast
1 Focus on quality
2 Build great docs and examples
3 Use github
4 Limit the technicality of your codebase
5 Releasing and packaging matter
6 Focus on your contributors,
give them credit, decision power
http://www.slideshare.net/GaelVaroquaux/
scikit-learn-dveloppement-communautaire
G Varoquaux 33
3 Quality assurance
Code review: pull requests
Can include newcomers
Everything is discussed:
- Should the algorithm go in?
- Are there good defaults?
- Are names meaningfull?
- Are the numerics stable?
- Could it be faster?
G Varoquaux 34
3 Quality assurance
Unit testing
Everything is tested
If it ain’t tested
it’s broken
G Varoquaux 35
Make it work, make it right, make it boring
G Varoquaux 36
3 The tragedy of the commons
Individuals, acting independently and rationally accord-
ing to each one’s self-interest, behave contrary to the
whole group’s long-term best interests by depleting
some common resource.
Wikipedia
@GaelVaroquaux
Scikit-learn
The vision
Machine learning as a means not an end
The tool
Simple API uniform across learners
Numpy matrices as data containers
Reasonnably fast
@GaelVaroquaux
Scikit-learn
The vision
Machine learning as a means not an end
The tool
Simple API uniform across learners
The project
Many people working together
Tests and discussions for quality
We’re hiring!
@GaelVaroquaux