Machine Learning Tutorial for Beginners: What is, Basics of ML

⚡ Smart Summary

Machine Learning is a family of computer algorithms that improve from examples instead of being explicitly coded, combining data with statistical tools to predict outputs that people can turn into actionable decisions.

  • 🔘 Rules are learned, not written: Traditional programming codes every rule by hand, while a model derives the rule from paired inputs and outputs.
  • ☑️ Two stages: Learning discovers patterns and summarises them into a model; inference applies that model to never-seen data.
  • Two broad families: Supervised learning needs labelled outputs, unsupervised learning finds structure without them.
  • 🧪 Algorithm choice follows the objective: Regression predicts continuous values, classification assigns labels, clustering groups similar records.
  • 🛠️ Data is the real constraint: Too little data, or data without variety, produces a model that cannot generalise.
  • ⚙️ Where it pays off: Fraud detection in banking, image detection in healthcare, demand forecasting across the supply chain.

Machine Learning Tutorial for Beginners: Basics of ML

What is Machine Learning?

Machine Learning is a system of computer algorithms that can learn from examples through self-improvement, without being explicitly coded by a programmer. Machine learning is a part of artificial intelligence which combines data with statistical tools to predict an output that can be used to make actionable insights.

The breakthrough comes with the idea that a machine can learn from the data (i.e., examples) on its own to produce accurate results. Machine learning is closely related to data mining and Bayesian predictive modeling. The machine receives data as input and uses an algorithm to formulate answers.

A typical machine learning task is to provide a recommendation. For those who have a Netflix account, all recommendations of movies or series are based on the user’s historical data. Tech companies use unsupervised learning to improve the user experience by personalizing recommendations.

Machine learning is also used for a variety of tasks such as fraud detection, predictive maintenance, portfolio optimization, and task automation.

Machine Learning vs. Traditional Programming

Traditional programming differs significantly from machine learning. In traditional programming, a programmer codes all the rules in consultation with an expert in the industry for which the software is being developed. Each rule is based on a logical foundation; the machine produces an output by following the logical statement. When the system grows complex, more rules need to be written, and it can quickly become unsustainable to maintain. The diagram below shows that flow, where data and hand-written rules go in and answers come out.

Traditional programming flow: data plus hand-coded rules produce the output
Traditional Programming

Machine learning is meant to overcome this issue. The machine learns how the input and output data are correlated, and it writes the rule itself. Programmers do not need to write new rules each time there is new data. The algorithms adapt in response to new data and experience to improve efficacy over time. The second diagram inverts the first one: data and known answers go in, and the rule comes out.

Machine learning flow: data plus known answers produce the rule

Machine Learning

How does Machine Learning Work?

With that contrast in place, the next question is what actually happens inside the learning step.

Machine learning is the brain where all the learning takes place. The way the machine learns is similar to the way a human being does. Humans learn from experience: the more we know, the more easily we can predict. By analogy, when we face an unknown situation, the likelihood of success is lower than in a known situation. Machines are trained the same way. To make an accurate prediction, the machine sees an example. When we give the machine a similar example, it can figure out the outcome. However, like a human, if it is fed a previously unseen example, the machine has difficulty predicting.

The core objectives of machine learning are learning and inference. First of all, the machine learns through the discovery of patterns, and that discovery is made possible by the data. One crucial part of the data scientist’s job is to choose carefully which data to provide to the machine. The list of attributes used to solve a problem is called a feature vector. You can think of a feature vector as a subset of data that is used to tackle a problem.

The machine uses algorithms to simplify reality and transform this discovery into a model. The learning stage is therefore used to describe the data and summarize it into a model, as illustrated below.

Learning stage: training data passes through an algorithm to build a model

For instance, the machine is trying to understand the relationship between the wage of an individual and the likelihood of going to a fancy restaurant. It turns out the machine finds a positive relationship between wage and going to a high-end restaurant: this is the model.

Inferring

