Using scikit-learn for Machine Learning
The reason MKL matters to a scikit-learn user is performance.
The Setup Problem Behind Machine Learning in Python
Imagine you want to do machine learning in Python on a computer that has no scientific Python tools yet. You would need a numerical computing library, a library for scientific algorithms, plotting tools, data-handling tools, an interactive environment for experiments, and finally scikit-learn itself. Each of these could be installed on its own, but the choices and the order of installation quickly become a chore.
This article looks at one way around that problem: a single Python distribution called Anaconda, which arrives with most of these tools already in place. As you read, keep one question in mind: what does it mean for a distribution to already contain the packages you need, and what does that save you from doing?
What Anaconda Is Designed For
Anaconda is a Python distribution made for large-scale data processing, predictive analytics, and scientific computing, available on Mac OS, Windows, and Linux.
The word distribution is the key idea. When you install Anaconda, you are not installing one program. You are installing a container that holds several components at once, so that every component beneath it arrives as part of that single installation. Because it is offered on Mac OS, Windows, and Linux, the same bundle idea applies across the three major desktop platforms.
Tracing What One Installation Contains
Think of the installation as a set of layers. The distribution sits at the top, and the packages that scikit-learn depends on and works alongside sit beneath it. The source names seven packages that come with Anaconda: NumPy, SciPy, matplotlib, pandas, IPython, Jupyter Notebook, and scikit-learn. These cover different roles, from numerical arrays to plotting to interactive work, and all of them are present after one installation.
What do you think happens?
You install only Anaconda on a clean machine and nothing else. Is scikit-learn available afterward?
Reveal answer
Yes, it is included
The source lists scikit-learn among the packages that come with one Anaconda installation, so one installation delivers it along with the other six named packages.
Separate Installs Versus One Bundle
Compare the two routes to a working machine learning setup. In the manual route, you must first decide on each library, work out an order in which to install them, and then install scikit-learn last. In the Anaconda route, you install one distribution, and the packages it contains are already in place. The steps differ mainly in how many separate decisions you have to make.
| Question | Separate installs | Anaconda bundle |
|---|---|---|
| How many packages must you pick? | Each one, individually | Covered by the distribution |
| Is order a concern? | Yes, you must work it out | The bundle is installed as one unit |
| Where does scikit-learn come from? | A separate install step | Included in the installation |
| Is Intel MKL included? | Not part of the manual route described in the source | Included, and used automatically |
The bundle replaces a series of choices with one installation
Where Intel MKL Fits in the Call Path
Anaconda also includes the Intel MKL library. The source describes it as commercial software that is provided for free within Anaconda. You do not choose to add it, and using it happens automatically when Anaconda is installed.
The reason MKL matters to a scikit-learn user is performance. The source states that using MKL can give significant speed improvements for many algorithms in scikit-learn. Read the chain from left to right: an algorithm you call in scikit-learn runs, and the Intel MKL library, included in Anaconda, works on the algorithms that scikit-learn runs. The source does not give further detail on the internal mechanism, so this article does not go beyond that relationship.
What do you think happens?
Do you have to take a separate step to turn on Intel MKL after installing Anaconda?
Reveal answer
No, it is used automatically on installation
The source says using MKL happens automatically when Anaconda is installed, so there is no extra choice for the learner to make.
Deciding When Anaconda Fits Your Setup
The source gives one clear rule: Anaconda is suggested for people who do not already have an installation of the scientific Python packages. You can turn that into a short sequence of checks. Work through them in order and stop at the first answer that settles the matter.
- 1Check whether the scientific Python stack, including NumPy, SciPy, matplotlib, pandas, IPython, Jupyter Notebook, and scikit-learn, is already installed on the machine.
- 2If the stack is not there yet, Anaconda is the suggested starting point, because it is aimed at exactly that situation.
- 3If the stack is already installed, Anaconda is not required by the source's recommendation, and you can decide on the basis of your own setup.
- 4Confirm the platform: Anaconda is offered for Mac OS, Windows, and Linux.
Applying the checks to a new laptop
A learner has a new laptop on Windows with Python but none of the scientific packages. They want to run scikit-learn experiments in a notebook. Should they start with Anaconda?
- 1Check the installed stack
The scientific packages are not yet on the machine, so the situation matches the one Anaconda is aimed at.
- 2Check the platform
Windows is one of the platforms Anaconda is offered for.
- 3Check the goal
The learner wants an interactive environment for experiments. Anaconda includes IPython and Jupyter Notebook, which the source names among its packages.
Anaconda is a sensible starting point for this learner, because it supplies scikit-learn and the supporting tools in one installation.
A colleague already has NumPy, SciPy, matplotlib, pandas, IPython, Jupyter Notebook, and scikit-learn installed on their own Linux machine. Using the source's guidance, is Anaconda the suggested starting point for them? Explain your reasoning in terms of the phrase already have.
Hints
- Look at the phrase already have in the source's recommendation.
- The source aims Anaconda at people who do not yet have the scientific stack.
Mistakes Learners Make About Anaconda
Common mistake Treating Anaconda as one program rather than a distribution
Why it failsThe source describes a container that holds several components at once, not a single application.
Do this insteadThink of the installation as delivering a set of packages, including NumPy, SciPy, matplotlib, pandas, IPython, Jupyter Notebook, and scikit-learn.
Common mistake Assuming Intel MKL must be chosen and installed separately
Why it failsThe source says MKL is included in Anaconda and used automatically on installation.
Do this insteadExpect MKL to be part of the Anaconda installation without an extra selection step.
Common mistake Recommending Anaconda to everyone regardless of existing setup
Why it failsThe source specifically recommends Anaconda for people who do not already have an installation of the scientific Python packages.
Do this insteadCheck first whether the scientific stack is already present before deciding.
Common mistake Believing MKL guarantees a speed-up for every operation (the source says significant speed improvements for many algorithms, not all)
Checking Your Understanding
Key Takeaways
- Anaconda is a Python distribution for large-scale data processing, predictive analytics, and scientific computing, available on Mac OS, Windows, and Linux.
- One Anaconda installation includes NumPy, SciPy, matplotlib, pandas, IPython, Jupyter Notebook, and scikit-learn, so you do not install each one separately.
- Anaconda includes the commercial Intel MKL library for free, and it is used automatically on installation; the source reports significant speed improvements for many scikit-learn algorithms.
- Anaconda is suggested for people who do not already have an installation of the scientific Python packages.