Do Machine Learning Yourself with Python
Do Machine Learning Yourself with Python
About the Book
Do Machine Learning Yourself is a collection of do it yourself (DIY) projects about machine learning, mainly about computer vision, for beginner and intermediate levels. Through a detailed guidance per each project, everything required to do that project yourself will be clear. One primary focus of the book is to make machine learning available for mobile devices.
The book is organized into 8 chapters where each chapter handles a topic.
Chapter 1 is about doing some machine learning projects using OpenCV. Because OpenCV is a cross-platform library, then the projects can run on both desktop and mobile devices. For such a reason, the book builds the project for running in Android devices.
Chapter 2 builds 3 computer vision projects for Raspberry Pi. This includes preparing Raspberry Pi for first-time use in order to be able to access it and install some Python libraries. A USB camera is connected to the Raspberry Pi to capture images for building a surveillance system and also a simple robot car.
Chapter 3 discusses some topics about neural network such as selecting the best architecture that works for a given data. Also, a neural network is created in Keras that is deployed to a Flask server. An Android client uploads images to be classified by the trained Keras model and then return the response.
Chapter 4 uses the genetic algorithm for building doing some optimization. This includes optimizing the 8 queen puzzle to reach a solution. Besides that project, the algorithm is used for reproducing images by evolving the pixel values.
Chapter 5 uses a framework named Kivy for building GUI Python applications. Based on the Kivy app, cross-platform applications can be generated. This book focuses on building Android applications with the help of 2 projects named Python-4-Android and Buildozer. Kivy allows some Python libraries to be executed in Android such as NumPy which is one of the most important libraries for building data science applications. An image classifier is created in Python that is able to work in Android using NumPy. The book also discusses supporting the Arabic text with Kivy.
Chapter 6 uses OpenCV for building an Android application able to do some image effects. The effects supported are horizontal and vertical image stitching, reducing the number of colors representing the both color and gray images by editing the lookup tables, noise removal using the median filter, converting images to binary, cartooning images, image blending using the alpha channel, creating animated GIF image from a number of images, and creating image patterns.
Chapter 7 builds a chat application for Android devices for sending and receiving text messages. The app allows users to register themselves by entering their information that includes a username, password, and e-mail. One the e-mail address is verified, the user is registered and able to send and receive messages. The project starts by building the database and the tables for holding the users' data and also the messages. A Flask-based server is created that is connected to the Android app. The project supports instant notifications for new messages and encryption.
Chapter 8 lists some miscellaneous topics about machine learning. This includes a discussion about how machine learning is not killed by the appearance of deep learning. Also, this chapter guides beginners to understand how ensemble algorithms work and understand the difference between bagging and boosting ensemble models. The gradient boosting algorithm is discussed which is an application of ensemble boosting.
Table of Contents Preface Acknowledgment About the Author Table of Contents Chapter 1: Machine Learning with OpenCV A Guide to Preparing OpenCV for Android Overview of OpenCV Building an Android Studio Project Running the Project Editing the Project to Display a Toast Message Downloading OpenCV Importing OpenCV in Android Studio Fixing Possible Gradle Sync Errors Adding OpenCV as a Dependency Adding Native Libraries Using OpenCV for Filtering Images Summary Running Artificial Neural Networks in Android using OpenCV Creating a New Java Application in NetBeans Downloading OpenCV for Windows Importing OpenCV in NetBeans Solving the UnsatisfiedLinkError Preparing the Training Data Building the ANN (Architecture and Parameters) Training the ANN Loading and Testing the Trained ANN in NetBeans Building an Android Studio Project Loading the Trained ANN in Android Studio and Making Predictions Conclusion Image Classification on Android using OpenCV Preparing the Image Dataset Image Feature Extraction (Color Histogram) Building, Training, and Saving the ANN Making Predictions by Loading the Saved ANN Building an Android App Predicting the Class Label of the Image in Android Project at GitHub Chapter 2: Machine Learning for Raspberry Pi Building an Image Classifier Running on Raspberry Pi Raspberry Pi Network Configuration Secure Shell Login X11 Windowing System Image Classification For More Details Building Surveillance System using USB Camera and Wireless-Connected Raspberry Pi Connecting RPi to a PC using the Wireless Interface Connecting a USB Camera to RPi Capturing Images using PyGame Building the Background Model Detecting Changes to the Background Model Building a Simple Circuit that Lights a Led When a Change Occurs For More Details Building a Vision-Controlled Car Using Raspberry Pi—From Scratch Preparing the Car Components Fixing the Components on the Wood Plank Understanding the Circuit Connected to the Motor Building the Circuit on the BB using Transistors, Resistors, and Diodes Connecting the BB to the Raspberry Pi GPIO Pins Accessing the Raspberry Pi Controlling the Car’s Motors Connecting a USB Camera to the Raspberry Pi Controlling the Motors using the Camera For More Details Chapter 3: Neural Networks Selecting the Best Architecture for Artificial Neural Networks Example 1 Python Implementation Example 2 Conclusion Uploading images from Android to a Python-based Flask server Building the Layout of the Android App Using OkHttp for building the client-side Android app Building the server-side Python app using Flask Testing the connection between Android and Flask Selecting an image from Android storage Modifying the Flask app to save an uploaded image Conclusion Image Classification on Android using a Keras Model Deployed in Flask Preparing the MNIST Dataset Building the MLP Training the MLP Saving the Model Loading the Model and Making Predictions Editing the Flask Server to Classify Uploaded Images Conclusion Chapter 4: Optimization with Genetic Algorithm 8 Queen Puzzle Optimization Using a Genetic Algorithm in Python 8 Queen Puzzle Review Building the 8x8 Board using Kivy Adding Widgets to Control the Project Initializing the Population Visualizing the Best Solution with a Population Optimization using GA Running the Project Reproducing Images using Genetic Algorithm with Python Further Reading about GA and its Python Implementation Genetic Algorithm Steps Data Representation Python Code for Converting the Image into a Chromosome and Vice Versa Initial Population Fitness Calculation Parent Selection Crossover Mutation Project Example Conclusion + 2 Helper Functions Chapter 5: Python for Android with Kivy Python for Android: Start Building Kivy Cross-Platform Applications Introduction Installing Kivy Dependencies Creating Virtual Environment for Installing Kivy Installing Cython Installing Kivy Importing Kivy Creating Simple Kivy Application Installing Buildozer Creating buildozer.spec File Building Android Application using Buildozer References Running NumPy in Android Devices using the Kivy Python Framework Introduction Kivy Installation for Linux Installing Kivy in a Virtual Environment Importing Kivy Creating a Basic Application Python for Android Installing Buildozer Preparing buildozer.spec File Building an Android Application using Buildozer Image Classification for Android Devices Using NumPy and Kivy For More Information ANN Architecture Creating the Widget Tree using the KV Language Creating the Kivy Application Using the Proper NumPy Version Building the Android Application Supporting Arabic Alphabet in Kivy for Building Cross-Platform Applications Introduction Displaying Arabic Text on a Label Widget Using a Font that Supports the Arabic Alphabet Changing the Text Direction using BIDI Algorithm Reshaping the Text using the Python Arabic Reshaper Library Editing the TextInput Class FileChooser Conclusion Chapter 6: Image Effects using OpenCV for Android Vertical and Horizontal Stitching Preparing OpenCV for Android Image Stitching Horizontal Image Stitching Horizontal Stitching Implementation Saving Images to the Gallery Uploading Images from Android to a Flask Server Vertical Image Stitching Conclusion Cartoon Effect What is LUT? OpenCV Built-in LUTs Color Reduction using LUT for Gray Images Color Reduction Using LUT for Color Images Using a Single LUT for All Color Image Channels Using a Single LUT for Each Color Channel Adaptive Thresholding Noise Removal Using Median Filter Cartoon Effect Building Android App Conclusion Image Blending What is Alpha Channel? Working with Alpha Channel in OpenCV Image Blending Region Blending Building the Android App Conclusion Animated GIF Using GridLayout Selecting a Single Image Selecting More than One Image Applying Effects Using Selected Images Reading Multiple Images for Multi-Image Effects Create Animated GIF Building Android App Conclusion Image Pattern A Review about 2D Convolution Creating Patterns Adding a Pattern to an Image Editing Android Studio Project Conclusion Chapter 7: Chat Application for Android Android Login System Creating the MySQL Database Connecting to MySQL Returning a Cursor Executing Operations Creating a Table for the Users Data Building the Flask Server Building the Android App Main Screen Registration Activity Login Activity Testing the System Conclusion E-mail Verification for an Android Registration System Sending E-mails using Python Verification Code Text Encryption Generating Encryption Keys Verifying Code Text Decryption Adding an EditText for E-mail in the Android App Conclusion Sending Text Messages for Android between Verified Users Chapter 8: Others Do New Technologies Kill their Ancestors? Intuitive Ensemble Learning Guide with Gradient Boosting as a Study Case Introduction Ensemble Learning Gradient Boosting (GB) Summary of GB
The Leanpub 60-day 100% Happiness Guarantee
Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.
See full terms
80% Royalties. Earn $16 on a $20 book.
We pay 80% royalties. That's not a typo: you earn $16 on a $20 sale. If we sell 5000 non-refunded copies of your book or course for $20, you'll earn $80,000.
(Yes, some authors have already earned much more than that on Leanpub.)
In fact, authors have earnedover $12 millionwriting, publishing and selling on Leanpub.
Learn more about writing on Leanpub
Free Updates. DRM Free.
If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).
Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.
Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.