When the model is built, it is possible to test how powerful it is on never-seen-before data. The new data is transformed into a feature vector, goes through the model and gives a prediction. This is the valuable part of machine learning. There is no need to update the rules or train the model again — you can use the previously trained model to make an inference on new data, exactly as the diagram below shows.

Inference stage: new data passes through the trained model to give a prediction

The life of a machine learning program is straightforward and can be summarized in the following points:

  1. Define a question
  2. Collect data
  3. Visualize data
  4. Train algorithm
  5. Test the algorithm
  6. Collect feedback
  7. Refine the algorithm
  8. Loop through steps 4 to 7 until the results are satisfying
  9. Use the model to make a prediction

Once the algorithm gets good at drawing the right conclusions, it applies that knowledge to new sets of data.

Machine Learning Algorithms and Where they are Used?

The chart below groups the most common algorithms by the kind of task they solve.

Machine learning algorithms grouped into supervised and unsupervised tasks

Machine learning Algorithms

Machine learning can be grouped into two broad learning tasks: supervised and unsupervised. Two further families sit between and beyond them — semi-supervised learning, which mixes a small labelled set with a large unlabelled one, and reinforcement learning, where an agent learns from rewards rather than from labelled answers.

Supervised learning

An algorithm uses training data and feedback from humans to learn the relationship between given inputs and a given output. For instance, a practitioner can use marketing expense and weather forecast as input data to predict the sales of cans.

You can use supervised learning when the output data is known. The algorithm will then predict on new data.

There are two categories of supervised learning:

  • Classification task
  • Regression task

Classification

Imagine you want to predict the gender of a customer for a commercial. You will start by gathering data on height, weight, job, salary, purchasing basket and so on from your customer database. You know the gender of each of your customers, and it can only be male or female. The objective of the classifier is to assign a probability of being male or female (i.e., the label) based on the information you have collected (i.e., the features). When the model has learned how to recognize male or female, you can use new data to make a prediction. For instance, you have just received new information from an unknown customer, and you want to know whether the customer is male or female. If the classifier predicts male = 70%, it means the algorithm is 70% sure that this customer is male, and 30% sure the customer is female.

The label can have two or more classes. The above machine learning example has only two classes, but if a classifier needs to predict objects, it may have dozens of classes (e.g., glass, table, shoes — each object represents a class).

Regression

When the output is a continuous value, the task is a regression. For instance, a financial analyst may need to forecast the value of a stock based on a range of features such as equity, previous stock performance and macroeconomic indices. The system will be trained to estimate the price of the stock with the lowest possible error.

The table below lists the supervised algorithms you will meet most often, and the task each one is suited to.

Algorithm Description Type
Linear regression Finds a way to correlate each feature to the output to help predict future values. Regression
Logistic regression Extension of linear regression that’s used for classification tasks. The output variable is binary (e.g., only black or white) rather than continuous (e.g., an infinite list of potential colors) Classification
Decision tree Highly interpretable classification or regression model that splits data-feature values into branches at decision nodes (e.g., if a feature is a color, each possible color becomes a new branch) until a final decision output is made Regression
Classification
Naive Bayes The Bayesian method is a classification method that makes use of the Bayesian theorem. The theorem updates the prior knowledge of an event with the independent probability of each feature that can affect the event. Regression
Classification
Support vector machine Support Vector Machine, or SVM, is typically used for the classification task. The SVM algorithm finds a hyperplane that optimally divides the classes. It is best used with a non-linear solver. Regression (not very common)
Classification
Random forest The algorithm is built upon a decision tree to improve the accuracy drastically. Random forest generates many simple decision trees and uses the ‘majority vote’ method to decide which label to return. For the classification task, the final prediction will be the one with the most votes; for the regression task, the average prediction of all the trees is the final prediction. Regression
Classification
AdaBoost Classification or regression technique that uses a multitude of models to come up with a decision but weighs them based on their accuracy in predicting the outcome Regression
Classification
Gradient-boosting trees Gradient-boosting trees is a state-of-the-art classification/regression technique. It focuses on the error committed by the previous trees and tries to correct it. Regression
Classification

