DMbook TOC1
DMbook TOC1
Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
I Introduction 9
2
Contents
3
Contents
9 Classification 371
9.1 Data Sets used in this Chapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 371
9.2 Assigning Categories: Classification . . . . . . . . . . . . . . . . . . . . . . . . . . . 372
9.3 Generative Classification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 374
9.4 K-Nearest-Neighbor Classifier . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 384
9.5 Discriminative Classification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 386
9.6 Support Vector Machines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 387
9.7 Decision Trees . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 391
9.8 Evaluating Classifiers: ROC Curves . . . . . . . . . . . . . . . . . . . . . . . . . . 400
9.9 Which classifier should I use? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 403
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 406
IV Appendices 473
4
Contents
5
Preface
Astronomy and astrophysics are witnessing dramatic increases in data volume as detectors, tele-
scopes and computers become ever more powerful. During the last decade, sky surveys across the
electromagnetic spectrum have collected hundreds of terabytes of astronomical data for hundreds
of millions of sources. Over the next decade, the data volume will enter the petabyte domain, and
provide accurate measurements for billions of sources. Astronomy and physics students are not
traditionally trained to handle such voluminous and complex data sets. Furthermore, standard
analysis methods employed in astronomy often lag far behind rapid progress in statistics and com-
puter science. The main purpose of this book is to help minimize the time it takes a student to
become an effective researcher.
This book provides the interface between astronomical data analysis problems and modern statis-
tical methods. It is aimed at physical and data-centric scientists who have an understanding of the
science drivers for analyzing large data sets but may not be aware of developments in statistical
techniques over the last decade. The book targets researchers who want to use existing methods for
analysis of large data sets, rather than those interested in the development of new methods. Theo-
retical discussions are limited to the minimum required to understand the algorithms. Nevertheless,
extensive and detailed references to relevant specialist literature are interspersed throughout the
book.
We present an example-driven compendium of modern statistical and data mining methods, to-
gether with carefully chosen examples based on real modern data sets, and of current astronomical
applications that will illustrate each method introduced in the book. The book is loosely organized
by practical analysis problems, and offers a comparative analysis of different techniques, including
discussions of the advantages and shortcomings of each method, and their scaling with the sample
size. The exposition of the material is supported by appropriate publicly available Python code
(available from the book website, rather than fully printed here) and data to enable a reader to
reproduce all the figures and examples, evaluate the techniques, and adapt them to their own field
of interest. To some extent, this book is an analog of the well-known Numerical Recipes book, but
aimed at the analysis of massive astronomical data sets, with more emphasis on modern tools for
data mining and machine learning, and with freely available code.
From the start, we desired to create a book which, in the spirit of reproducible research, would
allow readers to easily replicate the analysis behind every example and figure. We believe this
feature will make the book uniquely valuable as a practical guide. We chose to implement this
using Python, a powerful and flexible programming language that is quickly becoming a standard
in astronomy (a number of next-generation large astronomical surveys and projects use Python,
e.g., JVLA, ALMA, LSST). The Python code base associated with this book, called AstroML,
is maintained as a live web repository (GitHub), and is intended to be a growing collection of
well-documented and well-tested tools for astronomical research. Any astronomical researcher who
7
is currently developing software for analysis of massive survey data is invited and encouraged to
contribute their own tools to the code.
The target audience for this text includes senior undergraduate and graduate students in physics
and astronomy, as well as researchers using large data sets in a scientific context. Familiarity with
calculus and other basic mathematical techniques is assumed, but no extensive prior knowledge in
statistics is required (e.g., we assume that readers have heard before of the Gaussian distribution,
but not necessarily of the Lorentzian distribution). Though the examples in this book are aimed
at researchers in the fields of astronomy and astrophysics, the organization of the book allows for
easy mapping of relevant algorithms to problems from other fields. After the first introductory
Chapter, data organization and some aspects of fast computation are discussed in Chapter 2,
statistical foundations are reviewed in Chapters 3–5 (statistical distributions, maximum likelihood
and other classical statistics, and Bayesian methodology), exploratory data analysis is described
in Chapters 6 and 7 (Searching for Structure in Point Data; Dimensionality and its Reduction),
and data-based prediction methods are described in Chapters 8-10 (Regression and Model Fitting;
Classification; Time Series Analysis).
Finally, we are indebted to a number of colleagues whose careful reading and resulting comments
significantly improved this book. A summer study group consisting of Bob Abel, Yusra AlSayyad,
Lauren Anderson, Vaishali Bhardwaj, James Davenport, Alexander Fry, Bryce Kalmbach, and
David Westman identified many rough edges in the manuscript and tested the AstroML code.
We thank Alan Weinstein for help and advice with LIGO data, and Carl Carter-Schwendler for
motivational and expert discussions about Bayesian statistics. In addition, Tim Axelrod, Andy
Becker, Joshua Bloom, Tamás Budavári, David Hogg, Robert Lupton, Chelsea MacLeod, Lovro
Palaversa, Fernando Perez, Maria Süveges, Przemek Woźniak, and two anonymous reviewers pro-
vided extensive expert comments. Any remaining errors are entirely our own.
We dedicate this book to Cristin, Ian, Nancy, Pamela, Tom, and Vedrana for their support, encour-
agement, and understanding during the periods of intensive work and absent-mindedness along the
way to this finished text.