Data Science from Scratch, 2nd Edition

Book description

To really learn data science, you should not only master the tools—data science libraries, frameworks, modules, and toolkits—but also understand the ideas and principles underlying them. Updated for Python 3.6, this second edition of Data Science from Scratch shows you how these 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 the hacking skills you need to get started as a data scientist. Packed with new material on deep learning, statistics, and natural language processing, this updated book shows you how to find the gems in today’s messy glut of data.

  • Get a crash course in Python
  • Learn the basics of linear algebra, statistics, and probability—and 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, Naïve 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 to the Second Edition
    1. Conventions Used in This Book
    2. Using Code Examples
    3. O’Reilly Online Learning
    4. How to Contact Us
    5. Acknowledgments
  2. Preface to the First Edition
    1. Data Science
    2. From Scratch
  3. 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
  4. 2. A Crash Course in Python
    1. The Zen of Python
    2. Getting Python
    3. Virtual Environments
    4. Whitespace Formatting
    5. Modules
    6. Functions
    7. Strings
    8. Exceptions
    9. Lists
    10. Tuples
    11. Dictionaries
      1. defaultdict
    12. Counters
    13. Sets
    14. Control Flow
    15. Truthiness
    16. Sorting
    17. List Comprehensions
    18. Automated Testing and assert
    19. Object-Oriented Programming
    20. Iterables and Generators
    21. Randomness
    22. Regular Expressions
    23. Functional Programming
    24. zip and Argument Unpacking
    25. args and kwargs
    26. Type Annotations
      1. How to Write Type Annotations
    27. Welcome to DataSciencester!
    28. For Further Exploration
  5. 3. Visualizing Data
    1. matplotlib
    2. Bar Charts
    3. Line Charts
    4. Scatterplots
    5. For Further Exploration
  6. 4. Linear Algebra
    1. Vectors
    2. Matrices
    3. For Further Exploration
  7. 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
  8. 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
  9. 7. Hypothesis and Inference
    1. Statistical Hypothesis Testing
    2. Example: Flipping a Coin
    3. p-Values
    4. Confidence Intervals
    5. p-Hacking
    6. Example: Running an A/B Test
    7. Bayesian Inference
    8. For Further Exploration
  10. 8. Gradient Descent
    1. The Idea Behind Gradient Descent
    2. Estimating the Gradient
    3. Using the Gradient
    4. Choosing the Right Step Size
    5. Using Gradient Descent to Fit Models
    6. Minibatch and Stochastic Gradient Descent
    7. For Further Exploration
  11. 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: Keeping Tabs on Congress
    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
  12. 10. Working with Data
    1. Exploring Your Data
      1. Exploring One-Dimensional Data
      2. Two Dimensions
      3. Many Dimensions
    2. Using NamedTuples
    3. Dataclasses
    4. Cleaning and Munging
    5. Manipulating Data
    6. Rescaling
    7. An Aside: tqdm
    8. Dimensionality Reduction
    9. For Further Exploration
  13. 11. Machine Learning
    1. Modeling
    2. What Is Machine Learning?
    3. Overfitting and Underfitting
    4. Correctness
    5. The Bias-Variance Tradeoff
    6. Feature Extraction and Selection
    7. For Further Exploration
  14. 12. k-Nearest Neighbors
    1. The Model
    2. Example: The Iris Dataset
    3. The Curse of Dimensionality
    4. For Further Exploration
  15. 13. Naive Bayes
    1. A Really Dumb Spam Filter
    2. A More Sophisticated Spam Filter
    3. Implementation
    4. Testing Our Model
    5. Using Our Model
    6. For Further Exploration
  16. 14. Simple Linear Regression
    1. The Model
    2. Using Gradient Descent
    3. Maximum Likelihood Estimation
    4. For Further Exploration
  17. 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
  18. 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
  19. 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
  20. 18. Neural Networks
    1. Perceptrons
    2. Feed-Forward Neural Networks
    3. Backpropagation
    4. Example: Fizz Buzz
    5. For Further Exploration
  21. 19. Deep Learning
    1. The Tensor
    2. The Layer Abstraction
    3. The Linear Layer
    4. Neural Networks as a Sequence of Layers
    5. Loss and Optimization
    6. Example: XOR Revisited
    7. Other Activation Functions
    8. Example: FizzBuzz Revisited
    9. Softmaxes and Cross-Entropy
    10. Dropout
    11. Example: MNIST
    12. Saving and Loading Models
    13. For Further Exploration
  22. 20. 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
  23. 21. Natural Language Processing
    1. Word Clouds
    2. n-Gram Language Models
    3. Grammars
    4. An Aside: Gibbs Sampling
    5. Topic Modeling
    6. Word Vectors
    7. Recurrent Neural Networks
    8. Example: Using a Character-Level RNN
    9. For Further Exploration
  24. 22. Network Analysis
    1. Betweenness Centrality
    2. Eigenvector Centrality
      1. Matrix Multiplication
      2. Centrality
    3. Directed Graphs and PageRank
    4. For Further Exploration
  25. 23. Recommender Systems
    1. Manual Curation
    2. Recommending What’s Popular
    3. User-Based Collaborative Filtering
    4. Item-Based Collaborative Filtering
    5. Matrix Factorization
    6. For Further Exploration
  26. 24. 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
  27. 25. 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
  28. 26. Data Ethics
    1. What Is Data Ethics?
    2. No, Really, What Is Data Ethics?
    3. Should I Care About Data Ethics?
    4. Building Bad Data Products
    5. Trading Off Accuracy and Fairness
    6. Collaboration
    7. Interpretability
    8. Recommendations
    9. Biased Data
    10. Data Protection
    11. In Summary
    12. For Further Exploration
  29. 27. 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
      6. Deep Learning
    4. Find Data
    5. Do Data Science
      1. Hacker News
      2. Fire Trucks
      3. T-Shirts
      4. Tweets on a Globe
      5. And You?
  30. Index

Product information

  • Title: Data Science from Scratch, 2nd Edition
  • Author(s): Joel Grus
  • Release date: May 2019
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9781492041139