Unsupervised learning

In unsupervised learning, an algorithm explores input data without being given an explicit output variable (e.g., it explores customer demographic data to identify patterns).

You can use it when you do not know how to classify the data and you want the algorithm to find the patterns and group the data for you. The main unsupervised algorithms are summarized below.

Algorithm Name Description Type
K-means clustering Puts data into some groups (k) that each contains data with similar characteristics (as determined by the model, not in advance by humans) Clustering
Gaussian mixture model A generalization of k-means clustering that provides more flexibility in the size and shape of groups (clusters) Clustering
Hierarchical clustering Splits clusters along a hierarchical tree to form a classification system. Can be used to cluster loyalty-card customers Clustering
Recommender system Helps to define the relevant data for making a recommendation. Clustering
PCA/t-SNE Mostly used to decrease the dimensionality of the data. The algorithms reduce the number of features to 3 or 4 vectors with the highest variances. Dimension Reduction

How to Choose Machine Learning Algorithm

There are plenty of machine learning algorithms, and the choice of algorithm is driven by the objective rather than by fashion.

In the machine learning example below, the task is to predict the type of flower among three varieties. The predictions are based on the length and the width of the petal. The picture depicts the results of ten different algorithms. The picture on the top left is the dataset itself, with the data classified into three categories: red, light blue and dark blue. Some groupings are visible. For instance, in the second image, everything in the upper left belongs to the red category, the middle part holds a mixture of uncertainty and light blue, while the bottom corresponds to the dark category. The other images show how different algorithms try to classify the same data.

Ten algorithms compared on the same three-class flower dataset

Once a candidate is chosen, its quality is judged on data it has never seen, usually with a confusion matrix and the accuracy, precision and recall figures derived from it.

Challenges and Limitations of Machine Learning

The primary challenge of machine learning is the lack of data, or the lack of diversity within the dataset. A machine cannot learn if there is no data available. A dataset that lacks diversity also gives the machine a hard time, because a machine needs heterogeneity to learn a meaningful insight. It is rare that an algorithm can extract information when there are no or few variations. A common rule of thumb is to have at least 20 observations per group to help the machine learn; below that, evaluation and prediction both suffer.

Data volume is not the only limit. Models trained on biased historical records reproduce that bias, complex models are hard to explain to a regulator or a customer, and any model degrades as the world it was trained on changes.

Application of Machine Learning

The techniques above already run in production across most industries. The examples below move from general assistance to specific sectors.

Augmentation: Machine learning assists humans with their day-to-day tasks, personally or commercially, without having complete control of the output. Such machine learning is used in different ways, such as virtual assistants, data analysis and software solutions. The primary purpose is to reduce errors caused by human bias.

Automation: Machine learning works entirely autonomously in any field without the need for human intervention. For example, robots perform the essential process steps in manufacturing plants.

Finance industry: Machine learning is growing in popularity in the finance industry. Banks mainly use ML to find patterns inside the data, but also to prevent fraud.

Government organizations: Governments make use of ML to manage public safety and utilities. Take the example of China and its large-scale face recognition programme, where artificial intelligence applications are used to identify jaywalkers.

Healthcare industry: Healthcare was one of the first industries to use machine learning, starting with image detection.

Marketing: Broad use of AI is made in marketing thanks to abundant access to data. Before the age of mass data, researchers developed advanced mathematical tools such as Bayesian analysis to estimate the value of a customer. With the boom in data, marketing departments rely on AI to optimize customer relationships and marketing campaigns.

Example of Machine Learning in the Supply Chain

Machine learning gives strong results for visual pattern recognition, opening up many potential applications in physical inspection and maintenance across the entire supply chain network.

Unsupervised learning can quickly search for comparable patterns in a diverse dataset. In turn, the machine can perform quality inspection throughout the logistics hub and flag shipments with damage and wear.

