Machine Learning for Hackers - Drew Conway.pdf

(24050 KB) Pobierz
Machine Learning for Hackers
Drew Conway and John Myles White
Beijing
Cambridge
Farnham
Köln
Sebastopol
Tokyo
Machine Learning for Hackers
by Drew Conway and John Myles White
Copyright © 2012 Drew Conway and John Myles White. All rights reserved.
Printed in the United States of America.
Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472.
O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions
are also available for most titles (http://my.safaribooksonline.com). For more information, contact our
corporate/institutional sales department: (800) 998-9938 or
corporate@oreilly.com.
Editor:
Julie Steele
Production Editor:
Melanie Yarbrough
Copyeditor:
Genevieve d’Entremont
Proofreader:
Teresa Horton
February 2012:
First Edition.
Indexer:
Angela Howard
Cover Designer:
Karen Montgomery
Interior Designer:
David Futato
Illustrator:
Robert Romano
Revision History for the First Edition:
2012-02-06
First release
See
http://oreilly.com/catalog/errata.csp?isbn=9781449303716
for release details.
Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of
O’Reilly Media, Inc.
Machine Learning for Hackers,
the cover image of a griffon vulture, and related
trade dress are trademarks of O’Reilly Media, Inc.
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as
trademarks. Where those designations appear in this book, and O’Reilly Media, Inc., was aware of a
trademark claim, the designations have been printed in caps or initial caps.
While every precaution has been taken in the preparation of this book, the publisher and authors assume
no responsibility for errors or omissions, or for damages resulting from the use of the information con-
tained herein.
ISBN: 978-1-449-30371-6
[LSI]
1328629742
Table of Contents
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . vii
1. Using R . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
R for Machine Learning
Downloading and Installing R
IDEs and Text Editors
Loading and Installing R Packages
R Basics for Machine Learning
Further Reading on R
2
5
8
9
12
27
2. Data Exploration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Exploration versus Confirmation
What Is Data?
Inferring the Types of Columns in Your Data
Inferring Meaning
Numeric Summaries
Means, Medians, and Modes
Quantiles
Standard Deviations and Variances
Exploratory Data Visualization
Visualizing the Relationships Between Columns
29
30
34
36
37
37
40
41
44
61
3. Classification: Spam Filtering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
This or That: Binary Classification
Moving Gently into Conditional Probability
Writing Our First Bayesian Spam Classifier
Defining the Classifier and Testing It with Hard Ham
Testing the Classifier Against All Email Types
Improving the Results
73
77
78
85
88
90
iii
Zgłoś jeśli naruszono regulamin