1. Trang chủ
  2. » Công Nghệ Thông Tin

Machine learning google platform hands 13 pdf

649 175 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 649
Dung lượng 26,32 MB

Nội dung

Hands-On Machine Learning on Google Cloud Platform Implementing smart and efficient analytics using Cloud ML Engine Giuseppe Ciaburro V Kishore Ayyadevara Alexis Perrier BIRMINGHAM - MUMBAI Hands-On Machine Learning on Google Cloud Platform 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 Commissioning Editor: Sunith Shetty Acquisition Editor: Tushar Gupta Content Development Editor: Cheryl Dsa Technical Editor: Dinesh Pawar Copy Editor: Vikrant Phadkay Project Coordinator: Nidhi Joshi Proofreader: Safis Editing Indexer: Mariammal Chettiyar Graphics: Tania Dutta Production Coordinator: Arvindkumar Gupta First published: April 2018 Production reference: 1260418 Published by Packt Publishing Ltd Livery Place 35 Livery Street Birmingham B3 2PB, UK ISBN 978-1-78839-348-5 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 Why subscribe? 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 PacktPub.com 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 service@packtpub.com 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 Contributors About the authors Giuseppe Ciaburro holds a PhD in environmental technical physics and two master's degrees His research is on machine learning applications in the study of urban sound environments He works at Built Environment Control Laboratory, Università degli Studi della Campania Luigi Vanvitelli (Italy) He has over 15 years' experience in programming Python, R, and MATLAB, first in the field of combustion, and then in acoustics and noise control He has several publications to his credit V Kishore Ayyadevara has over years' experience of using analytics to solve business problems and setting up analytical work streams through his work at American Express, Amazon, and, more recently, a retail analytics consulting startup He has an MBA from IIM Calcutta and is also an electronics and communications engineer He has worked in credit risk analytics, supply chain analytics, and consulting for multiple FMCG companies to identify ways to improve their profitability Alexis Perrier is a data science consultant with experience in signal processing and stochastic algorithms He holds a master's in mathematics from Université Pierre et Marie Curie Paris VI and a PhD in signal processing from Télécom ParisTech He is actively involved in the DC data science community He is also an avid book lover and proud owner of a real chalk blackboard, where he regularly shares his fascination of mathematical equations with his kids Agents An agent is a program that responds to a specific task It could be a hostess for hotel room reservations Or it could be a business expert who knows all the products and price lists of an online store Or it could a competent support technician for the household appliances we purchased Or it could be the onboard computer of a car What is important is that an agent has a specific purpose and a limited baggage of knowledge; we are not interested in playing chess with the bot that makes flight bookings, and in any case it would not be able to so With Dialogflow, the creation of an agent is very simple; just go to the initial page of the service, click on the CREATE AGENT button, and give it a name, as shown in the following screenshot: To access Dialogflow, just use the URL https://dialogflow.com/ You can register or use a Google account and log in Intent An intent is what an end user can ask an agent Booking a hotel room is an intent; another intent is the consultation of lunch hours, or the cancellation of a reservation that is already made Understanding what the user's request is is the intelligent part of the agent because there are many ways in which a request can be expressed in natural language, that is, what we humans talk about The agent will try to interpret the user's request by identifying the closest intent Naturally, the association is not always precise; in fact a ranking of possible interpretations is returned But, from this point of view, we can improve the answers by providing more alternative examples of the same requests Also it is possible to apply machine learning algorithms in order to learn from the previous answers Entity If an intent matches a request, the entity corresponds to the details In booking a hotel room you need to know the exact date, the people who will stay, or the user's requests From the design point of view of the agent, an entity such as hotel room is defined and it contains all the necessary details Dialogflow has a series of already-created system entities that facilitate the management of simpler concepts (for example, dates) The developer can define a series of entities (Dev entity) to generalize the behavior of the agent Finally, the end user creates an entity for each request A Dev entity can have values determined by a list, perform a mapping, or be in turn made up of other entities, and much more Action Until now, we have dealt with interpreting the user's request; now it is a matter of answering In reality, the concept is broader; once we have understood a request, we can fulfill it, for example, by booking the room, opening a ticket, or communicating with the restaurant But if what we are making is a chatbot, the answer will probably correspond to the action An action corresponds to the step your application will take when a specific intent has been triggered by a user's input Both the action name and its parameters are defined in the action section of an intent Context What time does the guest arrive at the hotel? What did you eat? These are meaningless phrases without a context but become comprehensible in the context of a broader dialogue; this is what a context is for The syntax for collecting a parameter from the context is very simple: # context_name.parameter_name With Dialogflow, a context is maintained for 10 minutes or five requests Building a chatbot with Dialogflow After analyzing the main components of Dialogflow, it is time to focus on a practical application In fact, we will create a simple chatbot that will help users to retrieve weather information about the most beautiful city in the world The first thing to is to create the agent, that is, the project containing intents, entities, and answers that you want to deliver to the user The intent is the mechanisms that collect what the user is requesting (using the entities) and direct the agent to respond accordingly For simple answers that not include information collected outside the conversation, you can define the answers directly in the intent You can perform more advanced responses using your own logic and the web hooks for implementation The web hook is the URL to be invoked that hosts the code that implements the actions to be performed Unlike other environments, Dialogflow also allows you to use the HTTP protocol (and not just the HTTPS protocol) Agent creation To create an agent, perform the following steps: If you don't have a Dialogflow account, sign up If you have an account, log in Click on Create Agent in the left navigation and fill in the fields The following window is opened: In this window, we will have to set some parameters: The name of the agent Primary language for your agent Time zone setting Date and time are resolved using this time zone Google project This enables Cloud functions, actions on Google, and permissions management A series of agents (prebuilt agents) are already available for some types of requests that can be customized and enriched for your needs The number of agents available depends on the language; more than 30 different agents are available in English Click on the Save button Intent definition As we said previously, the user's intent is their purpose, the ultimate goal Examples are ordering something, wanting to activate something on the user window, looking for shows, or simply saying goodbye A chatbot should be able to perform some actions based on the intent it detects from the user's message To create an intent, click on the plus icon next to Intents; the following window is opened: In this window, we will have to set some parameters: Intent name: The name of the intent Contexts: This is used to manage the flow of the conversation Events: This is a feature that allows you to invoke intents by an event name instead of a user query Events can be used by external services to trigger Dialogflow intents, for example, Google Assistant's built-in intents Training phrases: The phrases that identify the intent must be reported in natural language You can use both examples (example mode identified with the " icon) and templates (template mode identified with the @ icon) Other examples of sentences are provided, the more the agent will be intelligent or he will be able to better recognize the user requests and to resolve ambiguities Action and parameters: This specifies the possible action to be executed and its parameters that can be extracted from the dialogue Response: The answers to be returned to the user when the intent has been recognized must be reported To make it more human-like, you can enter different variations for the same answer The answers can also be parameterized, and depending on the integration used, they can consist of rich messages Fulfillment: Call a web service to connect your backend Send the intent, parameters, and context to your Cloud function or a web service Execute the necessary logic and respond with a written, spoken, or visual response When an example sentence is inserted, it is automatically noted, recognizing the parts that are collected as entity An agent always contains a default fallback intent that collects all the cases in which no other intent has been recognized The first intent we want to insert has the purpose to specify the position related to our weather forecast We said that an intent represents the user's purpose, so we need to think what questions the user may ask to receive weather forecasts We need different intentions because there are many ways to ask the same thing The process of identifying the intent is to map all the possible ways that the user can use to express an intent The requests that we may expect from a user should be specified in the training phrases section To start, let's insert the following phrases: What's the weather like in Rome How's the weather in Rome Weather in Rome Rome weather forecast To insert a single phrase, simply add the user expression in the Training phrases text field and then press Enter to add another phrase We will notice that the sentence will be added to our declaration of intent In particular, we can see that the word Rome is highlighted This means that it was noted as a parameter assigned to existing city entities, as shown in the following screenshot: We continue to insert the sentences After defining the location, it is necessary to define the time It is clear that the user will need to know the predictions on a specific day, today or tomorrow for example Then we also include these phrases: What is the weather today Weather for tomorrow Weather forecast in Rome today As before, the time parameter is also highlighted, this time with a different color The last sentence is interesting as it contains both a date parameter and a geo-city parameter, as shown in the following screenshot: To start, we leave the other fields as is and focus only on the answer that the chatbot will have to provide to the user So far, we have not considered any external reference from which to retrieve the information requested by the user This means that at least for now, we will have to insert vague answers like these: I'm sorry, I not have this information right now Forecasts for $date are not available The weather forecast for $date in $geo-city is not available In the last two phrases, we have inserted the following reference entities: $date and $geo-city So, when the agent responds, it takes into account the parameter values gathered and will use a reply that includes those values that it picked up Once we're done, we click on the Save button The following messages appear at the bottom right of the window: Intent saved Agent training started Agent training completed The meaning is clear Now that your agent can understand basic requests from the user, try out what you have made so far To try the newly created agent, we can use the appropriate box available in the console at the top right To this, we simply need to type in a request Let's try our agent by typing a slightly different request from the examples given in the Training phrases section For example, we ask: Hows the weather in Rome today After this, we press Enter and the following window is returned: We can understand the frustration of the user who has not recovered the searched information, but we can already be satisfied as the agent has correctly interpreted the question and provided a plausible answer Remember that, at least for now, the forecast data is not available and this is what the agent said Also, as anticipated, the agent has identified the two reference entities and reused them to construct the response Summary In this chapter, we discovered the amazing world of chatbots Chatbots are robots, that interact with users through a chat and are able to assist them by carrying out extremely limited tasks: providing information on a current account, buying a ticket, receiving news about the weather, and so forth To begin with, we took a look at the fundamentals of the topic, starting with the history of chatbots in the 1950s, with the efforts of Alan Turing and various subsequent implementations of chatbots that perfected the basic concepts Eliza, Parry, Jabberwacky, Dr Sbaitso, ALICE, SmarterChild, and IBM Watson are the most important examples As time passed and technology evolved, more and more sophisticated AI methods were created After introducing the basic concepts, we focused on the design techniques of chatbots and then moved on to analyze the architecture of a chatbot We explored the interesting fields of NLP and NLU In the last part of the chapter, we covered Google Cloud Dialogflow, a platform for creating voice and text conversation applications based on machine learning It supports 14 languages and can be integrated with major chat platforms Finally, we created a simple chatbot that helps users to retrieve weather information about the most beautiful city in the world, that is, Rome This can be an opportunity to travel, at least with the mind ... Essential Machine Learning, starts our journey into machine learning and deep learning; we learn when to apply each one Chapter , Google Machine Learning APIs, teaches us how to use Google Cloud machine. .. scientists, machine learning developers, and AI developers who want to learn Google Cloud Platform services to build machine learning applications Since interaction with the Google ML platform is... error Root mean square error The difference between machine learning and deep learning Applications of deep learning Summary Google Machine Learning APIs Vision API Enabling the API Opening an

Ngày đăng: 21/03/2019, 08:54

TỪ KHÓA LIÊN QUAN