Skip to Content
Python Machine Learning Cookbook
book

Python Machine Learning Cookbook

by Prateek Joshi, Vahid Mirjalili
June 2016
Beginner to intermediate
304 pages
6h 24m
English
Packt Publishing
Content preview from Python Machine Learning Cookbook

Preprocessing data using different techniques

In the real world, we usually have to deal with a lot of raw data. This raw data is not readily ingestible by machine learning algorithms. To prepare the data for machine learning, we have to preprocess it before we feed it into various algorithms.

Getting ready

Let's see how to preprocess data in Python. To start off, open a file with a .py extension, for example, preprocessor.py, in your favorite text editor. Add the following lines to this file:

import numpy as np
from sklearn import preprocessing

We just imported a couple of necessary packages. Let's create some sample data. Add the following line to this file:

data = np.array([[3, -1.5,  2, -5.4], [0,  4,  -0.3, 2.1], [1,  3.3, -1.9, -4.3]])

We are now ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Python Machine Learning Cookbook - Second Edition

Python Machine Learning Cookbook - Second Edition

Giuseppe Ciaburro, Prateek Joshi
Python: Real World Machine Learning

Python: Real World Machine Learning

Prateek Joshi, John Hearty, Bastiaan Sjardin, Luca Massaron, Alberto Boschetti

Publisher Resources

ISBN: 9781786464477Supplemental Content