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
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Python Machine Learning
Python Machine Learning

Python Machine Learning: Learn how to build powerful Python machine learning algorithms to generate useful data insights with this data analysis tutorial

Arrow left icon
Profile Icon Sebastian Raschka
Arrow right icon
Free Trial
Full star icon Full star icon Full star icon Full star icon Half star icon 4.3 (100 Ratings)
Paperback Sep 2015 454 pages 1st Edition
eBook
₱2000.99
Paperback
₱2500.99
Subscription
Free Trial
Arrow left icon
Profile Icon Sebastian Raschka
Arrow right icon
Free Trial
Full star icon Full star icon Full star icon Full star icon Half star icon 4.3 (100 Ratings)
Paperback Sep 2015 454 pages 1st Edition
eBook
₱2000.99
Paperback
₱2500.99
Subscription
Free Trial
eBook
₱2000.99
Paperback
₱2500.99
Subscription
Free Trial

What do you get with a Packt Subscription?

Free for first 7 days. $15.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

Chapter 2. Training Machine Learning Algorithms for Classification

In this chapter, we will make use of one 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 to 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 classification...

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 to design artificial intelligence, Warren McCullock and Walter Pitts published the first concept of a simplified brain cell, the so-called McCullock-Pitts (MCP) neuron, in 1943 (W. S. McCulloch and W. Pitts. A Logical Calculus of the Ideas Immanent in Nervous Activity. The 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:

McCullock 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...

Implementing a perceptron learning algorithm in Python


In the previous section, we learned how 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. We will take an objected-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 add 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:

NumPy: http://wiki.scipy.org/Tentative_NumPy_Tutorial

Pandas: http://pandas.pydata.org/pandas-docs/stable/tutorials.html

Matplotlib: http://matplotlib.org/users...

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, only a few years after Frank Rosenblatt's perceptron algorithm, by Bernard Widrow and his doctoral student Tedd Hoff, and can be considered as an improvement on the latter (B. Widrow et al. Adaptive "Adaline" neuron using chemical "memistors". Number Technical Report 1553-2. Stanford Electron. Labs. Stanford, CA, October 1960). The Adaline algorithm is particularly interesting because it illustrates the key concept of defining and minimizing cost functions, which will lay the groundwork for understanding more advanced machine learning algorithms for classification, such as logistic regression and support vector machines, as well as regression models that we will discuss in future chapters.

The key difference between the Adaline rule (also known as the Widrow-Hoff rule) and Rosenblatt's perceptron...

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 on-line 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 off-the-shelf machine learning classifiers that are commonly used in academia as well as in industry.

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • • Leverage Python’s most powerful open-source libraries for deep learning, data wrangling, and data visualization
  • • Learn effective strategies and best practices to improve and optimize machine learning systems and algorithms
  • • Ask – and answer – tough questions of your data with robust statistical models, built for a range of datasets

Description

Machine learning and predictive analytics are transforming the way businesses and other organizations operate. Being able to understand trends and patterns in complex data is critical to success, becoming one of the key strategies for unlocking growth in a challenging contemporary marketplace. Python can help you deliver key insights into your data – its unique capabilities as a language let you build sophisticated algorithms and statistical models that can reveal new perspectives and answer key questions that are vital for success. Python Machine Learning gives you access to the world of predictive analytics and demonstrates why Python is one of the world’s leading data science languages. If you want to ask better questions of data, or need to improve and extend the capabilities of your machine learning systems, this practical data science book is invaluable. Covering a wide range of powerful Python libraries, including scikit-learn, Theano, and Keras, and featuring guidance and tips on everything from sentiment analysis to neural networks, you’ll soon be able to answer some of the most important questions facing you and your organization.

Who is this book for?

If you want to find out how to use Python to start answering critical questions of your data, pick up Python Machine Learning – whether you want to get started from scratch or want to extend your data science knowledge, this is an essential and unmissable resource.

What you will learn

  • • Explore how to use different machine learning models to ask different questions of your data
  • • Learn how to build neural networks using Keras and Theano
  • • Find out how to write clean and elegant Python code that will optimize the strength of your algorithms
  • • Discover how to embed your machine learning model in a web application for increased accessibility
  • • Predict continuous target outcomes using regression analysis
  • • Uncover hidden patterns and structures in data with clustering
  • • Organize data using effective pre-processing techniques
  • • Get to grips with sentiment analysis to delve deeper into textual and social media data

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Sep 23, 2015
Length: 454 pages
Edition : 1st
Language : English
ISBN-13 : 9781783555130
Category :
Languages :
Tools :

What do you get with a Packt Subscription?

Free for first 7 days. $15.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 23, 2015
Length: 454 pages
Edition : 1st
Language : English
ISBN-13 : 9781783555130
Category :
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$12.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 6,500+ 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
$129.99 billed annually
Feature tick icon Unlimited access to Packt's library of 6,500+ 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 ₱260 each
Feature tick icon Exclusive print discounts
$179.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 6,500+ 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 ₱260 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 7,604.97
Python Machine Learning
₱2500.99
Learning Data Mining with Python
₱2500.99
Practical Machine Learning
₱2602.99
Total 7,604.97 Stars icon

Table of Contents

13 Chapters
Giving Computers the Ability to Learn from Data Chevron down icon Chevron up icon
Training Machine Learning Algorithms for Classification Chevron down icon Chevron up icon
A Tour of Machine Learning Classifiers Using Scikit-learn Chevron down icon Chevron up icon
Building Good Training Sets – Data Preprocessing Chevron down icon Chevron up icon
Compressing Data via Dimensionality Reduction Chevron down icon Chevron up icon
Learning Best Practices for Model Evaluation and Hyperparameter Tuning Chevron down icon Chevron up icon
Combining Different Models for Ensemble Learning Chevron down icon Chevron up icon
Applying Machine Learning to Sentiment Analysis Chevron down icon Chevron up icon
Embedding a Machine Learning Model into a Web Application Chevron down icon Chevron up icon
Predicting Continuous Target Variables with Regression Analysis Chevron down icon Chevron up icon
Working with Unlabeled Data – Clustering Analysis Chevron down icon Chevron up icon
Training Artificial Neural Networks for Image Recognition Chevron down icon Chevron up icon
Parallelizing Neural Network Training with Theano 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
(100 Ratings)
5 star 62%
4 star 17%
3 star 11%
2 star 6%
1 star 4%
Filter icon Filter
Top Reviews

Filter reviews by




Rob Bontekoe Nov 13, 2016
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I had a lot of frustration with ML online courses and bought this book. But not until I created the right test environment, it didn't take away my frustration. Now I'm using a Raspberry Pi 3 with Docker installed. I found the right Docker image (including TensorFlow) and imported the necessarily Python3 libraries needed for this book. I'm using Chrome to access the iPython browser implementation.Sebastion explains the ML subjects very well. All the examples work fine and improve my understanding in ML a lot. When I did the Decision Tree section of chapter 3, I could even use the web version of Graphviz to display the resulting decision diagram.I'm really happy I bought his book.
Amazon Verified review Amazon
C. Herther Nov 09, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This is the first Python Machine Learning book that actually made sense. Sebastian managed to combine theory (math behind the models, how to implement an algorithm from scratch) with practice (how to actually implement it using scikit-learn) in a way no book has done thus far. I was really impressed (and surprised) to see how 'easy' it is to implement the more simple algorithms from scratch, and while I wouldn't do that normally, it was very helpful to understand what's going on behind the scenes.I would recommend this to people that have at least *some* understanding of Machine Learning (and obviously Python).If you've taken Andrew Ng's ML class on Coursera, some of this (and the terminology) should ring very familiar.
Amazon Verified review Amazon
Gabe 101 Dec 15, 2019
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Raschka does a good job, particularly in later editions, of walking through the concepts and code. I have adapted some of his work for hands-on Google Colabs for my course in ML and this remains one of the books I recommend for students.
Amazon Verified review Amazon
Publius1981 Feb 23, 2017
Full star icon Full star icon Full star icon Full star icon Full star icon 5
the standard for books on machine learning and python. sebastian is an outstanding author and hopefully his upcoming deep learning book will be just as good. if you can only buy one book on ML - buy this one.
Amazon Verified review Amazon
Atreya Apr 02, 2016
Full star icon Full star icon Full star icon Full star icon Full star icon 5
UPDATE:This is a fantastic follow-up book to Andrew Ng's awesome machine learning course on Coursera. While Andrew Ng covers the basics at the level of first year under-graduate students (or even high school students), this book covers a whole lot more at a slightly higher level. The notation used in this book is consistent with Andrew Ng's course as well. You also get to implement most of the algos from scratch with Python and then with Scikit-learn. No better way to learn machine learning!I keep going back to this book very often to look up something or the other.ORIGINAL REVIEW:This is absolutely the best machine learning book in market today!If you are totally new to machine learning, then this book will get you started the right way and teach you enough to become a machine learning professional.I have been working in the fields of machine learning and natural language processing for over a decade now (on and off depending on company project requirements) and at various times read (or tried to read) several books on various topics in machine learning. But none of them bring you to action as fast as this book does. It's got clean and elegant Python code that you can immediately put to use, along with the correct level of theory and motivation. You can think of this book as a companion to Andrew Ng's Coursera course on machine learning. While Ng's course uses Matlab, this book will teach most of what Ng teaches in Python and more. I have been able to use the code in this book on Kaggle competitions and get decent scores!Cons: Packt (as usual) has done a poor job of formatting the math equations all over the book, and it is an eye sore! There are also a few typos, which could have been easily avoided with careful reviewers. But the author has more than compensated for the publisher's flaws with his sensible diagrams (so color coding still makes sense in gray scale) and point styles for different kinds of data.
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.

Modal Close icon
Modal Close icon