Chapter 10. How to Tell If Your Toaster Is Learning – Machine Learning Essentials

Machine learning has become quite the phrase of the decade. It seems as though every time we hear about the next great start-up or turn on the news, we hear something about a revolutionary piece of machine learning technology and how it will change the way we live.

This chapter focuses on machine learning as a practical part of data science. We will cover the following topics in this chapter:

  • Defining the different types of machine learning, along with examples of each kind
  • Regression and classification
  • What is machine learning and how is it used in data science?
  • The differences between machine learning and statistical modeling and how machine learning is a broad category of the latter

Our aim will be to utilize statistics, probability, and algorithmic thinking in order to understand and apply essential machine learning skills to practical industries, such as marketing. Examples will include predicting star ratings of restaurant reviews, predicting the presence of a disease, spam email detection, and much more. This chapter focuses on machine learning as a whole and as a single statistical model. The subsequent chapters will deal with many more models, some of which are much more complex.

We will also turn our focus on metrics, which tell us how effective our models are. We will use metrics in order to conclude results and make predictions using machine learning.

What is machine learning?

It wouldn't make sense to continue without a concrete definition of what machine learning is. Well, let's back up for a minute. In Chapter 1, How to Sound Like a Data Scientist, we defined machine learning as giving computers the ability to learn from data without being given explicit rules by a programmer. This definition still holds true. Machine learning is concerned with the ability to ascertain certain patterns (signals) out of data, even if the data has inherent errors in it (noise).

Machine learning models are able to learn from data without the explicit help of a human. That is the main difference between machine learning models and classical algorithms. Classical algorithms are told how to find the best answer in a complex system and the algorithm then searches for these best solutions and often works faster and more efficiently than a human. However, the bottleneck here is that the human has to first come up with the best solution. In machine learning, the model is not told the best solution and, instead, is given several examples of the problem and is told to figure out the best solution.

Machine learning is just another tool in the belt of a data scientist. It is on the same level as statistical tests (chi-square or t-tests) or uses base probability/statistics to estimate population parameters. Machine learning is often regarded as the only thing data scientists know how to do, and this is simply untrue. A true data scientist is able to recognize when machine learning is applicable and, more importantly, when it is not.

Machine learning is a game of correlations and relationships. Most machine learning algorithms in existence are concerned with finding and/or exploiting relationships between datasets (often represented as columns in a pandas DataFrame). Once machine learning algorithms can pinpoint certain correlations, the model can either use these relationships to predict future observations or generalize the data to reveal interesting patterns.

Perhaps a great way to explain machine learning is to offer an example of a problem coupled with two possible solutions: one using a machine learning algorithm and the other utilizing a non-machine learning algorithm.

Example – facial recognition

This problem is very well documented. Given a picture of a face, who does it belong to? However, I argue that there is a more important question that must be asked even before this. Suppose you wish to implement a home security system that recognizes who is entering your house. Most likely, during the day, your house will be empty most of the time and the facial recognition will kick in only if there is a person in the shot. This is exactly the question I propose we try and solve—given a photo, is there a face in it?

Given this problem, I propose the following two solutions:

  • A non-machine learning algorithm that will define a face as having a roundish structure, two eyes, hair, nose, and so on. The algorithm then looks for these hard-coded features in the photo and returns whether or not it was able to find any of these features.
  • A machine learning algorithm that will work a bit differently. The model will only be given several pictures of faces and non-faces that are labeled as such. From the examples (called training sets), it would figure out its own definition of a face.

The machine learning version of the solution is never told what a face is, it is merely given several examples, some with faces, and some without. It is then up to the machine learning model to figure out the difference between the two. Once it figures out the difference between the two, it uses this information to take in a picture and predict whether or not there is a face in the new picture. For example, to train the model, we will give it the following three photographs:

Example – facial recognition

Images for training machine learning model

The model will then figure out the difference between the pictures labeled as Face and the pictures labeled as No Face and be able to use that difference to find faces in future photos.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset