Book Image

Python Machine Learning By Example - Second Edition

By : Yuxi (Hayden) Liu
Book Image

Python Machine Learning By Example - Second Edition

By: Yuxi (Hayden) Liu

Overview of this book

The surge in interest in machine learning (ML) is due to the fact that it revolutionizes automation by learning patterns in data and using them to make predictions and decisions. If you’re interested in ML, this book will serve as your entry point to ML. Python Machine Learning By Example begins with an introduction to important ML concepts and implementations using Python libraries. Each chapter of the book walks you through an industry adopted application. You’ll implement ML techniques in areas such as exploratory data analysis, feature engineering, and natural language processing (NLP) in a clear and easy-to-follow way. With the help of this extended and updated edition, you’ll understand how to tackle data-driven problems and implement your solutions with the powerful yet simple Python language and popular Python packages and tools such as TensorFlow, scikit-learn, gensim, and Keras. To aid your understanding of popular ML algorithms, the book covers interesting and easy-to-follow examples such as news topic modeling and classification, spam email detection, stock price forecasting, and more. By the end of the book, you’ll have put together a broad picture of the ML ecosystem and will be well-versed with the best practices of applying ML techniques to make the most out of new opportunities.
Table of Contents (15 chapters)
Free Chapter
1
Section 1: Fundamentals of Machine Learning
3
Section 2: Practical Python Machine Learning By Example
12
Section 3: Python Machine Learning Best Practices

What this book covers

Chapter 1, Getting Started with Machine Learning and Python, will be the starting point for readers who are looking forward to entering the field of machine learning with Python. It will introduce the essential concepts of machine learning, which we will dig deeper into throughout the rest of the book. In addition, it will discuss the basics of Python for machine learning and explain how to set it up properly for the upcoming examples and projects.

Chapter 2, Exploring the 20 Newsgroups Dataset with Text Analysis Techniques, will start developing the first project of the book, exploring and mining the 20 newsgroups dataset, which will be split into two parts—Chapter 2, Exploring the 20 Newsgroups Dataset with Text Analysis Techniques, and Chapter 3, Mining the 20 Newsgroups Dataset with Clustering and Topic Modeling Algorithms. In this chapter, readers will get familiar with NLP and various NLP libraries that will be used for this project. We will explain several important NLP techniques implementing them in NLTK. We will also cover the dimension reduction technique, especially t-SNE and its use in text data visualization.

Chapter 3, Mining the 20 Newsgroups Dataset with Clustering and Topic Modeling Algorithms, will continue our newsgroups project after exploring the 20 newsgroups dataset. In this chapter, readers will learn about unsupervised learning and clustering algorithms, as well as some advanced NLP techniques, such as LDA and word embedding. We will cluster the newsgroups data using the k-means algorithm, and detect topics using NMF and LDA.

Chapter 4, Detecting Spam Emails with Naive Bayes, will start our supervised learning journey. In this chapter, we focus on classification with Naïve Bayes, and we'll look at an in-depth implementation. We will also cover other important machine learning concepts, such as classification performance evaluation, model selection and tuning, and cross-validation. Examples including spam email detection will be demonstrated.

Chapter 5, Classifying Newsgroup Topics with a Support Vector Machine, will reuse the newsgroups dataset we used in Chapter 2, Exploring the 20 Newsgroups Dataset with Text Analysis Techniques, and Chapter 3, Mining the 20 Newsgroups Dataset with Clustering and Topic Modeling Algorithms. We will cover multiclass classification, as well as SVM and how they are applied in topic classification. Other important concepts, such as kernel machines, overfitting, and regularization, will be discussed as well.

Chapter 6, Predicting Online Ad Click-Through with Tree-Based Algorithms, will introduce and explain decision trees and random forests in depth throughout the course of solving the advertising click-through rate problem. Important concepts of tree-based models such as ensemble, feature importance, and feature selection will also be covered.

Chapter 7, Predicting Online Ads Click-Through with Logistic Regression, will introduce and explain logistic regression classifiers on the same project from the previous chapters. We will also cover other concepts, such as categorical variable encoding, L1 and L2 regularization, feature selection, online learning and stochastic gradient descent, and, of course, how to work with large datasets.

Chapter 8, Scaling Up Prediction to Terabyte Click Logs, covers online advertising click-through prediction, where we have millions of labeled samples in a typical large-scale machine learning problem. In this chapter, we will explore a more scalable solution than the previous chapters, utilizing powerful parallel computing tools such as Apache Hadoop and Spark. We will cover the essential concepts of Spark, such installation, RDD, and core programming, as well as its machine learning components. We will work with the entire dataset of millions of samples, explore the data, build classification models, perform feature engineering, and performance evaluation using Spark, which scales up the computation.

Chapter 9, Stock Price Prediction with Regression Algorithms, introduces the aim of this project, which is to analyze and predict stock market prices using the Yahoo/Google Finance data, and maybe additional data.

We will start the chapter by covering the challenges in finance and looking at a brief explanation of the related concepts. The next step is to obtain and explore the dataset and start feature engineering after exploratory data analysis. The core section, looking at regression and regression algorithms, linear regression, decision tree regression, SVR, and neural networks, will follow. Readers will also practice solving regression problems using scikit-learn and the TensorFlow API.

Chapter 10, Machine Learning Best Practices, covers best practices in machine learning. After covering multiple projects in this book, you will have gathered a broad picture of the machine learning ecosystem using Python. However, there will be issues once you start working on projects in the real world. This chapter aims to foolproof your learning and get you ready for production by providing 21 best practices throughout the entire machine learning workflow.