23,92 €
Build smart applications by implementing real-world artificial intelligence projects
Key Features
Book Description
Artificial Intelligence (AI) is the newest technology that's being employed among varied businesses, industries, and sectors. Python Artificial Intelligence Projects for Beginners demonstrates AI projects in Python, covering modern techniques that make up the world of Artificial Intelligence.
This book begins with helping you to build your first prediction model using the popular Python library, scikit-learn. You will understand how to build a classifier using an effective machine learning technique, random forest, and decision trees. With exciting projects on predicting bird species, analyzing student performance data, song genre identification, and spam detection, you will learn the fundamentals and various algorithms and techniques that foster the development of these smart applications. In the concluding chapters, you will also understand deep learning and neural network mechanisms through these projects with the help of the Keras library.
By the end of this book, you will be confident in building your own AI projects with Python and be ready to take on more advanced projects as you progress
What you will learn
Who this book is for
Python Artificial Intelligence Projects for Beginners is for Python developers who want to take their first step into the world of Artificial Intelligence using easy-to-follow projects. Basic working knowledge of Python programming is expected so that you're able to play around with code
Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:
Seitenzahl: 127
Veröffentlichungsjahr: 2018
Copyright © 2018 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author(s), nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
Commissioning Editor:Pravin DhandreAcquisition Editor:Joshua NadarContent Development Editors: Prasad Ramesh, Karan ThakkarTechnical Editor: Sagar SawantCopy Editor: Safis EditingProject Coordinator: Nidhi JoshiProofreader: Safis EditingIndexer:Pratik ShirodkarGraphics: Jisha ChirayilProduction Coordinator: Arvindkumar Gupta
First published: July 2018
Production reference: 1300718
Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK.
ISBN 978-1-78953-946-2
www.packtpub.com
Mapt is an online digital library that gives you full access to over 5,000 books and videos, as well as industry leading tools to help you plan your personal development and advance your career. For more information, please visit our website.
Spend less time learning and more time coding with practical eBooks and Videos from over 4,000 industry professionals
Improve your learning with Skill Plans built especially for you
Get a free eBook or video every month
Mapt is fully searchable
Copy and paste, print, and bookmark content
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at [email protected] for more details.
At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters, and receive exclusive discounts and offers on Packt books and eBooks.
Joshua Eckroth is assistant professor of computer science at Stetson University, where he teaches big data mining and analytics, artificial intelligence (AI), and software engineering. Dr. Eckroth joined the math and computer science department at Stetson University in fall 2014. He earned his PhD from Ohio State University in AI and cognitive science, focusing on abductive reasoning and meta-reasoning.
If you're interested in becoming an author for Packt, please visit authors.packtpub.com and apply today. We have worked with thousands of developers and tech professionals, just like you, to help them share their insight with the global tech community. You can make a general application, apply for a specific hot topic that we are recruiting an author for, or submit your own idea.
Title Page
Copyright and Credits
Python Artificial Intelligence Projects for Beginners
Packt Upsell
Why subscribe?
PacktPub.com
Contributors
About the author
Packt is searching for authors like you
Preface
Who this book is for
What this book covers
To get the most out of this book
Download the example code files
Download the color images
Conventions used
Get in touch
Reviews
Building Your Own Prediction Models
Classification overview and evaluation techniques
Evaluation
Decision trees
Common APIs for scikit-learn classifiers
Prediction involving decision trees and student performance data
Summary
Prediction with Random Forests
Random forests
Usage of random forest
Predicting bird species with random forests
Making a confusion matrix for the data
Summary
Applications for Comment Classification
Text classification
Machine learning techniques
Bag of words
Detecting YouTube comment spam
Word2Vec models
Doc2Vec
Document vector
Detecting positive or negative sentiments in user reviews
Summary
Neural Networks
Understanding neural networks
Feed-forward neural networks
Identifying the genre of a song with neural networks
Revising the spam detector to use neural networks
Summary
Deep Learning
Deep learning methods
Convolutions and pooling
Identifying handwritten mathematical symbols with CNNs
Revisiting the bird species identifier to use images
Summary
Other Books You May Enjoy
Leave a review - let other readers know what you think
Artificial Intelligence (AI) is the newest emerging and disruptive technology among varied businesses, industries, and sectors. This book demonstrates AI projects in Python, covering modern techniques that make up the world of AI.
This book begins with building your first prediction model using the popular Python library, scikit-learn. You will understand how to build a classifier using effective machine learning techniques: random forest and decision trees. With exciting projects on predicting bird species, analyzing student performance data, song genre identification, and spam detection, you will learn the fundamentals and various algorithms and techniques that foster the development of such smart applications. You will also understand deep learning and the neural network mechanism through these projects with the use of the Keras library.
By the end of this book, you will be confident to build your own AI projects with Python and be ready to take on more advanced content as you go ahead.
This book is for Python developers who want to take their first step in the world of artificial intelligence using easy-to-follow projects. Basic working knowledge of Python programming is expected so that you can play around with the code.
Chapter 1, Building Your Own Prediction Models, introduces classification and techniques for evaluation, and then explains decision trees, followed by a coding project in which a predictor for student performance is built.
Chapter 2, Prediction with Random Forests, looks at random forests and uses them in a coding project for classifying bird species.
Chapter 3, Applications for Comment Classification, introduces text processing and the bag-of-words technique. Then shows how this technique can be used to build a spam detector for YouTube comments. Next, you will learn about the sophisticated Word2Vec model and practice it with a coding project that detects positive and negative product, restaurant, and movie reviews.
Chapter 4, Neural Networks, covers a brief introduction to neural networks, proceeds with feedforward neural networks, and looks at a program to identify the genre of a song with neural networks. Finally, you will revise the spam detector from earlier to make it work with neural networks.
Chapter 5, Deep Learning, discusses deep learning and CNNs. You will practice convolutional neural networks and deep learning with two projects. First, you will build a system that can read handwritten mathematical symbols and then revisit the bird species identifier and change the implementation to use a deep convolutional neural network that is significantly more accurate.
You need to have a basic understanding of Python and its scientific computing libraries
Get Jupyter Notebook installed, preferably via Anaconda
You can download the example code files for this book from your account at www.packtpub.com. If you purchased this book elsewhere, you can visit www.packtpub.com/support and register to have the files emailed directly to you.
You can download the code files by following these steps:
Log in or register at
www.packtpub.com
.
Select the
SUPPORT
tab.
Click on
Code Downloads & Errata
.
Enter the name of the book in the
Search
box and follow the onscreen instructions.
Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:
WinRAR/7-Zip for Windows
Zipeg/iZip/UnRarX for Mac
7-Zip/PeaZip for Linux
The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Python-Artificial-Intelligence-Projects-for-Beginners. In case there's an update to the code, it will be updated on the existing GitHub repository.
We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!
We also provide a PDF file that has color images of the screenshots/diagrams used in this book. You can download it here: http://www.packtpub.com/sites/default/files/downloads/PythonArtificialIntelligenceProjectsforBeginners_ColorImages.pdf.
There are a number of text conventions used throughout this book.
CodeInText: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: "The classes.txt file shows class IDs with the bird species names."
Bold: Indicates a new term, an important word, or words that you see onscreen. For example, words in menus or dialog boxes appear in the text like this.
Feedback from our readers is always welcome.
General feedback: Email [email protected] and mention the book title in the subject of your message. If you have questions about any aspect of this book, please email us at [email protected].
Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details.
Piracy: If you come across any illegal copies of our works in any form on the Internet, we would be grateful if you would provide us with the location address or website name. Please contact us at [email protected] with a link to the material.
If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit authors.packtpub.com.
Please leave a review. Once you have read and used this book, why not leave a review on the site that you purchased it from? Potential readers can then see and use your unbiased opinion to make purchase decisions, we at Packt can understand what you think about our products, and our authors can see your feedback on their book. Thank you!
For more information about Packt, please visit packtpub.com.
Our society is more technologically advanced than ever. Artificial Intelligence (AI) technology is already spreading throughout the world, replicating humankind. The intention of creating machines that could emulate aspects of human intelligence such as reasoning, learning, and problem solving gave birth to the development of AI technology. AI truly rivals human nature. In other words, AI makes a machine think and behave like a human. An example that can best demonstrate the power of this technology would be the tag suggestions or face-recognition feature of Facebook. Looking at the tremendous impact of this technology on today's world, AI will definitely become one of the greatest technologies out there in the coming years.
We are going to be experimenting with a project based on AI technology, exploring classification using machine learning algorithms along with the Python programming language. We will also explore a few examples for a better understanding.
In this chapter, we are going to explore the following interesting topics:
An overview of the classification technique
The Python scikit library
AI provides us with various classification techniques, but machine learning classification would be the best to start with as it is the most common and easiest classification to understand for the beginner. In our daily life, our eyes captures millions of pictures: be they in a book, on a particular screen, or maybe something that you caught in your surroundings. These images captured by our eyes help us to recognize and classify objects. Our application is based on the same logic.
Here, we are creating an application that will identify images using machine learning algorithms. Imagine that we have images of both apples and oranges, looking at which our application would help identify whether the image is of an apple or an orange. This type of classification can be termed as binary classification, which means classifying the objects of a given set into two groups, but techniques do exist for multiclass classification as well. We would require a large number of images of apples and oranges, and a machine learning algorithm that would be set in such a way that the application would be able to classify both image types. In other words, we make these algorithms learn the difference between the two objects to help classify all the examples correctly. This is known as supervised learning.
Now let's compare supervised learning with unsupervised learning. Let's assume that we are not aware of the actual data labels (which means we do not know whether the images are examples of apples or oranges). In such cases, classification won't be of much help. The clustering method can always ease such scenarios. The result would be a model that can be deployed in an application, and it would function as seen in the following diagram. The application would memorize facts about the distinction between apples and oranges and recognize actual images using a machine learning algorithm. If we took a new input, the model would tell us about its decision as to whether the input is an apple or orange. In this example, the application that we created is able to identify an image of an apple with a 75% degree of confidence:
Sometimes, we want to know the level of confidence, and other times we just want the final answer, that is, the choice in which the model has the most confidence.
We can evaluate how well the model is working by measuring its accuracy. Accuracy would be defined as the percentage of cases that are classified correctly. We can analyze the mistakes made by the model, or its level of confusion, using a confusion matrix. The confusion matrix refers to the confusion in the model, but these confusion matrices can become a little difficult to understand when they become very large. Let's take a look at the following binary classification example, which shows the number of times that the model has made the correct predictions of the object:
In the preceding table, the rows of True apple
