Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Python Machine Learning, Second Edition
Python Machine Learning, Second Edition

Python Machine Learning, Second Edition: Machine Learning and Deep Learning with Python, scikit-learn, and TensorFlow , Second Edition

Arrow left icon
Profile Icon Sebastian Raschka Profile Icon Vahid Mirjalili
Arrow right icon
€18.99 per month
Full star icon Full star icon Full star icon Full star icon Half star icon 4.3 (89 Ratings)
Paperback Sep 2017 622 pages 2nd Edition
eBook
€8.99 €26.99
Paperback
€32.99
Subscription
Free Trial
Renews at €18.99p/m
Arrow left icon
Profile Icon Sebastian Raschka Profile Icon Vahid Mirjalili
Arrow right icon
€18.99 per month
Full star icon Full star icon Full star icon Full star icon Half star icon 4.3 (89 Ratings)
Paperback Sep 2017 622 pages 2nd Edition
eBook
€8.99 €26.99
Paperback
€32.99
Subscription
Free Trial
Renews at €18.99p/m
eBook
€8.99 €26.99
Paperback
€32.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
Table of content icon View table of contents Preview book icon Preview Book

Python Machine Learning, Second Edition

Chapter 2. Training Simple Machine Learning Algorithms for Classification

In this chapter, we will make use of two of the first algorithmically described machine learning algorithms for classification, the perceptron and adaptive linear neurons. We will start by implementing a perceptron step by step in Python and training it to classify different flower species in the Iris dataset. This will help us understand the concept of machine learning algorithms for classification and how they can be efficiently implemented in Python.

Discussing the basics of optimization using adaptive linear neurons will then lay the groundwork for using more powerful classifiers via the scikit-learn machine learning library in Chapter 3, A Tour of Machine Learning Classifiers Using scikit-learn.

The topics that we will cover in this chapter are as follows:

  • Building an intuition for machine learning algorithms
  • Using pandas, NumPy, and Matplotlib to read in, process, and visualize data
  • Implementing linear...

Artificial neurons – a brief glimpse into the early history of machine learning

Before we discuss the perceptron and related algorithms in more detail, let us take a brief tour through the early beginnings of machine learning. Trying to understand how the biological brain works, in order to design AI, Warren McCulloch and Walter Pitts published the first concept of a simplified brain cell, the so-called McCulloch-Pitts (MCP) neuron, in 1943 (A Logical Calculus of the Ideas Immanent in Nervous Activity, W. S. McCulloch and W. Pitts, Bulletin of Mathematical Biophysics, 5(4): 115-133, 1943). Neurons are interconnected nerve cells in the brain that are involved in the processing and transmitting of chemical and electrical signals, which is illustrated in the following figure:

Artificial neurons – a brief glimpse into the early history of machine learning

McCulloch and Pitts described such a nerve cell as a simple logic gate with binary outputs; multiple signals arrive at the dendrites, are then integrated into the cell body, and, if the accumulated signal exceeds...

Implementing a perceptron learning algorithm in Python

In the previous section, we learned how the Rosenblatt's perceptron rule works; let us now go ahead and implement it in Python, and apply it to the Iris dataset that we introduced in Chapter 1, Giving Computers the Ability to Learn from Data.

An object-oriented perceptron API

We will take an object-oriented approach to define the perceptron interface as a Python class, which allows us to initialize new Perceptron objects that can learn from data via a fit method, and make predictions via a separate predict method. As a convention, we append an underscore (_) to attributes that are not being created upon the initialization of the object but by calling the object's other methods, for example, self.w_.

Note

If you are not yet familiar with Python's scientific libraries or need a refresher, please see the following resources:

Adaptive linear neurons and the convergence of learning

In this section, we will take a look at another type of single-layer neural network: ADAptive LInear NEuron (Adaline). Adaline was published by Bernard Widrow and his doctoral student Tedd Hoff, only a few years after Frank Rosenblatt's perceptron algorithm, and can be considered as an improvement on the latter. (Refer to An Adaptive "Adaline" Neuron Using Chemical "Memistors", Technical Report Number 1553-2, B. Widrow and others, Stanford Electron Labs, Stanford, CA, October 1960).