For instance, IBM’s Watson platform can determine shipping container damage. Watson combines visual and systems-based data to track, report and make recommendations in real time.

In the past, stock managers relied extensively on manual methods to evaluate and forecast inventory. When big data and machine learning are combined, better forecasting techniques become possible, with reported improvements of 20 to 30 percent over traditional forecasting tools. In terms of sales, that translates into an increase of 2 to 3 percent thanks to the potential reduction in inventory costs.

Example of Machine Learning in the Google Car

Everybody knows the Google car. The car is covered in lasers on the roof, which tell it where it is in relation to the surrounding area. It has radar at the front, which informs the car of the speed and motion of all the cars around it. It uses all of that data to figure out not only how to drive the car but also to predict what the drivers around it are going to do. What is impressive is that the car processes almost a gigabyte of data a second.

Self-driving car sensors feeding machine learning models in real time

Why is Machine Learning Important?

Machine learning is the best tool so far to analyze, understand and identify a pattern in the data. One of the main ideas behind machine learning is that a computer can be trained to automate tasks that would be exhausting or impossible for a human being. The clear break from traditional analysis is that machine learning can make decisions with minimal human intervention.

Take the following example: a retail agent can estimate the price of a house based on personal experience and knowledge of the market.

A machine can be trained to translate the knowledge of that expert into features. The features are all the characteristics of a house, the neighborhood, the economic environment and so on that make the price differ. For the expert, it probably took years to master the art of estimating the price of a house, and the expertise improves after each sale.

For the machine, it takes millions of data points (i.e., examples) to master this art. At the very beginning of its learning, the machine makes mistakes, much like a junior salesperson. Once the machine has seen enough examples, it has enough knowledge to make its estimation, and to do so with high accuracy. The machine is also able to correct its mistakes as new sales arrive.

Most large companies have understood the value of machine learning and of holding data. The McKinsey Global Institute estimated the annual value of all analytics techniques at $9.5 trillion to $15.4 trillion, and attributed roughly 40 percent of that — some $3.5 trillion to $5.8 trillion a year — to advanced AI techniques based on deep neural networks, as set out in its Notes from the AI Frontier research.

Where rules are known but imprecise rather than absent, a rule-based approach such as fuzzy logic can be a better fit than a learned model, so the two techniques are often compared before a project starts.

FAQs

Semi-supervised learning trains on a small labelled set plus a large unlabelled one, which helps when labelling is expensive. Reinforcement learning has no labels at all: an agent acts, receives a reward or penalty, and adjusts its policy over many attempts.

They are nested. Artificial intelligence is the broadest goal of machine-like intelligence, machine learning is the subset that learns from data, and deep learning is the subset of machine learning built on multi-layer neural networks.

Overfitting happens when a model memorises the training set, including its noise, and then fails on new data. Cross-validation, simpler models, regularisation, early stopping and more training examples are the usual defences.

A model always scores well on the rows it was fitted to, so that score proves nothing. Holding back a test set — and often a separate validation set for tuning — is the only honest estimate of performance on data the model has never seen.

Comfort with basic statistics and probability, linear algebra at the level of vectors and matrices, and one scripting language. Practical data handling matters more than advanced mathematics at the start, so cleaning and exploring a real dataset is the best first exercise.

Python leads, with scikit-learn for classical models and TensorFlow or PyTorch for neural networks. R remains strong for statistical modelling and visualisation, while SQL is unavoidable for pulling the training data itself.

Predictive models output a label or a number for a given input. Generative models learn the distribution of the data and produce new samples from it — text, images or code. Both are trained on data, but only one is evaluated on accuracy alone.

GitHub Copilot drafts boilerplate quickly: loading a dataset, splitting it, fitting an estimator and plotting results. Review every suggestion, because a plausible-looking pipeline can still leak test data into training and inflate the score.

Summarize this post with: