Machine Learning for Email - Drew Conway.pdf

(9918 KB) Pobierz
Machine Learning for Email
Drew Conway and John Myles White
Beijing
Cambridge
Farnham
Köln
Sebastopol
Tokyo
Machine Learning for Email
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:
Kristen Borg
Proofreader:
O’Reilly Production Services
Revision History for the First Edition:
Cover Designer:
Karen Montgomery
Interior Designer:
David Futato
Illustrator:
Robert Romano
2011-10-24
First release
See
http://oreilly.com/catalog/errata.csp?isbn=9781449314309
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 Email,
the image of an axolotl, 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-31430-9
[LSI]
1319571973
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
11
26
2. Data Exploration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Exploration vs. 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
Modes
Skewness
Thin Tails vs. Heavy Tails
Visualizing the Relationships between Columns
29
30
34
36
37
37
40
41
43
54
57
59
66
3. Classification: Spam Filtering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
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
75
80
81
88
91
v
Zgłoś jeśli naruszono regulamin