The Adaline algorithm is particularly interesting because it illustrates the key concepts of defining and minimizing continuous cost functions. This lays the groundwork for understanding more advanced machine learning algorithms for classification, such as logistic regression, support vector machines, and regression models, which we will discuss in future chapters.

The key difference between the Adaline rule (also known as the Widrow...

Summary

In this chapter, we gained a good understanding of the basic concepts of linear classifiers for supervised learning. After we implemented a perceptron, we saw how we can train adaptive linear neurons efficiently via a vectorized implementation of gradient descent and online learning via stochastic gradient descent.

Now that we have seen how to implement simple classifiers in Python, we are ready to move on to the next chapter, where we will use the Python scikit-learn machine learning library to get access to more advanced and powerful machine learning classifiers that are commonly used in academia as well as in industry. The object-oriented approach that we used to implement the perceptron and Adaline algorithms will help with understanding the scikit-learn API, which is implemented based on the same core concepts that we used in this chapter: the fit and predict methods. Based on these core concepts, we will learn about logistic regression for modeling class probabilities and support...

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Second edition of the bestselling book on Machine Learning
  • A practical approach to key frameworks in data science, machine learning, and deep learning
  • Use the most powerful Python libraries to implement machine learning and deep learning
  • Get to know the best practices to improve and optimize your machine learning systems and algorithms

Description

Publisher's Note: This edition from 2017 is outdated and is not compatible with TensorFlow 2 or any of the most recent updates to Python libraries. A new third edition, updated for 2020 and featuring TensorFlow 2 and the latest in scikit-learn, reinforcement learning, and GANs, has now been published. Machine learning is eating the software world, and now deep learning is extending machine learning. Understand and work at the cutting edge of machine learning, neural networks, and deep learning with this second edition of Sebastian Raschka’s bestselling book, Python Machine Learning. Using Python's open source libraries, this book offers the practical knowledge and techniques you need to create and contribute to machine learning, deep learning, and modern data analysis. Fully extended and modernized, Python Machine Learning Second Edition now includes the popular TensorFlow 1.x deep learning library. The scikit-learn code has also been fully updated to v0.18.1 to include improvements and additions to this versatile machine learning library. Sebastian Raschka and Vahid Mirjalili’s unique insight and expertise introduce you to machine learning and deep learning algorithms from scratch, and show you how to apply them to practical industry challenges using realistic and interesting examples. By the end of the book, you’ll be ready to meet the new data analysis opportunities. If you’ve read the first edition of this book, you’ll be delighted to find a balance of classical ideas and modern insights into machine learning. Every chapter has been critically updated, and there are new chapters on key technologies. You’ll be able to learn and work with TensorFlow 1.x more deeply than ever before, and get essential coverage of the Keras neural network library, along with updates to scikit-learn 0.18.1.

Who is this book for?

If you know some Python and you want to use machine learning and deep learning, pick up this book. Whether you want to start from scratch or extend your machine learning knowledge, this is an essential and unmissable resource. Written for developers and data scientists who want to create practical machine learning and deep learning code, this book is ideal for developers and data scientists who want to teach computers how to learn from data.

What you will learn

  • Understand the key frameworks in data science, machine learning, and deep learning
  • Harness the power of the latest Python open source libraries in machine learning
  • Explore machine learning techniques using challenging real-world data
  • Master deep neural network implementation using the TensorFlow 1.x library
  • Learn the mechanics of classification algorithms to implement the best tool for the job
  • Predict continuous target outcomes using regression analysis
  • Uncover hidden patterns and structures in data with clustering
  • Delve deeper into textual and social media data using sentiment analysis

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Sep 20, 2017
Length: 622 pages
Edition : 2nd
Language : English
ISBN-13 : 9781787125933
Vendor :
Google
Category :
Languages :
Concepts :

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

Publication date : Sep 20, 2017
Length: 622 pages
Edition : 2nd
Language : English
ISBN-13 : 9781787125933
Vendor :
Google
Category :
Languages :
Concepts :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 116.97
Artificial Intelligence with Python
€41.99
Python Machine Learning, Second Edition
€32.99
Statistics for Machine Learning
€41.99
Total 116.97 Stars icon
Banner background image

Table of Contents

17 Chapters
1. Giving Computers the Ability to Learn from Data Chevron down icon Chevron up icon
2. Training Simple Machine Learning Algorithms for Classification Chevron down icon Chevron up icon
3. A Tour of Machine Learning Classifiers Using scikit-learn Chevron down icon Chevron up icon
4. Building Good Training Sets – Data Preprocessing Chevron down icon Chevron up icon
5. Compressing Data via Dimensionality Reduction Chevron down icon Chevron up icon
6. Learning Best Practices for Model Evaluation and Hyperparameter Tuning Chevron down icon Chevron up icon
7. Combining Different Models for Ensemble Learning Chevron down icon Chevron up icon
8. Applying Machine Learning to Sentiment Analysis Chevron down icon Chevron up icon
9. Embedding a Machine Learning Model into a Web Application Chevron down icon Chevron up icon
10. Predicting Continuous Target Variables with Regression Analysis Chevron down icon Chevron up icon
11. Working with Unlabeled Data – Clustering Analysis Chevron down icon Chevron up icon
12. Implementing a Multilayer Artificial Neural Network from Scratch Chevron down icon Chevron up icon
13. Parallelizing Neural Network Training with TensorFlow Chevron down icon Chevron up icon
14. Going Deeper – The Mechanics of TensorFlow Chevron down icon Chevron up icon
15. Classifying Images with Deep Convolutional Neural Networks Chevron down icon Chevron up icon
16. Modeling Sequential Data Using Recurrent Neural Networks Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.3
(89 Ratings)
5 star 67.4%
4 star 14.6%
3 star 7.9%
2 star 2.2%
1 star 7.9%
Filter icon Filter
Top Reviews

Filter reviews by




VISA Nov 30, 2018
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Great book! Presenting the machine learning algorithms and some of the elements of the linked theory, altogether with Python code is really useful.
Amazon Verified review Amazon
sipy Aug 14, 2018
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This book will stay on your reference shelf for years to come!The authors clearly have taught these materials many times before, and their significant mathematical and technical prowess is delivered using a very approachable style. This book seems best suited for someone who wants to sit down and begin to apply Python Machine Learning to a problem that they already know they have. It's not particularly an "intro course to M.L.", but it contains enough details that you could easily follow along and learn how to use the various tools and techniques of the field if you've never seen or heard of them before.The copious notes scattered throughout this book are pure gold, mined from the obvious experiences of the authors while working in the field. If there ever is a Machine Learning equivalent to the venerable "Forrest M. Mims Engineering Notebook" for electronics, I feel these two authors could write it!Once you use this book to work on your current M.L. problem in Python, you will find yourself returning to it as a reference for other problems in the M.L. space. Its lucid explanations will help reinforce the topics presented, and cement your understanding of the materials.This book will get you writing Python Machine Learning code to work your current M.L. problem in no time flat!
Amazon Verified review Amazon
Dave May 20, 2018
Full star icon Full star icon Full star icon Full star icon Full star icon 5
It is the best book on Machine Learning using python. Algorithms are well explained. Suitable for beginners though you need to know some calculus.
Amazon Verified review Amazon
Bio620 Mar 17, 2018
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Very interesting book
Amazon Verified review Amazon
Jano Aug 08, 2018
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Very steep learning curve.I almost gave up in chapter two at perceptron but since that algorithm is the foundation of all I spent a whole week to understand it. The code the author uses is pretty much optimized and it was not in sync with the mathematical introduction. But the first 30 pages are absolutely neccessary to read and understand deeply in order to move on.After page 30 it became a little faster to proceed with the book since topics from page 30 - 107 are mostly the extension of the perceptron. At page 107- 160 I am already accustomedto the authors style and to the books logic so it is now quite effective to read and digest the models.And that is where I am at the moment. I gave this book 5 stars since I wanted a high quality ML and python book which leads me through the models in a step-by-step way no matter how hard it is mathematically or programmtechnically. And I got this.negative:The pdf version has color pictures which is nice especially for multiline charts ( like page 212) where the b&w book just visually flat and some chart elements cannot be identified.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.