Machine Learning Concepts For Beginner

Sharing is caring!

Last Updated on July 11, 2022 by Jay

This tutorial will talk about several key machine learning concepts in a beginner friendly way. Machine learning is a broad topic and people who are just starting out can find it overwhelming. Hopefully, this tutorial will give you a basic understanding of what machine learning is about without getting into the technical details.

What Is Machine Learning (ML)

The traditional software consists of explicit instructions and rules written by a programmer. For example, if condition_1 is met, do this, and if condition_2 is met, do that, etc. However, for complex problems, there’s no way that human programmers can capture all the scenarios and write each rule into code.

Machine learning is a study that combines both computer science and statistics. Instead of thousands of human-coded instructions to the computer, a machine learning model can learn from examples by using statistical methods to infer conclusions from data. In other words, ML algorithms can generalize from known examples. In layman’s terms, ML algorithms can examine known data and figure out patterns, then apply the learned patterns to unknown data and then make a prediction.

Machine Learning Examples

Do you use your fingerprint or your face to unlock your smartphone? That’s a machine learning program in the work. Our smartphone doesn’t need thousands of pictures of ourselves at every angle or in different settings. It just needs a handful of pictures, then it will recognize our faces in most scenarios.

Do you ask your Google Home or Alexa for weather, time, or doing a search? That’s also machine learning that can recognize human speech. Each person has a different voice, accent, tone, etc. Yet those devices can understand human language in most cases.

Ever binge watching Netflix or Youtube at home? Why do we always find something else interesting after watching every show? Thanks to the recommendation system (also an ML algorithm) that knows what kind of shows we are most interested in.

Types of Machine Learning Approaches

There are two main types of machine learning approaches: Supervised and Unsupervised.

Supervised Learning

Our goal is to predict some output variable that’s associated with each input variable. For example, whether a credit card transaction is fraudulent or not. Or the price of a home in a given neighborhood.

Supervised learning needs to have a labeled dataset. The label refers to the output variable. In the credit card example shown below, the input data are time, location, amount, store, and whether it’s an online order. The output, or the label, is whether a transaction is fraudulent or not.

Sample data with labels
Sample data with labels

Classification

For a classification problem, the output is a category (usually a finite number of possible outcomes). Such as whether a credit card transaction is fraudulent or not (an example of binary class). Or, if a fruit is an apple, or orange, or a peach. The function for solving this problem is called a classifier.

Regression

For regression, the output is usually a value or number, like the price of a house in Toronto. Or tomorrow’s temperature in degrees. We call the function for solving this problem a regression function.

Variable Terminologies

Let’s go through some common terminologies used to describe our data using the sample dataset above.

Input/Independent/Features Variable

Usually, the input variables are also called independent variables, or features. In our code, we usually use the variable name X to represent the input variables, which is usually a table of data points. Each column is a feature of the dataset, and each row is a data sample or observation.

Features and Target Variables
Features and Target Variables
Output/Target Variable

The output variables (or labels) are often called the dependent variable, or target variable. In our code, we usually use the variable y to denote the target variable. The labels usually come from human inputs. As you can see, producing these labels can be a labor-intensive task in certain cases. For example, Tesla uses humans to label images and videos captured by cars – where is the road, lane markings, pedestrians, cars, stop signs, etc. This is the part where humans “supervise” the learning algorithm by providing labels.

Labeling image data
Labeling image data

What And How Does The ML Model Learn?

A machine learning model will examine the relationship between the input variable X and the target variable y. Our goal is to learn some sort of function that can map each row in the input variable X (features) to a label in the target variable y. Once that function is learned, we can give the program a different set of X to predict y.

The Model

Supervised Learning Algorithm Examples

Here are a few beginner friendly (supervised) machine learning algorithm examples: linear regression, k-nearest neighbors, decision trees, etc. These algorithms can be either regression or classification.

Unsupervised Learning

For unsupervised learning, usually, we only have input data X, and we don’t have any labels. For this type of problem, we usually want to examine the input data and try to find useful clusters or groupings from it.

Data cluster example
Data cluster example (source: Wikipedia)

For example, the YouTube algorithm might put users into different groupings depending on the viewing activities – people that like to watch financial news, people who like to watch programming tutorials, or people who like to watch funny videos, etc. Once YouTube’s algorithm places us into a cluster, it will keep recommending related videos to us. This is why we often find YouTube’s recommended videos fit our taste well.

All the things we talked about in Supervised Learning also apply to Unsupervised learning, except that usually there’s no target variable for an unsupervised learning problem.

Unsupervised Learning Algorithm Examples

A few beginner friendly (supervised) machine learning algorithm examples are k-means clustering, principal component analysis, etc.

High-level Machine Learning Workflow For Beginner

The below outlines a high-level machine learning workflow. We’ll start off by defining the problem we want to solve.

  1. What problem do we want to solve? Is it regression or classification? What algorithm is suitable?
  2. Do we have enough data? If not, can we derive data from some other sources or existing data? This is called feature engineering.
  3. Split the dataset into two parts, usually a 75% / 25% split. One of the sub-dataset is called the training set (75%), and the other is called the test set (25%).
  4. We would use the training set to learn the relationship (function) between features and target variables by building a model with some initial parameters.
  5. Then use the test set to measure how well the model prediction is. Remember, in the test set, we also have labels so we can measure how many predictions are correct.
  6. Usually, the performance (e.g. accuracy) of the first model won’t be good. Now we need to consider whether the algorithm we chose in step 1 is appropriate. If we need to use a different algorithm, we have to repeat steps 2-5.
  7. Once we are happy with an algorithm, we need to fine-tune the parameters to improve the performance. Repeat step 4-5 with a different set of parameters until we are happy with the prediction performance.

Additional Resources

How to A Plot Decision Tree in Python Matplotlib

Leave a Reply

Your email address will not be published. Required fields are marked *