Machine learning allows computers to find hidden insights without being explicitly programmed where to look or what to look for.
Thanks to the work of some dedicated developers, Python has one of the best machine learning platforms out there called Scikit-Learn.
In this episode, Alexander Gramfort is here to tell us about Scikit-Learn and machine learning.
This is Talk Python to Me, number 31, recorded Friday, September 25, 2015.
I'm a developer in many senses of the word, because I make these applications, but I also use these verbs to make this music.
I construct it line by line, just like when I'm coding another software design.
In both cases, it's about design patterns. Anyone can get the job done, it's the execution that matters.
I have many interests, sometimes conflict, but creativity can usually be a benefit.
Welcome to Talk Python to Me, a weekly podcast on Python, the language, the libraries, the ecosystem, and the personalities.
This is your host, Michael Kennedy. Follow me on Twitter, where I'm @mkennedy.
Keep up with the show and listen to past episodes at talkpython.fm, and follow the show on Twitter via at Talk Python.
This episode is brought to you by Hired and Codeship.
Thank them for supporting the show on Twitter via at Hired underscore HQ and at Codeship.
Hey, everyone. Thanks for listening today.
Let me introduce Alexander so we can get right to the interview.
Alexander Grandfort is currently an assistant professor at Telecom Paris Tech and scientific consultant for the CEA Neurospin Brain Imaging Center.
His work is on statistical machine learning, signal and image processing optimization, scientific computing, and software engineering with a primary focus in brain functional imaging.
Before joining Telecom Paris Tech, he worked at the Martino Center for Biomedical Imaging at Harvard in Boston.
He's also an active member for the Center for Data Science at Université Paris-Saclay.
Alexander, welcome to the show.
Thank you. Hi.
Hi. I'm really excited to talk about machine learning and Scikit-learn with you today.
It's something I know almost nothing about, so it's going to be a great chance for me to learn along with everyone else who's listening in.
So hopefully I'll be able to give relevant answers.
Yeah, I'm sure that you will.
All right, so we're going to talk all about machine learning, but before we get there, let's hear your story.
How did you get into programming in Python?
Well, I've done a lot of scientific computing and scientific programming over the last maybe 10 to 15 years.
I started my undergrad in computer science, doing a lot of signal and image processing.
Well, like these types of people, I've done a lot of MATLAB in my previous life.
Yes, I've done a lot of MATLAB too. I know about the .im files.
And I switched to a team for my postdoc.
Basically, I did a PhD in computer science applied to brain imaging.
And I switched to a different team where basically I was surrounded by people working with Python.
And basically, I got into it and switched.
In one week, MATLAB was gone from my life.
But it's been maybe five years now.
And yeah, that's kind of the historical part.
Do you miss MATLAB?
Not really.
Me either.
There are some cool things about it, but...
Yeah, I still have students that are insisting to work with me in MATLAB.
So I have to still do stuff in MATLAB for supervision.
But not really when I have the choice.
Yeah, if you get a choice, of course.
I think one of the things that's really a drawback about specialized systems like MATLAB is it's very hard to build production finished products.
You can do research.
You can learn.
You can write papers.
You can even test algorithms.
But if you want to get something that's running on data centers on its own, probably MATLAB is, you know, you could make it work, but it's not generally the right choice.
Definitely.
Yeah.
And so things like, you know, I think that explains a lot of the growth of Python in this whole data science, scientific computing world, along with great toolkits like scikit-learn, right?
Yes.
I mean, definitely the way scikit-learn is now used.
The fact that the Python stack allows you to make this production type of code is a clear win for everyone.
So before we get into the details of scikit-learn and how you work with it and all the features it has, let's just, you know, in a really broad way, talk about machine learning.
Like, what is machine learning?
I would say the simple example of machine learning is trying to predict something from previous data.
So what people would call supervised learning.
And there are plenty of examples of this in everyday life, like your mailbox that predicts for you if your email is a spam or a ham.
And that's basically a system that learns from previous data how to make an informed choice and give you a prediction.
And that's basically the most simple way of seeing machine learning.
And basically you see machine learning problems framed this way in all contexts, from industry to academic science.
And, I mean, there are many examples.
And basically, in terms of other types of classes of problems that you see in machine learning, it's not really these prediction problems.
We're trying to make sense from raw data where you don't have labels like spam or ham, but you just have data and you want to figure out what's the structure, what types of input or insight can you get from it.
And that's, I would say, the other big class of problem that machine learning addresses.
Yeah, so there's that general classification.
I guess with the first category you were talking about, like spam filters and other things that maybe fall into that realm would be like credit card fraud, maybe trading stocks, these kind of binary, do it, don't do it, based on examples.
That's something that is, is it called structured learning or what's the?
The common name is supervised learning.
Supervised learning, that's right.
Yeah, so basically you have pairs of training observations that are the data and their corresponding labels.
So text and the label would be spam or ham.
Or you can also see, this is basically binary classification.
The other types of machine learning problems you have is, for example, regression.
You want to predict the price of a house and you know the number of square feet.
You know the number of rooms.
You know what's exactly the location.
And so you have a bunch of variables that describe your house or apartment.
And from this you want to predict the price.
And that's another example where now it seems the price is a continuous variable.
It's not binary.
This is what people call regression.
And this is another big class of supervised learning problem.
Right.
So you might know through the real estate data, all the houses in the neighborhood that have sold in the last two years, the ones that have sold last month, all their variables and dimensions, if you will, like number of bathrooms, number of bedrooms, square feet, or square meters.
You could feed it into the system to train it.
And then you could say, well, now I have a house with two bathrooms and three bedrooms.
And right here, what's it worth?
Right?
Exactly.
That's basically a typical example and also a typical data set that we use in Scikit-learn that basically illustrates the concept of regression with a similar problem.
Right.
There's, we'll talk more about it, but there's a Scikit-learn comes with some pre-built data sets.
And one of them is the Boston house market, right?
Exactly.
That's the one.
Yeah.
How much data do you have to give it?
Like, suppose I want to try to estimate the value of my house, which, you know, at least in the United States, we have this service called Zillow.
So they're doing way more.
I'm sure they're running something like this, actually.
But suppose I wanted to take it upon myself to, like, grab the real estate data and try to estimate the value of my home.
How many houses would I have to give it before it would start to be reasonable?
Well, that's a tough question.
And I guess there's no simple answer.
I mean, you have this, that you can see on the cheat sheets of Scikit-learn that says if you have less than 50 observations, then go get more data.
But I guess it's also a simplified answer.
It depends on the difficulty of the task.
So at the end of the day, often for these types of problems, you want to know something.
And this can be easy or hard.
You cannot really know before trying.
And typically regression would say, okay, if I predict that the 10% plus or minus, that's maybe good enough for my application.
And maybe you need less data.
If you want to be super accurate, you need more data.
But the question of how much is, it's really hard to answer without really trying and using actual data.
Yeah, I can imagine.
It probably also depends on the variability of the data, the accuracy of the data, how many variables you're trying to give it.
So if you just added, just tried to base it on square footage or square meters of your house, that one variable, maybe it's easier to predict than, you know, 20 components that describe your house, right?
So the thing, the more variables you have, the more you can hope to get.
Now it's not as simple as this, because if variables are not informative, then they're basically adding noise to your problem.
So you want as many variables to describe your data in order to capture the weak signals.
But sometimes just variables are not relevant or predictive.
And so there are more, you want to remove them from the prediction problem.
Okay, that makes sense.
So I was looking into what are some of the novel uses of machine learning in order to sort of have some things to ask you about and just see what's out there.
What are ones that come to mind for you?
And then I'll give you some that I found on my list.
Maybe I'm biased because I'm really into using machine learning for scientific data and academic problems.
But I guess for things that are really academic breakthrough that are reaching everybody is really related to computer vision and NLP these days and probably also speech.
So these types of systems that try to predict something from speech signals or from images like describing you what's the contents, what types of objects you can find.
And for NLP you have like machine translation.
We did a show with OpenCV and the whole Python angle there.
There was a lot of really cool stuff on medical imaging going on there.
Does that have to do with scikit-learn as well?
Well, you have people doing medical imaging using scikit-learn, basically extracting features from MR images, magnetic resonance images, or CT scanners, or also like EEG brain signals.
And they're using EEG – sorry, they're using scikit-learn as the prediction tool, deriving features from their raw data.
And that reaches, of course, clinical applications in some contexts.
Maybe automatic systems that say, hey, this looks like it could be cancer or it could be some kind of problem, bring the attention of an expert who could actually look at it and say, yes, no, something like this?
Yeah, exactly.
It's like helping diagnosis, like trying to help the clinician to isolate something that looks weird or suspicious in the data to get like the time of this physicist and the clinician onto this particular part of the data to see what's going on and if the patient is suffering for something.
Right.
That's really cool.
I mean, maybe you could take previous biopsies and invasive things that have happened to other people and their pictures and their outcomes and say, look, you have basically the same features and we did this test and the machine believes that you actually don't have a problem.
So, you know, probably don't worry about it.
We'll just watch this or something like that, right?
Yeah, I mean, on this line of thought, there was recently a Kaggle competition using retina pictures.
So, like people suffering from diabetes usually have problems with retinas.
And so, you can take pictures of retinas from hundreds of people and see if you can build a system that predicts something about the patient and the state of the disease from these images.
And this is typically done by pooling data from multiple people.
That's really cool.
I've heard this Kaggle competition or challenges before in various places looking at it.
What is that?
So, it's basically a website that allows you to organize these types of supervised learning problems where a company or a structure, NGO, whatever, is having data and is trying to build a system, a predictive system.
And they ask Kaggle to set this up, which basically means for Kaggle putting the training data set online and giving this to data scientists.
And they basically then spend time building a predictive system that is evaluated on new data on which to get a score.
And that allows you to see how the system works on new data and to rank basically the data scientists that are playing with the system.
It's kind of an open innovation approach in data science.
That's really cool.
So, that's just Kaggle.com.
Yes.
K-A-G-G-L-E.com.
Exactly.
Yeah.
Very nice.
Some of the other ones that I sort of ran across while I was looking around that were pretty cool was one is some guys at Cornell University built machine learning algorithms to listen for the sound of whales in the ocean and use them in real time to help ships avoid running into whales.
That's pretty awesome, right?
Yeah.
There was a Kaggle competition on these whale sounds maybe a couple of years ago.
And it was a – I mean, not many data scientists have experienced, like, listening to whales.
So, it's kind of everybody doesn't really know what types of data.
And I remember this presentation from the winner basically saying how to win a Kaggle competition without knowing anything about the data.
It's kind of a provocative talk.
That is cool.
But showing how you can basically build a predictive system by just looking at the data and trying to make sense out of it without really being an expert in the field.
Yeah.
That's probably a really valuable skill as a data scientist to have, right?
Because you can be an expert, but not in everything.
Some other ones that were interesting was IBM was working on something to look at the handwritten notes of physicians.
Uh-huh.
And then it would predict whether – how likely the person that those notes were about would have a heart attack.
Yeah.
In the clinical world, it's true that a lot of information is actually raw text, like manual, like just written notes, but also raw text on the system.
For machine learning, that's a particularly difficult problem because it's what we call unstructured data.
So you need to – typically for scikit-learn to work on these types of data, you need to do something extra to basically come up with a structure or come up with features that allow you to predict something.
Sure.
And so both of those two examples that I brought up have really interesting data origin problems.
So if I give you an MP3 of a whale or an audio stream of a whale, how do you turn that into numbers that go into the machine even to train it?
And then similarly with handwriting, how do you – you've got to do handwriting recognition.
You've got to then do sort of understanding what the handwriting means.
And there's a lot of levels.
How do you take this data and actually get it into something like scikit-learn?
So scikit-learn expects that every observation, we also call it a sample or a data point, is basically described by a vector, like a vector of values.
So if you take the sound of the whale, you can say, okay, there's a sound in the MP3, it's just a set of floating point values, like every time sample, really time domain signals that you get for a few seconds of data.
It's probably not the best way to get a predictive – a good predictive system.
You want to do some feature transformation, change the input to get something that brings features that are more powerful for scikit-learn and the learning system.
And you would typically do this with time-frequency transform, things like spectrograms, trying to extract features that are really, for example, invariant to some aspects of the day, like frequencies or time shifts.
So there's probably a bit of pre-processing to do on these row signals.
And then once you have your vector, you can use the scikit-learn machinery to build your predictive system.
How much of that pre-processing is in the tool set?
So it depends for what types of data.
Typically for signals, there's nothing really specific in scikit-learn.
You would probably use scipy signal or any types of signal processing Python code that you find online.
I would say for other types of data, like text, in scikit-learn, there are something that is called feature extraction module.
And you have – in the feature extraction module, you have something for text, which is probably the biggest part of the feature extraction is really text processing.
And you have some stuff also for images, but it's quite limited.
We should probably introduce what scikit-learn is and get into the details of that.
But I have one more sort of example to let people know about that I think is pretty cool.
On show 16, I talked to Roy Rappaport from Netflix.
And Netflix has a tremendously large cloud computing infrastructure to power all of their – you know, basically their movie system, right?
And everything behind the scenes there.
And they have so many virtual machine instances and services running on them and then different types of devices, accessing services on those machines that they said it's almost impossible to determine if there's, you know, some edge case where there's a problem manually.
And so they actually set up machine learning to monitor their infrastructure and then tell them if there's some kind of problem in real time.
Yeah.
So I think that's really a cool use of it as well.
This episode is brought to you by Hired.
Hired is a two-sided, curated marketplace that connects the world's knowledge workers to the best opportunities.
Each offer you receive has salary and equity presented right up front, and you can view the offers to accept or reject them before you even talk to the company.
Typically, candidates receive five or more offers in just the first week, and there are no obligations ever.
Sounds pretty awesome, doesn't it?
Well, did I mention there's a signing bonus?
Everyone who accepts a job from Hired gets a $2,000 signing bonus.
And as Talk Python listeners, it gets way sweeter.
Use the link Hired.com slash Talk Python to me, and Hired will double the signing bonus to $4,000.
Opportunity's knocking.
Visit Hired.com slash Talk Python to me and answer the call.
Yeah, that's a very cool thing to do.
And actually, many industries and many companies are looking for these types of systems that they call anomaly detection or failure prediction.
And it's getting a big use case for machine learning, indeed.
The Netflix guys were actually using Scikit-learn, not just some other machine learning system.
So let's get to the details of that.
What's Scikit-learn?
Where did it come from?
So Scikit-learn is probably the biggest machine learning library that you can find in the Python world.
So it dates back from almost 10 years ago when David Cornapal was doing a Google Summer of Code to kickstart the Scikit-learn project.
And then for a few years, there was a French guy called Mathieu Broucher who took on the project.
But it was kind of a one-guy project for many years.
And in 2010, with colleagues at INRIA in France, we decided to basically try to start from this state of Scikit-learn and make it bigger and really try to build a community around this.
So these people are Gael Varroco and Fabian Pedregosa and also somebody you may have heard of in the machine learning world with Olivier Grisel.
And so that was pretty much 2010, so five years ago.
And basically it took on pretty quickly.
After, I would say, a year of Scikit-learn, we had more than 10 core developers way beyond the initial lab where it started.
That's really excellent.
Yeah, I mean, it's definitely an absolutely mainstream project that people are using in production these days.
So congratulations to everyone on that.
That's great.
Thank you.
Yeah.
And so the name Scikit-learn comes from the fact that it's basically an extension to the SciPy pieces, right?
So SciPy is like NumPy for numerical processing, SciPy for scientific stuff, Matplotlib, IPython, SimPy for symbolic math, and Pandas, right?
And then there's these extensions.
Yes.
So basically the kind of division is that you cannot put everything in SciPy.
SciPy is already a big project.
And the idea of the SciKits were to build extensions around SciPy that are more domain-specific.
Also, it's kind of also easier to contribute to a smaller project.
So basically the barrier of entry for newcomers is much lower when you contribute to a Scikit than to SciPy, which is a fairly big project now.
Yeah, there's so much support for the whole SciPy system, right?
So it's much better to just build on that than try to duplicate anything and say NumPy or whatever.
Exactly.
I mean, there's a lot of efforts to see what could be NumPy 2.0 and what's going to be the future of it and how to extend it.
I mean, a lot of people are thinking of what's next because, I mean, NumPy is almost 10 years old, probably more than 10 years old now.
And, yeah, people are trying to see also how it can evolve.
Sure.
That makes a lot of sense.
So speaking of evolving and going forward, what are the plans with Scikit-learn?
Where is it going?
So I would say in terms of features, I mean, Scikit-learn is really in the consolidation stage.
Scikit-learn is five years old.
The API is pretty much settled.
There's a few things here and there that are basically that we have to deal with now that basically due to early decisions in terms of API that needs to be fixed.
And I guess the big objective is to basically do Scikit-learn 1.0, like the first stable, fully stable release in terms of API because that's something that we've been talking about between the core developers for, I mean, more than two years now, coming with this 1.0 version that stabilizes every part of the API.
Right.
One final major cleanup, if you can, and then stabilizing it, yeah?
Exactly.
And in terms of new features, I mean, you always have a lot of cool stuff that are around and you see the number of pull requests that are coming on top of Scikit-learn.
It's pretty crazy.
And I would say a huge maintainer's effort and reviewing effort.
So features are coming in slowly now in Scikit-learn, much more slowly than it used to be, but I guess it's normal for a project that is getting big.
Yeah, it's definitely getting big.
It has 7,600 stars and 4,500 forks on GitHub, so that's pretty awesome.
Yeah.
It has 457 contributors.
Cool.
Yeah, I would say for every release we get, I mean, we try to release every six months.
And for every release we get a big number of contributors.
So maybe we could do like a survey of the modules of Scikit-learn, just the important ones that come to mind.
What are the moving parts in there?
So I would say maybe something I know the most, which is a part of the module that I maintain the most, which is the linear model.
And recently the efforts on the linear models were to scale it up.
Basically try to learn this linear models in an out-of-core fashion to be able to scale to data that do not fit in RAM.
And that's part of the, I would say, part of the plan for this linear model module in Scikit-learn.
That's cool.
So what kind of problems do you solve with that?
The types of problems where you have a, like, humongous number of samples and potentially a lot number of features.
So there are not so many applications where you get that many number of samples, but that's typically text or log files.
These types of industry problems where you collect a lot of samples on a regular basis.
You have these examples also if you monitor an industrial system, like if you want to do what we discussed before about, like, predictive maintenance.
That's probably a use case where this can be useful.
Probably the other, like, module that also attracts a lot of effort these days is the Ensemble module, and especially the tree module.
So for models like Random Forest or Gradient Boosting, which are very popular models that have been helping people to win cargo competitions for the last few years.
Yeah, I've heard a lot about these forests and so on.
Can you talk a little bit about what that is?
So a random forest basically is a set of decision trees that you pull together to get a prediction that is more accurate.
More accurate because it has less variance in technical terms.
And the way it works is you try to basically build decision trees from a subset of data, a subset of samples, subset of features in a clever way.
And then you pull all these trees in one big predictive model.
And, for example, if you do binary classification and you train a thousand trees, you ask for a new observation to the thousand trees.
What's the label?
Is it positive or negative?
And then you basically count the number of trees that are saying positive.
And if you have more trees saying positive, then you predict positive.
That's kind of the basic idea of random forest.
And it turns out to be super powerful.
That's really cool.
Well, it seems to me like it would bring in kind of different perspectives or taking different components or parts of a problem into account.
So some of the trees look at some features and maybe the other trees look at other features.
And then they can combine in some important way.
Exactly.
Yeah.
Another one that I see coming up is the SVM module.
What's that one do?
So SVM is a very popular machine learning approach that was basically, I mean, very big in the 90s and 10 years ago and still get some attraction.
And basically, the idea of a support vector machine, which is the SVM is the according for, is to be able to use kernels on the data and basically solve linear problems in an abstract space where you project your raw data.
Let me try to give an example.
If you take a graph or if you take a graph or if you take a string, that's not naturally something that can be represented by a vector.
And when you do an SVM, you have a tool, which is a kernel that allows you to compare these observations, like a kernel between strings, a kernel between graphs.
And once you define this kernel, and this kernel needs to satisfy some properties that I'm going to skip, then you can use this SVM to do classification but also regression.
This is what you have in the SVM module of Seciturn, which is basically a very clever and efficient binding of an underlying library, which is called LibSVM.
Okay, excellent.
And is that used more in the unsupervised world?
It's completely supervised.
When you do SVM, it's classification or regression that's supervised.
There's one use case of SVM in an unsupervised setting, which is what we call the one-class SVM.
So you just have one class, which basically means that you don't have labels, you just have data, and you're trying to see what are the data that are the less like the others.
That's more like an anomaly detection problem, or we call it also novelty detection or outlier detection.
Maybe we could talk a little bit about some of the algorithms.
As a non-expert in sort of the data science machine learning field, I go in there and I see all these cool algorithms and graphs, but I don't really know what would I do with that.
On the site, it says there's all these algorithms it supports.
So, for example, it supports dimensionality reduction.
Like, what kind of problems would I bring that in for?
I guess it's hard to summarize.
The hundreds of hundreds of pages that you have in Scikit-Learn in the documentation, I'm trying to give you a big picture without too much technical detail to tell you when these algorithms are useful and what they are useful for, and what are the hypotheses and what kind of output you can hope to get.
It's one of the strengths of the Scikit-Learn documentation, by the way.
And so to answer your question, dimensionality reduction, I would say like the 101 way of doing it is the principal component analysis, where you're trying to extract subspace that captures the most variance in the data.
And that can be used to do visualization of the data in low dimension.
If you do a PCA in two or three dimensions, then you can look at your observation as a scatterplot in two or three D.
And that's basically visualization.
But you can also use this to reduce the size of your data set, maybe without losing too much predictive power.
So you take your biggest data set, you run a PCA, and then you reduce the dimension.
And then suddenly you have a learning problem, which is on smaller data, because you basically reduce the number of features.
That's kind of the standard approaches, which is like visualization or reducing of the data set to have a more efficient learning in terms of computing time, but also sometimes in prediction problem.
Okay, that makes a lot of sense.
That's really cool.
So like if we went back to my house example, maybe I was feeding like the length of the driveway and the number of trees in the yard.
And it might turn out that neither of those have any effect on house prices.
So we could reduce it to a smaller problem by having this whole PCA go, look, those don't matter.
Throw that part out.
It's really about the number of bathrooms and the square footage or something.
Well, yes and no.
That's kind of the idea.
Okay, but in this example of Boston, the prediction of houses, you want to reduce the dimension in an informed way.
Because the number of trees in the yard can be informative for something, but maybe not to predict the price of the apartment or price of the house.
So when you do dimensionally reduction in the context of supervised learning, that can be also what you call feature selection or basically selecting the predictive features, which ultimately leads to a reduced data set because you remove features.
But that would be in a supervised context.
When you do PCA, you're really in an unsupervised way.
You don't know what are the labels.
You just want to figure out what's the variance.
Where is the variance in the data coming from?
On which axis and which direction should I look to see the structure?
Another thing that is in there are ensemble methods for predicting multiple supervised models.
What's the story there?
That sounds cool.
So random forest is an example of ensemble methods.
When you have an ensemble, it's basically saying that you're taking a lot of classifiers or a lot of regressors and you combine them in a bag of prediction, a bag of models or an ensemble of models.
And then you make them collaborate in order to build a better prediction.
And random forest is basically an ensemble of trees.
But you can also do an ensemble of neural networks.
You can do an ensemble of whatever model you want to pull.
And that turns out to be in practice often a very efficient approach.
Yeah, like we were saying, the more perspectives, different models, it seems like that's a really good idea.
So you mentioned neural networks.
Yes.
So Scikit-Learn has support for neural networks as well?
Well, you have a multilayer perception, which is like the basic neural network.
I mean, these days in neural network, people talk about deep learning.
I've heard about it.
That's about the extent of it.
What's deep learning?
This episode is brought to you by Codeship.
Codeship has launched organizations, create teams, set permissions for specific team members,
and improve collaboration in your continuous delivery workflow.
Maintain centralized control of your organization's projects and teams with Codeship's new organizations plan.
And as Talk Python listeners, you can save 20% off any premium plan for the next three months.
Just use the code TALKPYTHON, all caps, no spaces.
Check them out at CodeChip.com and tell them thanks for supporting the show on Twitter where they're at, CodeChip.
So deep learning is basically neural networks 2.0, where you take neural networks and you stack more layers.
So kind of the story there is that for many years, people were kind of stuck with networks of two or three layers.
So not very deep.
And part of the issue is that it was really hard to train something that would add more layers.
In terms of research, there was two things that came up, which is first that we get access to more data,
which means that we can train bigger and more complex models.
But also there were some breakthrough in learning these models that allowed people to avoid overfitting,
trying to be able to learn this bigish model, these big models, because you have more data,
but also clever ways to prevent overfitting.
And that basically led to deep learning these days.
Oh, very interesting.
Yeah, that's been one of the problems with neural networks, right?
Is that if you teach it too much, then it only knows, you know, just the things you've taught it or something, right?
Exactly.
It basically learns by heart what you provide as trading observations
and end up being very bad when you provide new observations.
Want to talk a little bit about the datasets that come built in there?
Uh-huh.
We've talked a little bit about the Boston one, and that's the Boston house prices for regression.
What I hear coming up a lot is one called Iris.
Is that like your eye itself?
So Iris is the dataset that we use to illustrate all the classification problems.
It's really something that is a very common dataset that turned out to have a good license that we could ship it with scikit-learn,
and basically we built most of the examples using this Iris dataset,
which is also very much used in textbooks of machine learning.
So that was kind of the default choice, and it talks to people because you understand what's the problem that you're trying to do,
and it's rich enough and not too big, so we can make all these examples run super fast and build a nice location.
That's very cool.
What is the dataset?
What exactly is it about?
So the Iris dataset, you're trying to predict the types of plants, for example, using the sepal length, so the sepal width.
So you have a number of features that describe the plant, and you're trying to predict which one among three it is.
So it's a three-label, three-class classification problem.
Yeah, that's cool.
Enough data to not just be a linear model or something, a single variable model, but not too much?
Exactly.
It's not completely linear a bit, but not too hard at the same time.
Right.
If you get 20 variables, that's probably too much to deal with.
Then one is on diabetes.
What about diabetes does that dataset represent?
Do you know?
I'm actually not really sure what's the – no, it's a regression problem.
It's used a lot in the linear model, especially for the sparse regression models because the – I mean, part of these sparse regression models are trying to extract the predictive features.
I guess in the diabetes dataset, you try to find something related to diabetes, and you're interested into finding the most predictive features.
What are the best features?
And then that's part of the reason I think we're using it.
And then another one is digits, which kind of meant to model images, right?
One of the early, I would say, breakthrough of machine learning was this work in the 90s where Yad Lequin and other people were trying to build a system that could predict what was the digit present on the screen or in the image.
So it's a very old machine learning problem where you start from a picture or an image of a digit that is handwritten, and you're trying to predict what it is from zero to nine.
And it's an example that basically people can easily grasp in order to understand what's the machine learning.
You give me an image, and I'll predict something between zero and nine.
And historically, when we did the first version of the scikit-learn website, we had something like seven or eight lines of Python code that were running classification of digits.
So that was kind of the motivation example where we said, okay, scikit-learn is machine learning made easy.
And here it is, an example.
It's ten lines of code classifying digits.
And that was basically the punchline.
Solving this old hard problem in a nice, simple way, right?
Yeah.
You know, lately, there's been a lot of talk about artificial intelligence, and especially from people like Elon Musk and Stephen Hawking,
saying that maybe we should be concerned about artificial intelligence and things like that.
So one of my first questions around this area is, is machine learning the same thing as artificial intelligence?
Depends who you ask.
Okay.
Sure.
No, I mean, AI was basically the early name of trying to teach a computer to do something.
I mean, it dates back from the 60s and 70s, where basically in the US, for example, at MIT, you had labs that are basically called AI labs.
And machine learning is kind of a, I would say, more restricted set of problems that compared to AI,
which is, say, when you do AI and you want to do work with text or linguistic, you want to build a system that understands linguistic.
That would be an AI problem.
But machine learning is kind of a saying, okay, I've got a loss function.
I want to optimize my criteria.
I've got something that I want to train my system on.
And in a sense, you teach a system to learn.
And so you create some kind of intelligence.
But it's not, I would say it's a, I would say simpler thing to say than saying intelligence, which is kind of a hard concept.
That's maybe part of my personal answer to this.
Yeah, no, it's a great answer.
Just from my limited exposure to it, it seems like machine learning is more about classification and prediction,
whereas the AI concept is a, there's a strong autonomous component that is just completely lacking for machine learning.
Yeah, I guess I would say, I would explain it simply like this, exactly.
What things have you seen people using Scikit-learn for that surprised you?
Or like, wow, you guys are doing that?
That's amazing.
So on Scikit-learn, we have this testimonial page where we ask typically companies or institutes that are using Scikit-learn to write a couple of sentences to say, okay, what they're using Scikit-learn for and why they think it's great.
I'm trying to find this.
And I remember there was this, I think, a dating website.
Saying that they were using Scikit-learn to optimize dates between people.
That was great.
That was like a funny one.
That is funny.
So there may be people out there who are married and maybe even babies who are born because of Scikit-learn.
Yeah, that would be great.
I'm going to add this to my resume.
It's awesome.
Matchmaker.
So if people want to get started with Scikit-learn, they're out there listening, they're like, this is awesome.
Where do I start?
What would you recommend for sort of getting into this whole world of machine learning and getting started with Scikit-learn in particular?
They first start with the Scikit-learn website, which is pretty extensive.
But you also have a lot of tutorials that have been given by core devs of Scikit-learn in different conferences like SciPy, EuroSciPy, or PyData events.
And you can find all these videos online.
I'll just tell you, just take some of them and just sit down and just listen and try to do it yourself afterwards.
I mean, for example, in SciPy, you've got tutorials on Scikit-learn that are pretty much a whole day of tutorials, which is hands-on.
And all these are taped.
So you can really look and get the materials online from the tutorial and get started.
Oh, that's excellent.
Yeah, I think it's really amazing these days that there's so many of these videos online that you can...
There's some topic you imagine, like, hey, I want to know this thing in Python.
There's a very good chance that someone gave some kind of conference talk on it and it's online.
Yeah.
Anything you want to give sort of a shout-out to or a final call to action before we sort of wrap things up a bit?
So if you have free time, you like machine learning, come give us a hand to maintain this cool library.
Yeah, absolutely.
Yeah, like I said, there's 457 contributors, but, you know, you guys are looking to stabilize things and move forward.
So I'm sure there's a lot to be done around that.
Yeah.
I mean, basically, you also have two types of contributors.
You have these one-time contributors that are really expert in something that contributes something that is really specific and valuable that gets merged to the main code base.
And you have, I would say, less people that are investing their time to read the code from others, keep their library consistent in terms of API.
And that's really this big reviewing work that I would say.
I would say the historical core devs of scikit-learn are pretty much mostly doing these days and invest little time to do really new stuff that is basically left to the newcomers.
And I think what would be, if I had to wish something for the future is that these people or these one-time contributors also spend a bit of their time to help us maintain the entire library in longer run.
Yeah, that makes sense.
I can see in something like scikit-learn where it's kind of a family of all these different algorithms and little techniques that if you want to add your technique, you just go in there and you do that little bit and you kind of stay out of the rest of the code.
And I can see how that would definitely lead to inconsistencies and so on.
Yeah, and in terms of policy, I mean, in terms of scikit-learn, that's why maybe there's less things that are coming in these days is that we're not trying to build a library that contains all the algorithms that you can ever think of or that get published every year.
We're trying to keep or have the algorithms that are better on some clear use case in the current state of the art.
And so we cannot implement everything, but at least if you have a particular type of problem, you should have something in scikit-learn that does a good job.
So before I let you go, I have two more final questions for you.
So if you're going to open, if you're going to write some Python code, what editor do you open up?
So I've been a big user of TextMate over the years.
And I have to admit, I switched to Sublime recently because I got convinced by my neighbor.
So no Vim or Emacs troll with me.
Yeah, that's cool.
Yeah, I like Sublime Text a lot.
Very nice.
And of all the cool machine learning and Python in general packages out on PyPI, what are some that you think people maybe don't know about that you're like, hey, this is awesome.
You should know about it.
Well, maybe I'm biased because I do a lot of machine learning for brain science.
And so unrelated to scikit-learn per se, but I've been working for the last five years on this project that's called MNE, which allows you to process brain waves and classifying brain states.
Like, for example, build brain-computer interfaces or analyze clinical data of electrophysiology.
That's basically, if you want to play with brain waves, you can check it out.
That's really cool.
And when you say brain-machine interfaces, is it like EEGs and stuff like that?
Exactly.
EEG, MEG.
Yeah.
Okay.
Wow.
Very awesome.
Yeah, I hadn't heard of that one.
That's cool.
So again, I'm biased.
That's more my second baby.
Yeah, that's great.
So, Alexander, it's been really great to have you on the show.
And this has been a super interesting conversation.
Thanks.
Thank you very much.
You bet.
Talk to you later.
This has been another episode of Talk Python to Me.
Today's guest was Alexandra Gramfort.
And this episode has been sponsored by Hired and CodeShip.
Thank you guys for supporting the show.
Hired wants to help you find your next big thing.
Visit Hired.com slash Talk Python to me to get five or more offers with salary and equity presented right up front.
And a special listener signing bonus of $4,000.
CodeShip wants you to always keep shipping.
Check them out at CodeShip.com and thank them on Twitter via at CodeShip.
Don't forget the discount code for listeners.
It's easy.
Talk Python.
All caps.
No spaces.
You can find the links from today's show at talkpython.fm/episodes slash show slash 31.
Be sure to subscribe to the show.
Open your favorite podcatcher and search for Python.
We should be right at the top.
You can also find the iTunes and direct RSS feeds in the footer of the website.
Our theme music is Developers, Developers, Developers by Corey Smith, who goes by Smix.
You can hear the entire song on talkpython.fm.
This is your host, Michael Kennedy.
Thank you very much for listening.
Smix, take us out of here.
Thank you.
Stating with my voice.
There's no norm that I can feel within.
Haven't been sleeping.
I've been using lots of rest.
I'll pass the mic back to who rocked it best.
First of all, first of all.
developers, developers, developers, developers.