top of page
  • Robert John

Bite-Sized Machine Learning, Part 3: Getting Started

Updated: Jun 4, 2020


"Can I do Machine Learning without understanding mathematics and computer science"?


That is a very popular question, and hopefully this article makes things clearer. To answer the question of whether or not, let's use the analogy of pasta (spaghetti, macaroni, tagliatelle, or whatever your pasta of choice is).


Suppose you love to eat pasta, let's say for lunch on Saturdays. How do you get your pasta?


One option would be to get your pasta from a restaurant. In this case, you don't need to know anything about making pasta, or even about cooking. You just need to get dressed, go to the restaurant, and pay for your pasta. Enjoy your meal!


On the other hand, you might know "a little something" about cooking. In this case, you could purchase the dried pasta from a grocery store along with the ingredients you need for the sauce, and do your cooking at home.


If you are a good cook, you might even prefer to make your pasta from scratch. Did you know that you don't actually have to buy packaged, dried pasta? All you need is flour, eggs, and water. You might add a pinch of salt if you like.



Of course, at the very top of the pecking order is the restaurant. You could be so good at cooking and enjoy it so much that you decide to start a restaurant where other people who can't cook, or don't have the time, visit and pay you for a plate or two of pasta.




These analogies are designed to help you see the Machine Learning landscape in a new light. So, how should you get involved? The cooking metaphor stands for whether or not you are able to write your own Machine Learning code.


Suppose you have determined that the task you have requires Machine Learning, but you haven't taken any courses, you don't like the math, and you are not about to enroll for a Bootcamp or a Udacity Nanodegree. What are your options?


The solution would be for you to find a restaurant. You need to make use of an API.


Use an API


Suppose you have written a wonderful social network where people get together to talk about their pets. This network is popular among English-speaking kids in West Africa. Now, French-speaking kids in West Africa are now interested in using the social network. You can get a language translator to translate the website and mobile app to French, but how do you translate what users are communicating from English to French and back?


There is a restaurant for that!


Google has a language translation API that you can utilize. You can find it here. Is it free? No, it's not free, it's a restaurant! No free meals at a restaurant. You will need a Google Cloud Platform account before you can make use of this. You will find setup instructions at the link above.


So, how easy is this translation API? Take a look at the following code snippet.


That is a sample code written for node.js that will let you translate your text in less than 10 lines. Pretty neat. Enjoy your meal!


Now, suppose you wake up in the morning and decide to write an app that teaches kids how to read and spell. The app pronounces a word and the kid types it out, and they get a reward if they get this right. Obviously, your app will need a database of words.


You could get someone into the studio and record every word, or you could choose to automate the task. This is a good use of Machine Learning, and there is a restaurant for this as well!


Google has a text-to-speech API available here. This API will let you send it text, and it will generate a speech representation. You can choose from a range of languages, voices, and speeds. The image below is an example from the documentation site.




What if you wanted to build a different app? Perhaps one where you teach people to write a language by taking what they say and spelling it out? Again, there is a restaurant for that!


The Google Cloud Speech-to-text API lets you submit a sound recording and it returns a response containing the transcript. It's available here. It is quite versatile and recognizes over 120 languages.


What if you want to write a new game that uses the camera to find items? Perhaps the game will ask for something people have at home and then gives them some seconds to find the item. The more items you can find, the higher your score. This is a computer vision problem. How do you know if the photo that the player captured has that item in it?


The Google Cloud Vision API is what you need. It is available here. You send it an image, and it sends back a bunch of information.




In the image above, you can see an example image that I have uploaded to test the API. It correctly recognizes that the image contains a vegetable (you might consider it a fruit, I won't argue). But, that is not all it can do. There is a "Labels" tab with additional information.



The "Labels" tab shows the various labels it attributes to the image, as well as the probabilities attached to the labels. The response will be sent back as a JSON object that you will need to parse. The API recognizes over 100 thousand classes of objects.


That's all good, but, do you know of any vegan restaurants?

So you are a mobile developer?




What would we do without mobile developers and mobile phones? Of course, there is a restaurant for vegans.


Firebase ML Kit provides a Machine Learning library for native Android and iOS developers. There is even a short video introducing it.




ML Kit will let you incorporate a number of features into your mobile application. These include:

  • face detection

  • barcode scanning

  • text recognition

  • labeling images

  • detecting landmarks

ML Kit lets you embed these features into the app so that the app can work offline.


Vegan restaurants allow custom orders.


ML Kit lets you work with custom models that ML Engineers train for you. This is how you would embed a custom image recognition model into your mobile application. Firebase provides a free tier and all you have to do to get started is visit this link.


"I just want take-out coffee"


So you want to build your own chatbot? Awesome. Where will it run, Android or iOS? Do you want users to type into it? Should it integrate with Facebook Messenger? What if users want to talk to it through Alexa? You want it all? You, Oliver Twist, you!


Okay, you can get it all with Dialogflow. Fear not. Here is an introductory video.




DialogFlow introduces two new concepts: entities and intents.


Entities are the various components or objects in the statement. Suppose you write a bot to control a home. You might have commands to turn on the lights and turn them back off. If you issued the command "turn on the lights", the bot would know what you want, but what lights do you want to turn? Living room or kitchen? If you said "turn on the lights in the kitchen", kitchen would be an entity.


Intents are the specific action that you would like carried out. Suppose you said "it's dark in the living room", the bot would understand that you want the lights to come on, and the zone that you want the lights turned on in.


You will need to provide some sample statements that illustrate how users will communicate with the chatbot, as well as the meanings of the statements. The meanings are the intents, and the targets of the intents are your entities.


DialogFlow will extract your intents and entities, and call an endpoint which you specify. The endpoint could call further API endpoints, or interact with your own database to perform a lookup or a write.


You can get started with DialogFlow here.

 

"I can do my own cooking"


Perfect. Let's get started.


You can cook, but you will not be making your pasta from scratch. There are a few options depending on whether or not you know what a database query is, as well as the type of data you have.


If you have taken some courses in Machine Learning, and already know the difference between Supervised and Unsupervised Machine Learning, as well as what a learning rate is, what model evaluation is, and all that, but would rather not write code to train a model, then keep reading.


BQML: Machine Learning for Data Analysts


If you know how to write queries and spend some time working with databases, then you will be pleased to know that there is one database that supports training and deploying Machine Learning models.


The database is called BigQuery and is a part of the Google Cloud Platform, available here.


BigQueryML doesn't require any of the math, but it requires that you know everything else: feature engineering and model fine-tuning. It supports the following model types:

  • linear regression

  • logistic regression

  • k-means clustering

The following code snippet illustrates creating a logistic regression model.



The only thing new to a data analyst would be the CREATE MODEL statement. Similarly, running prediction on a model is illustrated by the following code snippet.



Obviously the two code snippets above are not all you need to create a fully functioning ML model, but you are not far off.


Working with BigQuery ML requires that you store your data in a table. This implies that you can't train models for computer vision or natural language, but we will get to that next.


AutoML


AutoML is a suite of products that lets you "roll your own pasta". There is an AutoML for most of the API that we have already discussed. There is an AutoML for the following:

  • Vision: for image analysis

  • Video Intelligence: for video analysis

  • Natural Language: for context-sensitive language models

  • Translation: for context-sensitive language translation tasks

  • Tables: for dealing with structured, tabular data

Why would you use AutoML? Because the APIs do not meet your needs. As a simple example, suppose you need to build something that can identify different traffic symbols. The standard Vision API might tell you it's a traffic sign. But, what does the sign mean?


While you will not write code, you will need to provide the training data as well as the labels. In the case of the traffic sign example, you will need to provide the images and labels for each class of traffic symbols.


What AutoML does is, it starts with pre-trained models that are optimal for the particular problem class. It then proceeds to try out different hyperparameters and model architectures. It continues to do this until it exhausts the compute time you have allocated for it.


You can read up on AutoML here.


 


If you feel like you want to do the heavy lifting and run a restaurant for others to eat out of, then this section is for you.


There is a lot that you need to know at this point. Some approaches require implementing some math, while others only require a knowledge of math to understand what is going on.


Implementing math is usually the domain of research, and requires the use of numerical computation libraries and some low-level API. The available libraries for python include the following:

  • Numpy

  • Scipy

  • PyTorch

  • TensorFlow

The approaches that do not require implementing math typically fall into the domain of Machine Learning Engineering. This requires the use of high-level APIs. Some libraries that provide high-level APIs include the following:

  • Scikit-learn

  • PyTorch

  • TensorFlow

TensorFlow is available for different languages, not just Python. There is even a JavaScript variant called tensorflow.js


TensorFlow is used internally by Google. You can use it to train models that you deploy to the cloud, and you can also use it to train models and deploy to mobile devices.

 

At this point, I hope that you have a clearer picture of the Machine Learning landscape and how you would like to get involved.


I will be providing some examples of using a lot of these libraries and APIs in future articles, so, stay tuned.

 

If you enjoyed reading this article, please subscribe to get notified of new articles.

220 views0 comments
Post: Blog2_Post
bottom of page