Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Mastering Machine Learning with scikit-learn

You're reading from   Mastering Machine Learning with scikit-learn Apply effective learning algorithms to real-world problems using scikit-learn

Arrow left icon
Product type Paperback
Published in Jul 2017
Publisher
ISBN-13 9781788299879
Length 254 pages
Edition 2nd Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Gavin Hackeling Gavin Hackeling
Author Profile Icon Gavin Hackeling
Gavin Hackeling
Arrow right icon
View More author details
Toc

Table of Contents (15) Chapters Close

Preface 1. The Fundamentals of Machine Learning FREE CHAPTER 2. Simple Linear Regression 3. Classification and Regression with k-Nearest Neighbors 4. Feature Extraction 5. From Simple Linear Regression to Multiple Linear Regression 6. From Linear Regression to Logistic Regression 7. Naive Bayes 8. Nonlinear Classification and Regression with Decision Trees 9. From Decision Trees to Random Forests and Other Ensemble Methods 10. The Perceptron 11. From the Perceptron to Support Vector Machines 12. From the Perceptron to Artificial Neural Networks 13. K-means 14. Dimensionality Reduction with Principal Component Analysis

Installing scikit-learn

This book was written for version 0.18.1 of scikit-learn; use this version to ensure that the examples run correctly. If you have previously installed scikit-learn, you can retrieve the version number by executing the following in a notebook or Python interpreter:

# In[1]:
import sklearn
sklearn.__version__

# Out[1]:
'0.18.1'
The package is named sklearn because scikit-learn is not a valid Python package name.

If you have not previously installed scikit-learn, you may install it from a package manager or build it from source. We will review the installation processes for Ubuntu 16.04, Max OS, and Windows 10 in the following sections, but refer to http://scikit-learn.org/stable/install.html for the latest instructions. The following instructions assume only that you have installed Python >= 2.6 or Python >= 3.3. See http://www.python.org/download/ for instructions on installing Python.

Installing using pip

The easiest way to install scikit-learn is to use pip, the PyPA-recommended tool for installing Python packages. Install scikit-learn using pip as follows:

$ pip install -U scikit-learn

If pip is not available on your system, consult the following sections for installation instructions for various platforms.

Installing on Windows

scikit-learn requires setuptools, a third-party package that supports packaging and installing software for Python. Setuptools can be installed on Windows by running the bootstrap script at https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py.

Windows binaries for the 32-bit and 64-bit versions of scikit-learn are also available. If you cannot determine which version you need, install the 32-bit version. Both versions depend on NumPy 1.3 or newer. The 32-bit version of NumPy can be downloaded from http://sourceforge.net/projects/numpy/files/NumPy/. The 64-bit version can be downloaded from http://www.lfd.uci.edu/~gohlke/pythonlibs/#scikit-learn.

A Windows installer for the 32-bit version of scikit-learn can be downloaded from http://sourceforge.net/projects/scikit-learn/files/. An installer for the 64-bit version of scikit-learn can be downloaded from http://www.lfd.uci.edu/~gohlke/pythonlibs/#scikit-learn.

Installing on Ubuntu 16.04

scikit-learn can be installed on Ubuntu 16.04 using apt.

$ sudo apt install python-scikits-learn

Installing on Mac OS

scikit-learn can be installed on OS X using Macports.

$ sudo port install py27-sklearn

Installing Anaconda

Anaconda is a free collection of more than 720 open source data science packages for Python including scikit-learn, NumPy, SciPy, pandas, and matplotlib. Anaconda is platform-agnostic and simple to install. See https://docs.continuum.io/anaconda/install/ for instructions for your operating system.

Verifying the installation

To verify that scikit-learn has been installed correctly, open a Python console and execute the following:

# In[1]:
import sklearn
sklearn.__version__

# Out[1]:
'0.18.1'

To run scikit-learn's unit tests, first install the nose Python library. Then execute the following in a terminal emulator:

$ nosetest sklearn -exe  

Congratulations! You've successfully installed scikit-learn.

You have been reading a chapter from
Mastering Machine Learning with scikit-learn - Second Edition
Published in: Jul 2017
Publisher:
ISBN-13: 9781788299879
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image