36,59 €
The essential blueprints and workflow you need to build successful AI business applications
Key Features
Book Description
AI Blueprints gives you a working framework and the techniques to build your own successful AI business applications. You'll learn across six business scenarios how AI can solve critical challenges with state-of-the-art AI software libraries and a well thought out workflow. Along the way you'll discover the practical techniques to build AI business applications from first design to full coding and deployment.
The AI blueprints in this book solve key business scenarios. The first blueprint uses AI to find solutions for building plans for cloud computing that are on-time and under budget. The second blueprint involves an AI system that continuously monitors social media to gauge public feeling about a topic of interest - such as self-driving cars. You'll learn how to approach AI business problems and apply blueprints that can ensure success.
The next AI scenario shows you how to approach the problem of creating a recommendation engine and monitoring how those recommendations perform. The fourth blueprint shows you how to use deep learning to find your business logo in social media photos and assess how people interact with your products. Learn the practical techniques involved and how to apply these blueprints intelligently. The fifth blueprint is about how to best design a 'trending now' section on your website, much like the one we know from Twitter. The sixth blueprint shows how to create helpful chatbots so that an AI system can understand customers' questions and answer them with relevant responses.
This book continuously demonstrates a working framework and strategy for building AI business applications. Along the way, you'll also learn how to prepare for future advances in AI. You'll gain a workflow and a toolbox of patterns and techniques so that you can create your own smart code.
What you will learn
Who this book is for
Programming AI Business Applications provides an introduction to AI with real-world examples. This book can be read and understood by programmers and students without requiring previous AI experience. The projects in this book make use of Java and Python and several popular and state-of-the-art opensource AI libraries.
Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:
Seitenzahl: 365
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 authors, 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.
Acquisition Editors: Frank Pohlmann, Suresh Jain, Andrew Waldron
Project Editor: Veronica Pais
Content Development Editor: Alex Sorrentino
Technical Editor: Saby D'silva
Proofreader: Safis Editing
Indexer: Priyanka Dhadke
Graphics: Tom Scaria
Production Coordinator: Sandip Tadge
First published: December 2018
Production reference: 2281218
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78899-287-9
www.packtpub.com
mapt.io
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.
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.Packt.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.Packt.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.
In retrospect, this book has been in the making for years. Stetson University, where I serve as an Assistant Professor of Computer Science, hosted its first annual hackathon in Spring 2016. The student organizers wanted faculty to give some lectures about programming and practical application development. AI was a hot topic then just as it is now, so I reached into my background in AI, including a PhD in the subject and multiple years of teaching an AI course in colleges, to develop a presentation I called AI/ML IRL, that is, artificial intelligence and machine learning in real life (AI/ML IRL, J. Eckroth, sudo HackStetson presentation, 2016, https://www2.stetson.edu/~jeckroth/downloads/eckroth-ai-irl-stetson-hackathon-2016.pdf). I covered current applications of AI, the fears and promises of AI, and concluded with advice about how to use AI in real-world applications. In this presentation may be found the seeds of the AI workflow developed in Chapter 1, The AI Workflow, and the discussion of the hype cycle in Chapter 8, Preparing for Your Future and Surviving the Hype Cycle.
Around the same time, my colleague and CEO at i2k Connect, Dr. Reid Smith, was awarded the Robert S. Engelmore Memorial Award, sponsored by the Innovative Applications in Artificial Intelligence conference and AI Magazine. Dr. Smith gave a presentation for this award (A Quarter Century of AI Applications: What we knew then vs. what we know now, R. G. Smith, Robert S. Engelmore Memorial Lecture Award, presented at the Twenty-Eighth Conference on Innovative Applications of Artificial Intelligence (IAAI-16), Phoenix, AZ, 15 February, 2016, http://www.reidgsmith.com/2016-02-15_Engelmore_Lecture.pdf), where he discussed numerous examples of successful AI applications and the lessons learned.
Dr. Smith and I discussed our separate contributions about the topic of programming AI applications and came together to write the cover article of the Spring 2017 AI Magazine (Building AI Applications: Yesterday, Today, and Tomorrow, R. G. Smith and J. Eckroth, AI Magazine 38(1): 6-22, Spring 2017, https://www.aaai.org/ojs/index.php/aimagazine/article/view/2709). This article examined a series of important deployed applications that made significant use of AI and machine learning. We also showed the increasing interest in AI, which I have updated for Chapter 5, A Blueprint for Detecting Your Logo in Social Media when I discuss deep learning. Most importantly, this article introduced some of the essential features of the AI workflow, including some checklist items to pay attention to when developing your own applications.
Jumping back to 2014 momentarily, Frank Pohlmann contacted me to write a book for another publisher. I agreed, and we developed an outline, but as I was just starting at Stetson University, I was swamped with other activities and had to cancel the plan. Three years later, Mr. Pohlmann was now a Managing Acquisition Editor for Packt and contacted me again. All of the developments I described above had occurred in the intervening time and I had more practice managing my time as a professor. The timing was right.
This book is different than any of those prior works. It focuses on programming realistic and useful AI applications with state-of-the-art software libraries and techniques. It also teaches the reader the fundamentals of the techniques we use throughout the book. But this book is the spiritual successor, and the culmination, of several years of thinking, writing, and speaking.
AI Blueprints could not have been written without the encouragement, insights, and close editorial attention from Frank Pohlmann, Reid Smith, and the staff at Packt. Another colleague at i2k Connect, Dr. Eric Schoen, graciously served as the technical reviewer of this work.
His decades of software engineering experience, including more than 30 years at Schlumberger and most recently as their Chief Software Architect, as well as a PhD in AI from Stanford University, helped refine the technical sophistication of the examples and explanations in this book.
As I'm sure every reader knows at some fundamental level, the time is right for AI. It has been for some time and will be for the foreseeable future. This book is designed to help you capture a bit of the magic of AI in your own applications.
Joshua Eckroth is an Assistant Professor of Computer Science at Stetson University, where he teaches AI, big data mining and analytics, and software engineering. He earned his PhD from The Ohio State University in AI and Cognitive Science. Dr. Eckroth also serves as Chief Architect at i2k Connect, which focuses on transforming documents into structured data using AI and enriched with subject matter expertise.
Dr. Eckroth has previously published two video series with Packt, Python Artificial Intelligence Projects for Beginners and Advanced Artificial Intelligence Projects with Python. His academic publications can be found on Google Scholar.
"I wish to express my gratitude to Dr. Eric Schoen, Director of Engineering at i2k Connect, for taking the time to carefully review each chapter. The rest of my colleagues at i2k Connect also gave me important feedback and new ideas along the way. I also wish to thank my wife for her encouragement and patience in a process that always seems to take longer than expected."
Eric Schoen is the Chief Technical Officer at i2k Connect, where he has overall responsibility for delivering its AI-powered information discovery platform. He plays a major role in ensuring its implementation, AI science, and processing algorithms are robust enough to enable operation at scale in cloud-based, on-premises, and hybrid installations. Before joining i2k Connect, Eric spent over 30 years at Schlumberger, in both research and engineering functions, most recently as its Chief Software Architect. At Schlumberger, he contributed to a broad range of software, from the company's early pioneering efforts to leverage knowledge-based systems and its GeoFrame and Ocean platforms for reservoir characterization, to its software quality processes and strategies for enterprise-scale architecture for data acquisition, transmission, processing, and delivery. Eric holds a PhD in computer science (AI) from Stanford University.
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.
Artificial intelligence (AI) is the hot new thing. Though AI has been around for 50 years, recent dramatic advances in the kinds of problems it can solve and the availability of open source software have opened it up to all programmers and organizations. AI technology can magnify the capabilities of an organization and its software, or open entirely new pursuits. For example, in Chapter 5, A Blueprint for Detecting Your Logo in Social Media, we show how to use deep learning to detect a company's logos in photos shared publicly on Twitter. Without such an AI tool, these photos would probably never be noticed, and the company would not be able to identify how their products and services connect with individuals' everyday lives. The data is there. Twitter, Reddit, news services, and others have public APIs that expose their continuous feeds of comments, photos, videos, news articles, and more. But nobody has time to look at all of that, and searches and filters do not work on photos. AI completely changes the rules.
My goal with this book is to change your expectation of where AI can be used in your applications, while giving you the power to build your own AI-powered applications. By covering a broad range of applications and technologies, I hope to show that there is not one single kind of AI (such as deep learning), nor a single kind of application.
We cover applications in planning (Chapter 2, A Blueprint for Planning Cloud Infrastructure), natural language processing (Chapter 3, A Blueprint for Making Sense of Feedback and Chapter 7, A Blueprint for Understanding Queries and Generating Responses), recommendation engines (Chapter 4, A Blueprint for Recommending Products and Services), deep learning (Chapter 5, A Blueprint for Detecting Your Logo in Social Media), logic programming (Chapter 7, A Blueprint for Understanding Queries and Generating Responses), and trend and anomaly detection (Chapter 6, A Blueprint for Discovering Trends and Recognizing Anomalies).
These applications show AI can help an organization with logistics and automation, customer relations, and marketing. These applications are not designed to replace human workers – instead, each project automates tedious aspects of work and provides new insights to knowledge workers. For example, Chapter 3, A Blueprint for Making Sense of Feedback shows how to analyze social media comments and news articles to gather detailed data about sentiment (positive or negative) about certain topics of interest. With this data, marketing experts can gauge whether a marketing campaign was successful, for example, or make an informed judgment about when to introduce a new product.
The time for AI is now. We are presently in an era where the (justified) hype for AI is strong. Consider these hypothetical headlines: "Hospital begins using AI to help with cancer diagnosis," "University uses AI to ensure on-time graduation," "Marketing firm builds AI to better target consumers," "Airline streamlines boarding process with AI." Each headline refers to some improvement, and AI is suggested to be the cause of the improvement. But what if we had replaced "uses AI" or "builds AI" with "adds staff" or "hires firm"? For example, "Airline streamlines boarding process with more gate agents and roped walkways..." It would feel like more of the same, not a revolutionary new approach.
There is something about AI that gives it a mysterious, optimistic, dreamy quality. AI can do anything! And whatever it does, it will be completely novel! Even if AI determined that a streamlined airplane boarding process can be accomplished by more roped walkways, travelers would likely marvel at the result.
"AI found this to be the optimal configuration!" In some sense, the more alien the result, the more likely we are to believe it came from AI and it is indeed optimal.
But they're not wrong. AI is different. AI is perpetually new. AI always promises that something we could not do yesterday can now be done with ease. Again, they're not wrong, though the hype can run away with itself sometimes.
I hope this book shows that AI is the future, it is available now, and it is here to stay.
This book is targeted at software engineers who are familiar with Java and Python and wish to learn how to use artificial intelligence and machine learning in their code. This book is not just a list of techniques and algorithms, however. Every example project includes a detailed discussion of integration and deployment strategies and techniques for continuous evaluation of the AI after it is deployed. The projects and suggested workflow target small/medium businesses and startup companies that wish to introduce advanced capabilities and automation into an existing platform.
Chapter 1, The AI Workflow, introduces the AI workflow, which is a series of four steps in a mature process for building and deploying AI. This chapter also discusses the role of AI in context of a larger software system. The chapter ends with an introduction to each of the projects developed in Chapter 2, A Blueprint for Planning Cloud Infrastructure to Chapter 7, A Blueprint for Understanding Queries and Generating Responses.
Chapter 2, A Blueprint for Planning Cloud Infrastructure, shows how to use the open source OptaPlanner constraint solver planning engine to create a plan for cloud computing resources.
Given a time and money budget and a set of computing tasks to complete, this chapter develops a Java-based solution for the optimal number of cloud resources to complete the tasks in the shortest time and lowest budget. Benchmarks are detailed to show that the solution is accurate. Each step of the AI workflow is addressed to help readers prepare to deploy the solution.
Chapter 3, A Blueprint for Making Sense of Feedback, shows how to acquire feedback from customers and the general public about a company's products and services, and how to identify the sentiment, or general mood, of the feedback for particular products, services, or categories. The Twitter and Reddit APIs are demonstrated for acquiring feedback.
Two approaches are demonstrated for sentiment analysis: a dictionary-based approach and a method using machine learning with the CoreNLP library. The sentiment data is then visualized with plotly.js in a dashboard view for real-time updates. Each step of the AI workflow is addressed to help readers prepare to deploy the solution.
Chapter 4, A Blueprint for Recommending Products and Services, shows how to build and deploy a recommendation engine for products and services. Given a history of all user activity (purchases, clicks, ratings), a system is designed that can produce appropriate recommendations for individual users. An overview of the relevant mathematics is included, and the Python implicit library is used for building the solution. A continuous evaluation methodology is detailed to ensure the recommender continues to provide appropriate recommendations after it is deployed. Each step of the AI workflow is addressed to help readers prepare to deploy the solution.
Chapter 5, A Blueprint for Detecting Your Logo in Social Media, shows how to build a convolutional neural network (CNN) to detect logos in other people's photos. Using the Python library TensorFlow, readers are shown how to take an existing pre-trained object recognition model such as Xception and refine it for detecting specific objects using a small training set of images. We also demonstrate the use of YOLO and compare results.
Then the Twitter API code from Chapter 3, A Blueprint for Making Sense of Feedback is reused to acquire images from social media, and the detector is run on these images to pick out photos of interest. A short introduction to CNNs and deep learning is included. Each step of the AI workflow is addressed to help readers prepare to deploy the solution.
Chapter 6, A Blueprint for Discovering Trends and Recognizing Anomalies, explains how to discover and track trends on a blog, storefront, or social media platform, as well as recognizing anomalous events that defy the trends. Using statistical models and anomaly detection algorithms, code is developed with the Python library scikit-learn. Different approaches are compared to address different use cases. Each step of the AI workflow is addressed to help readers prepare to deploy the solution.
Chapter 7, A Blueprint for Understanding Queries and Generating Responses, shows how to build and deploy an automated helpdesk chatbot. Using the Rasa Python library and Prolog coding, two custom chatbots are developed that examine the user's question and construct an appropriate answer using natural language generation. The Prolog code helps us develop a logical reasoning agent that is able to answer complex questions. Each step of the AI workflow is addressed to help readers prepare to deploy the solution.
Chapter 8, Preparing for Your Future and Surviving the Hype Cycle, examines the current state and near future of artificial intelligence. It examines the hype cycle and the dramatic shifts in popular interest in AI over the years and provides guidance for how to be successful in such unpredictable environments. The chapter includes advice for how to identify new approaches and advances in AI and how to decide whether or not these advances are relevant for real business needs.
This book uses state-of-the-art techniques and software libraries. For whatever reason, the original development of these libraries is typically done on Linux or macOS machines before being ported to Windows. Thus, it is possible some libraries might be difficult to install on a Windows machine, though Microsoft's Ubuntu on Windows 10 technology is helping close this gap. For example, TensorFlow has supported Windows for several years but difficulties installing it remained even in 2017 (https://github.com/tensorflow/tensorflow/issues/42).
Libraries are rapidly changing, so there is little use in detailing installation procedures in this Preface. A list of required libraries for each chapter are provided on this book's code repository: https://github.com/PacktPublishing/ProgrammingAIBusinessApplications. Installation procedures differ for each library and sometimes change as new versions are released. These instructions may be found on the library's linked homepage.
I intentionally chose to use state-of-the-art libraries even though they undergo rapid development and change. This change is usually for the better, but sometimes new versions break existing code or cannot be installed without some effort. However, I felt that it would not be helpful to write a book about old technology. For example, all Python applications in this book use Python 3.6 (or later) even though many may still work with minor changes in a Python 2.7 environment. Likewise, we use TensorFlow 1.10, the latest release at the time of writing. Books with code designed for TensorFlow 0.12, for example, will need significant updates, even though 0.12 was released less than two years ago.
Speaking of TensorFlow, if you have a GPU, you will find the code we develop in Chapter 5, A Blueprint for Detecting Your Logo in Social Media to be significantly more efficient, and better (more expensive) GPUs give even more performance gains. Even so, TensorFlow will still work with just a CPU.
You can download the example code files for this book from your account at http://www.packt.com. If you purchased this book elsewhere, you can visit http://www.packt.com/support and register to have the files emailed directly to you.
You can download the code files by following these steps:
Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:
The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/ProgrammingAIBusinessApplications. 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: https://www.packtpub.com/sites/default/files/downloads/9781788992879_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. For example; "Mount the downloaded WebStorm-10*.dmg disk image file as another disk in your system."
A block of code is set as follows:
When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:
Any command-line input or output is written as follows:
Bold: Indicates a new term, an important word, or words that you see on the screen, for example, in menus or dialog boxes, also appear in the text like this. For example: "Select System info from the Administration panel."
Warnings or important notes appear like this.
Tips and tricks appear like this.
Feedback from our readers is always welcome.
General feedback: If you have questions about any aspect of this book, mention the book title in the subject of your message and 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, http://www.packt.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 http://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 packt.com.
Like so many technologies before and surely an infinite progression of technologies to come, artificial intelligence (AI) is the promising idea du jour. Due to recent advances in hardware and learning algorithms, new commercial-grade software platforms, and a proliferation of large datasets for training, any software developer can build an intelligent system that sees (for example, face recognition), listens (for example, writing emails by voice), and understands (for example, asking Amazon's Alexa or Google Home to set a reminder). With free off-the-shelf software, any company can have their own army of chatbots, automated sales agents customized to each potential customer, and a team of tireless web bots that scan the media for mentions and photos and videos of a company's products, among other use cases. All of these solutions may be built by regular software developers in regular companies, not just researchers in well-funded institutions.
But any seasoned professional knows that the risk associated with technology is proportional to its newness, complexity, and the number of exclamation points in its marketing copy. Tried-and-true techniques are low risk but might keep a company from taking advantage of new opportunities. AI, like any promise of intelligent automation, must be built and deployed with a specific business outcome in mind. One must have a detailed plan for integrating it into existing workflows and procedures, and should regularly monitor it to ensure the context in which the AI was deployed does not gradually or dramatically change, rendering the AI either useless, or worse, a rogue agent run amok..
This book combines practical AI techniques with advice and strategies for successful deployment. The projects are aimed at small organizations that want to explore new uses of AI in their organizations. Each project is developed to work in a realistic environment and solve a useful task. While virtually all other books, videos, courses, and blogs focus solely on AI techniques, this book helps the reader ensure that the AI makes sense and continues to work effectively.
In this first chapter, we're going to cover:
"The passion caused by the great and sublime in nature, when those causes operate most powerfully, is astonishment; and astonishment is that state of the soul, in which all its motions are suspended, with some degree of horror. [...] When danger or pain press too nearly, they are incapable of giving any delight and are simply terrible; but at certain distances, and with certain modifications, they may be, and they are delightful, as we every day experience."
– Edmund Burke(Philosophical Enquiry into the Origin of our Ideas of the Sublime and the Beautiful, 1757)
Edmund Burke's careful study of the distinctions between what is aesthetically pleasing or beautiful versus what is compelling, astonishing, frightening, and sublime is an appropriate metaphor for the promises and the fears engendered by AI. At certain distances, that is, with the right design and careful deployment, AI has that quality that makes one marvel at the machine. If borne from a fear of being left behind or deployed haphazardly, if developed to solve a problem that does not exist, AI is a fool's game that can severely damage a company or brand.
Curiously, some of our top thinkers and entrepreneurs appear to be anxious about the careful balance between delight and horror. They have cautioned the world:
"Success in creating AI would be the biggest event in human history […] Unfortunately; it might also be the last."
– Stephen Hawking (https://futurism.com/hawking-creating-ai-could-be-the-biggest-event-in-the-history-of-our-civilization/)
"I think we should be very careful about artificial intelligence. If I were to guess at what our biggest existential threat is, it's probably that."
– Elon Musk (https://www.theguardian.com/technology/2014/oct/27/elon-musk-artificial-intelligence-ai-biggest-existential-threat)
"First the machines will do a lot of jobs for us and not be super intelligent. That should be positive if we manage it well. A few decades after that though the intelligence is strong enough to be a concern. I agree with Elon Musk and some others on this and don't understand why some people are not concerned."
– Bill Gates (https://www.reddit.com/r/IAmA/comments/2tzjp7/hi_reddit_im_bill_gates_and_im_back_for_my_third/co3r3g8/)
The fear of AI seems to be rooted in a fear of loss of control. Once the AI is "smart enough," it is thought that the AI will no longer obey our commands. Or it will make its own disastrous decisions and not inform us. Or it will hide critical information from us and make us subjects to its all-powerful will.
But these concerns may be flipped around to benefits: a smart AI can inform us of when we are making a bad decision and prevent embarrassments or catastrophes; it can automate tedious tasks such as making cold calls to open a sales channel; it can aggregate, summarize, and highlight just the right information from a deluge of data to help us make more informed and appropriate decisions. In short, good AI may be distinguished from bad AI by looking at its design, whether there are bugs or faults, its context of use in terms of correct inputs and sanity checks on its outputs, and the company's continuous evaluation methodology to keep track of the performance of the AI after it is deployed. This book aims to show readers how to build good AI by following these practices.
Although this book includes detailed discussion and code for a variety of AI techniques and use cases, the AI component of a larger system is usually very small. This book introduces planning and constraint solving, natural language processing (NLP), sentiment analysis, recommendation engines, anomaly detection, and neural networks. Each of these techniques is sufficiently exciting and complex to warrant textbooks, PhDs, and conferences dedicated to their elucidation and study. But they are a very small part of any deployed software system.
Consider the following diagram, showing some everyday concerns of a modern software developer:
Although probably the most interesting part of a project, the AI component is often the least troublesome part of software development. As we will see throughout this book, AI techniques are often contained in a single project module or class or function. The performance of the AI component depends almost entirely on the appropriateness of the inputs and correct handling and cleanup of the outputs.
For example, an AI component that determines the sentiment, positive or negative, of a tweet or product review is relatively straightforward to implement, particularly with today's AI software libraries (though the code in the library is quite complex). On the other hand, acquiring the tweets or reviews (likely involving authentication and rate limiting), formatting and cleaning the text (especially handling odd Unicode characters and emojis), and saving the output of sentiment analysis into a database for summarization and real-time visualization takes far more work than the "intelligent" part of the whole process.
But the AI is the most interesting part. Without it, there is no insight and no automation. And particularly in today's hyped environment with myriad tools and techniques and best practices, it is easy to get this part wrong. This book develops an AI workflow to help ensure success in building and deploying AI.
Building and deploying AI should follow a workflow that respects the fact that the AI component fits in the larger context of pre-existing processes and use cases. The AI workflow may be characterized as a four step process:
To help you ensure the AI workflow is followed, we offer a checklist of considerations and questions to ask during each step of the workflow.
Given the excitement around AI, there is a risk of adding AI technology to a platform just for the sake of not missing out on the next big thing. However, AI technology is usually one of the more complex components of a system, hence the hype surrounding AI and the promise of advanced new capabilities it supposedly brings. Due to its complexity, AI introduces potentially significant technical debt, that is, code complexity that is hard to manage and becomes even harder to eliminate. Often, the code must be written to message inputs to the AI into a form that meets its assumptions and constraints and to fix outputs for the AI's mistakes.
Engineers from Google published an article in 2014 titled Machine Learning: The High-Interest Credit Card of Technical Debt (https://ai.google/research/pubs/pub43146), in which they write:
In this paper, we focus on the system-level interaction between machine learning code and larger systems as an area where hidden technical debt may rapidly accumulate. At a system level, a machine learning model may subtly erode abstraction boundaries. It may be tempting to re-use input signals in ways that create unintended tight coupling of otherwise disjoint systems. Machine learning packages may often be treated as black boxes, resulting in large masses of "glue code" or calibration layers that can lock in assumptions. Changes in the external world may make models or input signals change behavior in unintended ways, ratcheting up maintenance cost and the burden of any debt. Even monitoring that the system as a whole is operating as intended may be difficult without careful design.
Machine Learning: The High-Interest Credit Card of Technical Debt, D. Sculley, G. Holt, D. Golovin, E. Davydov, T. Phillips, D. Ebner, V. Chaudhary, and M. Young, presented at the SE4ML: Software Engineering for Machine Learning (NIPS 2014 Workshop), 2014
They proceed to document several varieties of technical debt that often come with AI and machine learning (ML) technology and suggest mitigations that complement those covered in our AI workflow.
AI should address a business problem that is not solvable by conventional means. The risk of technical debt is too high (higher than many other kinds of software practices) to consider adding AI technology without a clear purpose.
The problem being addressed with AI should be known to be solvable. For example, until recent advances found in Amazon Echo and Google Home, speech recognition in a large and noisy room was not possible. A few years ago, it would have been foolish to attempt to build a product that required this capability.
The AI component should be well-defined and bounded. It should do one or a few tasks, and it should make use of established algorithms, such as those detailed in the following chapters. The AI should not be treated as an amorphous intelligent concierge that solves any problem, specified or unspecified. For example, our chatbot case study in Chapter 7, A Blueprint for Understanding Queries and Generating Responses, is intentionally designed to handle a small subset of possible questions from users. A chatbot that attempts to answer all questions, perhaps with some kind of continuous learning based on the conversations users have with it, is a chatbot that has a high chance of embarrassing its creators, as was the case with Microsoft's Tay chatbot (https://blogs.microsoft.com/blog/2016/03/25/learning-tays-introduction/).
In summary, the AI should solve a business problem, it should use established techniques that are known to be able to solve the problem, and it should have a well-defined and bounded role within the larger system.
After characterizing the problem to be solved, a method for solving the problem must be found or developed. In most cases, a business should not attempt to engage in a greenfield research project developing a novel way to solve the problem. Such research projects carry significant risk since an effective solution is not guaranteed within a reasonable time. Instead, one should prefer existing techniques.
This book covers several existing and proven techniques for a variety of tasks. Many of these techniques, such as planning engines, natural language part-of-speech tagging, and anomaly detection, are much less interesting to the AI research community than some newer methods, such as convolutional neural networks (CNN). But these older techniques are still quite useful. These techniques have "disappeared in the fabric," to use a phrase Dr. Reid Smith, Fellow of the Association for the Advancement of Artificial Intelligence (AAAI), and I wrote in an article for AI Magazine titled, Building AI Applications: Yesterday, Today, and Tomorrow in 2017 (https://www.aaai.org/ojs/index.php/aimagazine/article/view/2709) (Building AI Applications: Yesterday, Today, and Tomorrow, R. G. Smith and J. Eckroth, AI Magazine, vol. 38, no. 1, pp. 6–22, 2017). What is sometimes called the "AI Effect" is the notion that whatever has become commonplace is no longer AI but rather everyday software engineering (https://en.wikipedia.org/wiki/AI_effect). We should measure an AI technique's maturity by how "boring" it is perceived to be, such as boring, commonplace heuristic search and planning. Chapter 2, A Blueprint for Planning Cloud Infrastructure, solves a real-world problem with this kind of boring but mature AI.
Finally, when developing a method, one should also take care to identify computation and data requirements. Some methods, such as deep learning, require a significant amount of both. In fact, deep learning is virtually impossible without some high-end graphics processing units (GPU) and thousands to millions of examples for training. Often, open source libraries such as CoreNLP will include highly accurate pre-trained models so the challenge of acquiring sufficient data for training purposes can be avoided. In Chapter 5, A Blueprint for Detecting Your Logo in Social Media, we demonstrate a means of customizing a pre-trained model for a custom use case with what is known as "transfer learning."
Even the most intelligent AI may never be used. It is rare for people to change their habits even if there is an advantage in doing so. Finding a way to integrate a new AI tool into an existing workflow is just as important to the overall AI workflow as making a business case for the AI and developing it. Dr. Smith and I wrote:
Perhaps the most important lesson learned by AI system builders is that success depends on integrating into existing workflows — the human context of actual use. It is rare to replace an existing workflow completely. Thus, the application must play nicely with the other tools that people use. Put another way, ease of use delivered by the human interface is the "license to operate." Unless designers get that part right, people may not ever see the AI power under the hood; they will have already walked away.
Building AI Applications: Yesterday, Today, and Tomorrow, R. G. Smith and J. Eckroth, AI Magazine, vol. 38, no. 1, Page 16, 2017
Numerous examples of bad integrations exist. Consider Microsoft's "Clippy," a cartoon character that attempted to help users write letters and spell check their document. It was eventually removed from Microsoft Office (https://www.theatlantic.com/technology/archive/2015/06/clippy-the-microsoft-office-assistant-is-the-patriarchys-fault/396653/). While its assistance may have been useful, the problem seemed to be that Clippy was socially awkward, in a sense. Clippy asked if the user would like help at nearly all the wrong times:
Clippy suffered the dreaded "optimization for first-time use" problem. That is, the very first time you were composing a letter with Word, you might possibly be grateful for advice about how to use various letter-formatting features. The next billion times you typed "Dear..." and saw Clippy pop up, you wanted to scream.
(https://www.theatlantic.com/technology/archive/2008/04/-quot-clippy-quot-update-now-with-organizational-anthropology/8006/)
In a more recent example, most smartphone users do not use Apple Siri or Google Home, especially not in public (What can I help you with?: Infrequent users' experiences of intelligent personal assistants, B. R. Cowan, N. Pantidi, D. Coyle, K. Morrissey, P. Clarke, S. Al-Shehri, D. Earley, and N. Bandeira, presented at the 19th International Conference on Human-Computer Interaction with Mobile Devices and Services, New York, New York, USA, 2017, pp. 43–12). Changing social norms in order to increase adoption of a product is a significant marketing challenge. On the other hand, to "google" something, which clearly involves AI, is a sufficiently entrenched activity that it is defined as a verb in the Oxford English Dictionary ("Google, v.2'" OED Online, January 2018, Oxford University Press, http://www.oed.com/view/Entry/261961?rskey=yiwSeP&result=2&isAdvanced=false). Face recognition and automatic tagging on Facebook have been used by millions of people. And we click product recommendations on Amazon and other storefronts without a second thought. We have many everyday workflows that have evolved to include AI.
As a general rule, it is easier to ask users to make a small change to their habits if the payoff is large; and it is hard or impossible to ask users to make a large change to their habits or workflow if the payoff is small.
In addition to considering the user experience, effective deployment of AI also requires that one considers its placement within a larger system. What kinds of inputs are provided to the AI? Are they always in the right format? Does the AI have assumptions about these inputs that might not be met in extreme circumstances? Likewise, what kinds of outputs does the AI produce? Are these outputs always within established bounds? Is anything automated based on these outputs? Will an email be sent to customers based on the AI's decisions? Will a missile be fired?
As discussed in the preceding section, AI isn't everything, often a significant amount of code must be written around the AI component. The AI probably has strong assumptions about the kind of data it is receiving. For example, CNNs can only work on images of a specific, fixed size – larger or smaller images must be squished or stretched first. Most NLP techniques assume the text is written in a particular language; running part-of-speech tagging with an English model on a French text will produce bogus results.
