Python Machine Learning By Example

Book description

Take tiny steps to enter the big world of data science through this interesting guide

About This Book

  • Learn the fundamentals of machine learning and build your own intelligent applications

  • Master the art of building your own machine learning systems with this example-based practical guide

  • Work with important classification and regression algorithms and other machine learning techniques

  • Who This Book Is For

    This book is for anyone interested in entering the data science stream with machine learning. Basic familiarity with Python is assumed.

    What You Will Learn

  • Exploit the power of Python to handle data extraction, manipulation, and exploration techniques

  • Use Python to visualize data spread across multiple dimensions and extract useful features

  • Dive deep into the world of analytics to predict situations correctly

  • Implement machine learning classification and regression algorithms from scratch in Python

  • Be amazed to see the algorithms in action

  • Evaluate the performance of a machine learning model and optimize it

  • Solve interesting real-world problems using machine learning and Python as the journey unfolds

  • In Detail

    Data science and machine learning are some of the top buzzwords in the technical world today. A resurging interest in machine learning is due to the same factors that have made data mining and Bayesian analysis more popular than ever. This book is your entry point to machine learning.

    This book starts with an introduction to machine learning and the Python language and shows you how to complete the setup. Moving ahead, you will learn all the important concepts such as, exploratory data analysis, data preprocessing, feature extraction, data visualization and clustering, classification, regression and model performance evaluation. With the help of various projects included, you will find it intriguing to acquire the mechanics of several important machine learning algorithms – they are no more obscure as they thought. Also, you will be guided step by step to build your own models from scratch. Toward the end, you will gather a broad picture of the machine learning ecosystem and best practices of applying machine learning techniques.

    Through this book, you will learn to tackle data-driven problems and implement your solutions with the powerful yet simple language, Python. Interesting and easy-to-follow examples, to name some, news topic classification, spam email detection, online ad click-through prediction, stock prices forecast, will keep you glued till you reach your goal.

    Style and approach

    This book is an enticing journey that starts from the very basics and gradually picks up pace as the story unfolds. Each concept is first succinctly defined in the larger context of things, followed by a detailed explanation of their application. Every concept is explained with the help of a project that solves a real-world problem, and involves hands-on work—giving you a deep insight into the world of machine learning. With simple yet rich language—Python—you will understand and be able to implement the examples with ease.

    Table of contents

    1. Credits
    2. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
        1. Downloading the example code
        2. Errata
        3. Piracy
        4. Questions
    3. Getting Started with Python and Machine Learning
      1. What is machine learning and why do we need it?
      2. A very high level overview of machine learning
      3. A brief history of the development of machine learning algorithms
      4. Generalizing with data
      5. Overfitting, underfitting and the bias-variance tradeoff
        1. Avoid overfitting with cross-validation
        2. Avoid overfitting with regularization
      6. Avoid overfitting with feature selection and dimensionality reduction
      7. Preprocessing, exploration, and feature engineering
        1. Missing values
        2. Label encoding
        3. One-hot-encoding
        4. Scaling
        5. Polynomial features
        6. Power transformations
        7. Binning
      8. Combining models
        1. Bagging
        2. Boosting
        3. Stacking
        4. Blending
        5. Voting and averaging
      9. Installing software and setting up
      10. Troubleshooting and asking for help
      11. Summary
    4. Exploring the 20 Newsgroups Dataset with Text Analysis Algorithms
      1. What is NLP?
      2. Touring powerful NLP libraries in Python
      3. The newsgroups data
      4. Getting the data
      5. Thinking about features
      6. Visualization
      7. Data preprocessing
      8. Clustering
      9. Topic modeling
      10. Summary
    5. Spam Email Detection with Naive Bayes
      1. Getting started with classification
      2. Types of classification
      3. Applications of text classification
      4. Exploring naive Bayes
      5. Bayes' theorem by examples
      6. The mechanics of naive Bayes
      7. The naive Bayes implementations
      8. Classifier performance evaluation
      9. Model tuning and cross-validation
      10. Summary
    6. News Topic Classification with Support Vector Machine
      1. Recap and inverse document frequency
      2. Support vector machine
        1. The mechanics of SVM
          1. Scenario 1 - identifying the separating hyperplane
          2. Scenario 2 - determining the optimal hyperplane
          3. Scenario 3 - handling outliers
        2. The implementations of SVM
          1. Scenario 4 - dealing with more than two classes
        3. The kernels of SVM
        4. Choosing between the linear and RBF kernel
      3. News topic classification with support vector machine
      4. More examples - fetal state classification on cardiotocography with SVM
      5. Summary
    7. Click-Through Prediction with Tree-Based Algorithms
      1. Brief overview of advertising click-through prediction
      2. Getting started with two types of data, numerical and categorical
      3. Decision tree classifier
        1. The construction of a decision tree
        2. The metrics to measure a split
        3. The implementations of decision tree
      4. Click-through prediction with decision tree
      5. Random forest - feature bagging of decision tree
      6. Summary
    8. Click-Through Prediction with Logistic Regression
      1. One-hot encoding - converting categorical features to numerical
      2. Logistic regression classifier
        1. Getting started with the logistic function
        2. The mechanics of logistic regression
        3. Training a logistic regression model via gradient descent
      3. Click-through prediction with logistic regression by gradient descent
        1. Training a logistic regression model via stochastic gradient descent
        2. Training a logistic regression model with regularization
        3. Training on large-scale datasets with online learning
        4. Handling multiclass classification
      4. Feature selection via random forest
      5. Summary
    9. Stock Price Prediction with Regression Algorithms
      1. Brief overview of the stock market and stock price
      2. What is regression?
      3. Predicting stock price with regression algorithms
        1. Feature engineering
        2. Data acquisition and feature generation
        3. Linear regression
        4. Decision tree regression
        5. Support vector regression
        6. Regression performance evaluation
        7. Stock price prediction with regression algorithms
      4. Summary
    10. Best Practices
      1. Machine learning workflow
      2. Best practices in the data preparation stage
        1. Best practice 1 - completely understand the project goal
        2. Best practice 2 - collect all fields that are relevant
        3. Best practice 3 - maintain consistency of field values
        4. Best practice 4 - deal with missing data
      3. Best practices in the training sets generation stage
        1. Best practice 5 - determine categorical features with numerical values
        2. Best practice 6 - decide on whether or not to encode categorical features
        3. Best practice 7 - decide on whether or not to select features and if so, how
        4. Best practice 8 - decide on whether or not to reduce dimensionality and if so how
        5. Best practice 9 - decide on whether or not to scale features
        6. Best practice 10 - perform feature engineering with domain expertise
        7. Best practice 11 - perform feature engineering without domain expertise
        8. Best practice 12 - document how each feature is generated
      4. Best practices in the model training, evaluation, and selection stage
        1. Best practice 13 - choose the right algorithm(s) to start with
          1. Naive Bayes
          2. Logistic regression
          3. SVM
          4. Random forest (or decision tree)
          5. Neural networks
        2. Best practice 14 - reduce overfitting
        3. Best practice 15 - diagnose overfitting and underfitting
      5. Best practices in the deployment and monitoring stage
        1. Best practice 16 - save, load, and reuse models
        2. Best practice 17 - monitor model performance
        3. Best practice 18 - update models regularly
      6. Summary

    Product information

    • Title: Python Machine Learning By Example
    • Author(s): Yuxi Liu
    • Release date: May 2017
    • Publisher(s): Packt Publishing
    • ISBN: 9781783553112