Data Science from Scratch

Book description

Data science libraries, frameworks, modules, and toolkits are great for doing data science, but they’re also a good way to dive into the discipline without actually understanding data science. In this book, you’ll learn how many of the most fundamental data science tools and algorithms work by implementing them from scratch.

If you have an aptitude for mathematics and some programming skills, author Joel Grus will help you get comfortable with the math and statistics at the core of data science, and with hacking skills you need to get started as a data scientist. Today’s messy glut of data holds answers to questions no one’s even thought to ask. This book provides you with the know-how to dig those answers out.

  • Get a crash course in Python
  • Learn the basics of linear algebra, statistics, and probability—and understand how and when they're used in data science
  • Collect, explore, clean, munge, and manipulate data
  • Dive into the fundamentals of machine learning
  • Implement models such as k-nearest Neighbors, Naive Bayes, linear and logistic regression, decision trees, neural networks, and clustering
  • Explore recommender systems, natural language processing, network analysis, MapReduce, and databases

Publisher resources

View/Submit Errata

Table of contents

  1. Preface
    1. Data Science
    2. From Scratch
    3. Conventions Used in This Book
    4. Using Code Examples
    5. Safari® Books Online
    6. How to Contact Us
    7. Acknowledgments
  2. 1. Introduction
    1. The Ascendance of Data
    2. What Is Data Science?
    3. Motivating Hypothetical: DataSciencester
      1. Finding Key Connectors
      2. Data Scientists You May Know
      3. Salaries and Experience
      4. Paid Accounts
      5. Topics of Interest
      6. Onward
  3. 2. A Crash Course in Python
    1. The Basics
      1. Getting Python
      2. The Zen of Python
      3. Whitespace Formatting
      4. Modules
      5. Arithmetic
      6. Functions
      7. Strings
      8. Exceptions
      9. Lists
      10. Tuples
      11. Dictionaries
      12. Sets
      13. Control Flow
      14. Truthiness
    2. The Not-So-Basics
      1. Sorting
      2. List Comprehensions
      3. Generators and Iterators
      4. Randomness
      5. Regular Expressions
      6. Object-Oriented Programming
      7. Functional Tools
      8. enumerate
      9. zip and Argument Unpacking
      10. args and kwargs
      11. Welcome to DataSciencester!
    3. For Further Exploration
  4. 3. Visualizing Data
    1. matplotlib
    2. Bar Charts
    3. Line Charts
    4. Scatterplots
    5. For Further Exploration
  5. 4. Linear Algebra
    1. Vectors
    2. Matrices
    3. For Further Exploration
  6. 5. Statistics
    1. Describing a Single Set of Data
      1. Central Tendencies
      2. Dispersion
    2. Correlation
    3. Simpson’s Paradox
    4. Some Other Correlational Caveats
    5. Correlation and Causation
    6. For Further Exploration
  7. 6. Probability
    1. Dependence and Independence
    2. Conditional Probability
    3. Bayes’s Theorem
    4. Random Variables
    5. Continuous Distributions
    6. The Normal Distribution
    7. The Central Limit Theorem
    8. For Further Exploration
  8. 7. Hypothesis and Inference
    1. Statistical Hypothesis Testing
    2. Example: Flipping a Coin
    3. Confidence Intervals
    4. P-hacking
    5. Example: Running an A/B Test
    6. Bayesian Inference
    7. For Further Exploration
  9. 8. Gradient Descent
    1. The Idea Behind Gradient Descent
    2. Estimating the Gradient
    3. Using the Gradient
    4. Choosing the Right Step Size
    5. Putting It All Together
    6. Stochastic Gradient Descent
    7. For Further Exploration
  10. 9. Getting Data
    1. stdin and stdout
    2. Reading Files
      1. The Basics of Text Files
      2. Delimited Files
    3. Scraping the Web
      1. HTML and the Parsing Thereof
      2. Example: O’Reilly Books About Data
    4. Using APIs
      1. JSON (and XML)
      2. Using an Unauthenticated API
      3. Finding APIs
    5. Example: Using the Twitter APIs
      1. Getting Credentials
    6. For Further Exploration
  11. 10. Working with Data
    1. Exploring Your Data
      1. Exploring One-Dimensional Data
      2. Two Dimensions
      3. Many Dimensions
    2. Cleaning and Munging
    3. Manipulating Data
    4. Rescaling
    5. Dimensionality Reduction
    6. For Further Exploration
  12. 11. Machine Learning
    1. Modeling
    2. What Is Machine Learning?
    3. Overfitting and Underfitting
    4. Correctness
    5. The Bias-Variance Trade-off
    6. Feature Extraction and Selection
    7. For Further Exploration
  13. 12. k-Nearest Neighbors
    1. The Model
    2. Example: Favorite Languages
    3. The Curse of Dimensionality
    4. For Further Exploration
  14. 13. Naive Bayes
    1. A Really Dumb Spam Filter
    2. A More Sophisticated Spam Filter
    3. Implementation
    4. Testing Our Model
    5. For Further Exploration
  15. 14. Simple Linear Regression
    1. The Model
    2. Using Gradient Descent
    3. Maximum Likelihood Estimation
    4. For Further Exploration
  16. 15. Multiple Regression
    1. The Model
    2. Further Assumptions of the Least Squares Model
    3. Fitting the Model
    4. Interpreting the Model
    5. Goodness of Fit
    6. Digression: The Bootstrap
    7. Standard Errors of Regression Coefficients
    8. Regularization
    9. For Further Exploration
  17. 16. Logistic Regression
    1. The Problem
    2. The Logistic Function
    3. Applying the Model
    4. Goodness of Fit
    5. Support Vector Machines
    6. For Further Investigation
  18. 17. Decision Trees
    1. What Is a Decision Tree?
    2. Entropy
    3. The Entropy of a Partition
    4. Creating a Decision Tree
    5. Putting It All Together
    6. Random Forests
    7. For Further Exploration
  19. 18. Neural Networks
    1. Perceptrons
    2. Feed-Forward Neural Networks
    3. Backpropagation
    4. Example: Defeating a CAPTCHA
    5. For Further Exploration
  20. 19. Clustering
    1. The Idea
    2. The Model
    3. Example: Meetups
    4. Choosing k
    5. Example: Clustering Colors
    6. Bottom-up Hierarchical Clustering
    7. For Further Exploration
  21. 20. Natural Language Processing
    1. Word Clouds
    2. n-gram Models
    3. Grammars
    4. An Aside: Gibbs Sampling
    5. Topic Modeling
    6. For Further Exploration
  22. 21. Network Analysis
    1. Betweenness Centrality
    2. Eigenvector Centrality
      1. Matrix Multiplication
      2. Centrality
    3. Directed Graphs and PageRank
    4. For Further Exploration
  23. 22. Recommender Systems
    1. Manual Curation
    2. Recommending What’s Popular
    3. User-Based Collaborative Filtering
    4. Item-Based Collaborative Filtering
    5. For Further Exploration
  24. 23. Databases and SQL
    1. CREATE TABLE and INSERT
    2. UPDATE
    3. DELETE
    4. SELECT
    5. GROUP BY
    6. ORDER BY
    7. JOIN
    8. Subqueries
    9. Indexes
    10. Query Optimization
    11. NoSQL
    12. For Further Exploration
  25. 24. MapReduce
    1. Example: Word Count
    2. Why MapReduce?
    3. MapReduce More Generally
    4. Example: Analyzing Status Updates
    5. Example: Matrix Multiplication
    6. An Aside: Combiners
    7. For Further Exploration
  26. 25. Go Forth and Do Data Science
    1. IPython
    2. Mathematics
    3. Not from Scratch
      1. NumPy
      2. pandas
      3. scikit-learn
      4. Visualization
      5. R
    4. Find Data
    5. Do Data Science
      1. Hacker News
      2. Fire Trucks
      3. T-shirts
      4. And You?
  27. Index

Product information

  • Title: Data Science from Scratch
  • Author(s): Joel Grus
  • Release date: April 2015
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9781491901427