https://teachablemachine.withgoogle.
com/
What is Machine Learning (ML)?
Machine learning is a branch of Artificial Intelligence that enables algorithms to
discover hidden patterns in the given datasets. It allows them to predict new,
similar data without explicit programming for each task.
How machine learning algorithms work?
A machine learning algorithm works by learning patterns and relationships
from data to make predictions or decisions without being explicitly
programmed for each task.
Here’s a simplified overview of how a typical machine learning algorithm
works:
1. Data Gathering
First, relevant data is collected. This data could include features, or
attributes that are important for the task, such as images, text, numerical
data, etc.
2. Data Preprocessing
Before feeding the data into the algorithm, it is often need to prepare the
data for processing and this is called as data preprocessing. This step may
involve cleaning the data (handling missing values, outliers), transforming
the data (normalization, scaling).
3. Choosing a Model
Depending on the task (e.g., classification, regression, clustering), a
suitable machine learning model is chosen. Examples include decision
trees, neural networks, support vector machines etc.
4. Training the Model
The selected model is trained using the training data (splitting data into
training and test sets). During training, the algorithm learns patterns and
relationships in the data. This involves adjusting model parameters to
minimize the difference between predicted outputs and actual outputs
(labels or targets) in the training data.
5. Evaluating the Model
Once trained, the model is evaluated using the test data to assess its
performance. Metrics such as accuracy, precision, recall, or mean squared
error are used to evaluate how well the model generalizes to new, unseen
data.
6. Fine-tuning
Models may be fine-tuned by adjusting hyperparameters (parameters that
are not directly learned during training, like learning rate or number of
hidden layers in a neural network) to improve performance.
7. Prediction
Finally, the trained model is used to make predictions or decisions on new
data. This process involves applying the learned patterns to new inputs to
generate outputs, such as class labels in classification tasks or numerical
values in regression tasks.
Machine Learning Life
1. Defining the Problem: Clearly identify the real-world problem to be
solved.
2. Data Collection: Gather necessary data from various sources.
3. Data Cleaning and Preprocessing: Resolve data quality issues and
prepare the data for analysis.
4. Exploratory Data Analysis (EDA): Analyze data to identify patterns,
outliers, and trends.
5. Feature Engineering and Selection: Enhance data features and select
relevant ones to improve model performance.
6. Model Selection: Choose suitable models based on the problem type
and data characteristics.
7. Model Training: Train the model using a split of training and validation
datasets.
8. Model Evaluation and Tuning: Assess and optimize the model using
relevant metrics.
9. Model Deployment: Implement the model in a production environment
for real-time predictions.
10. Model Monitoring and Maintenance: Regularly check and update the
model to maintain accuracy.
Example:
Let's consider a common example of machine learning for predicting house
prices based on various features:
Task: Predicting house prices based on features like size, number of
bedrooms, location, etc.
Input Data: Data on houses including features like size, number of
bedrooms, location, etc.
Output Data: The predicted price of the house.
Model: A machine learning model trained on historical data to learn the
relationship between the input features and house prices.
Goal: To accurately predict house prices for new properties based on the
learned patterns from the training data.
In this example, the prediction task involves using a machine learning
model to predict house prices based on specific input features. The model is
trained on historical data where both the input features and
corresponding house prices are known. Once trained, the model can then
be used to predict house prices for new properties based on their features.
Statistical Modeling:
Statistical modeling uses mathematical models and statistical
assumptions to generate sample data and make predictions
applying statistical analysis to datasets. Therefore, it is a
collection of probability distributions on a set of all possible
outcomes of an experiment.
Common data sets for statistical analysis include Internet of
Things (IoT) sensors, census data, public health data, social
media data, imagery data, and other public sector data from real-
world.
Statistical Modeling Techniques
The first step in developing a statistical model is gathering data,
which may be sourced from spreadsheets, databases, data lakes,
or the cloud. The most common statistical modeling methods for
analyzing the data are categorized as either supervised learning
or unsupervised learning. Some popular statistical model
examples include logistic regression, clustering, and decision
trees.
Link for machine Learning Projects and study reference:
https://techvidvan.com/tutorials/learn-machine-learning/
A. Supervised Learning:
Supervised machine learning focuses on training models to make predictions or
decisions based on labeled training data. It involves a learning process where the
model learns from known examples to predict or classify unseen data accurately.
Supervised machine learning has two key components:
First input data and second corresponding output labels. The goal is to build a
model that can learn from the labeled data to make predictions or classifications on
new, unseen data.
The labeled data consists of input features (also known as independent variables
or predictors) and the corresponding output labels (also known as dependent
variables or targets). The model’s objective is to capture patterns and relationships
between the input features and the output labels, allowing it to generalize and make
accurate predictions on unseen data.
Supervised learning is the machine learning task that maps an input to an
output (input-output pairs). In this type of learning, we have labeled input
data. This means that the data presented to the model already contains the
correct answer. Some might wonder why we are providing data that already has
the right answer. The answer is simple.
We are giving this pre-labeled data to make the model learn from it. This means
if data with similar features is given to the machine in the future, it will
recognize it. In addition, the labeled data (training data) helps to train the model
to improve its accuracy.
For a better understanding, let’s take an example.
We have a bag of vegetables consisting of tomatoes, onions, potatoes, radishes,
etc.
Now you have to train your data like:
If the shape is round and the color is red, then the vegetable should be a
tomato.
If the shape is an elongated cylinder and color is white then the vegetable
should be a radish.
Since the machine has now learned about the vegetables, it should be able to
distinguish them based on their attributes. That is if the shape is round and the
color is red then the algorithm will put it in the tomatoes category.
Supervised learning is of two types:
1. Classification
It specifies the category to which data elements belong to and is best used when
the output has finite and discrete values.
The output of classification is a category. Such as ‘blue’, ‘green’, ‘sunny’, ‘no
sunny’, ‘disease’, ‘no disease’ etc.
The output here is in the form of classes.
2. Regression
It is a way which helps find the correlation between variables and enables us to
predict the continual output variable supported the one or more predictor
variables. The output in this problem is a real value like ‘mass’, ‘percent’,
‘rupees’, ‘dollars’ etc.
Summarized
Supervised learning techniques include regression models and
classification models:
Regression model: A type of predictive statistical model
that analyzes the relationship between a dependent and
an independent variable. Common regression models
include logistic, polynomial, and linear regression models.
Link to understand concept equation y = mx + c
https://thirdspacelearning.com/gcse-maths/algebra/y-mx-c/
Classification model: A type of machine learning in which
an algorithm analyzes an existing, large and complex set of
known data points as a means of understanding and then
appropriately classifying the data; common models include
decision trees, Naive Bayes, nearest neighbor, random
forests, and neural networking models.
B. Unsupervised Learning:
Unsupervised learning is a type of machine learning algorithm used to draw
inferences from datasets consisting of input data without labeled responses.
The most common unsupervised learning method is cluster analysis, which is
used for exploratory data analysis to find hidden patterns or grouping in data. In
this type of learning, there is no labeled input data. This means that the machine
won’t be given any training data to learn from.
Thus, the task of the machine is to group similar types of data together. This is
done based on patterns and differences without any sort of previous training.
Thus, the machine will have to figure everything from scratch without any
help.
Let’s take an example for a better understanding.
There is a picture of sardines and salmon fishes. Obviously, the machine has no
knowledge about this. But, the algorithm can help us to find some patterns in
the picture. Sardines and salmon are two varieties of fish. The sardines are small
in size. Hence, they form one group. Whereas the salmon is bigger in size.
Therefore, they form a separate group.
In this way, the algorithm classifies objects using unsupervised learning. Type
of unsupervised learning
1. Clustering:
It which involves segregating data supported the similarity between data
instances. It is an iterative process to seek out cluster centers called centroids
and assigning data points to at least one of the centroids.
Here, we have groups of data according to certain criteria.
For example, people who drink coffee are grouped separately. Whereas, people
who don’t drink come in a different group.
Summarized
Unsupervised learning techniques include clustering
algorithms and association rules:
K-means clustering: Grouping of data points based on
certain similarities. The main objective of k-means
clustering is to partition your data into a specific number
(k) of groups, where data points within each group are
similar and dissimilar to points in other groups.
Link to understand supervised-and-unsupervised-learning
https://www.simplilearn.com/tutorials/machine-learning-
tutorial/supervised-and-unsupervised-learning
Key differences between supervised and unsupervised
learning:
Data type:
Supervised learning uses labeled data, where each data point has
a corresponding correct answer, while unsupervised learning
uses unlabeled data with no predefined categories.
Goal:
Supervised learning aims to predict specific outcomes based on
the labeled data, while unsupervised learning seeks to identify
hidden patterns and relationships within the data.
Applications:
Supervised learning is used for tasks like email spam filtering,
image recognition, and sentiment analysis, while unsupervised
learning is used for customer segmentation, anomaly detection,
and recommendation systems.
Example scenarios:
Supervised learning:
Training a model to identify handwritten digits by providing
labeled images where each digit is already annotated with its
correct value.
Unsupervised learning:
Clustering customers into different groups based on their
purchasing behavior without any prior knowledge of which
customer belongs to which group
Feature Supervised Learning Unsupervised Learning
Data
Labeled data (input-output Unlabeled data (only
pairs) inputs)
Goal Predict output based on input Predict output based on
data input data
Output Classification or regression Clusters, associations, or
(specific predictions) reduced dimensionality
Algorithms Linear Regression, Logistic K-Means, Hierarchical
Regression, Decision Trees, Clustering, PCA, DBSCAN,
SVM, Neural Networks Autoencoders
Evaluation Based on comparison to true Based on internal criteria
labels (accuracy, F1 score, (e.g., silhouette score)
etc.)
Data Requires a large set of labeled Can work with unlabeled
Requirement data, often costly to obtain data, typically more
available
Use Case Predicting outcomes (e.g., Grouping data, anomaly
spam detection, price detection, dimensionality
prediction) reduction
Reinforcement learning:
It is machine learning technique that trains software to make
decisions to achieve the most optimal results. It mimics the trial-
and-error learning process that humans use to achieve their
goals.
Here, we take the concept of giving rewards for every positive
result and make it the base of our algorithm.
Let’s take the example of a dog.
We can train our dog to perform certain actions, of course, it
won’t be an easy task. You would order the dog to do certain
actions and for every proper execution, you would give a biscuit
as a reward. The dog will remember that if it does a certain
action, it would get biscuits. This way it will follow the
instructions properly next time.
Another example, in this case, a human child.
Kids often make mistakes. Adults try to make sure they learn
from it and try not to repeat it again. In this case, we can take
the concept of feedbacks. If the parents are strict, they will scold
the children for any mistakes. This is a negative type of feedback.
The child will remember it as if it does a certain wrong action, the
parents will scold the kid.
Then there is positive feedback, where the parent might praise
them for doing something right. This type of learning is called
enforced learning.
Here, we enforce or try to force a correct action in a certain way.
So, in short, reinforcement learning is the type of learning
methodology where we give rewards of feedback to the algorithm
to learn from and improve future results.
This type of learning is on the many research fields on a global
scale, as it is a big help to technologies like AI.
Advantages of Reinforcement Learning
It can solve higher-order and complex problems and the
solutions obtained will be very accurate.
The reason for its perfection is that it is very similar to the
human learning technique.
This model will undergo a rigorous training process that
take time as it helps to correct errors.
Due to it’s learning ability, it can be used with neural
networks. This can be termed as deep reinforcement
learning.
Since the model learns constantly, a mistake made earlier
would be unlikely to occur in the future.
Various problem-solving models are possible to build using
reinforcement learning.
When it comes to creating simulators, object detection in
automatic cars, robots, etc., reinforcement learning plays a
great role in the models.
The best part is that even when there is no training data, it
will learn through the experience it has from processing the
training data.
For various problems, which might seem complex to us, it
provides the perfect models to tackle them.
Machine Learning Vs Statistical Modeling
S.No Statistical Model Machine Learning
The relationship between variables is The relationship between variables is
1. found in the form of mathematical found by the self-learning algorithm that
equations. learns from the data.
The purpose of statistical modeling is to
Machine learning is focused on making
2. find the relationship between variables
accurate predictions.
and to test the hypothesis.
Statistical Modeling takes lot of
Machine learning don’t rely on such
3. assumptions to identify the underlying
assumptions.
distributions and relationships.
More interpretable as compared to
4. Less interpretable and more complex.
machine learning.
The model is developed on training data The model is developed on training data
5. by tuning hyperparameters (parameters that
and tested on testing data.
are set before the learning process starts) to
S.No Statistical Model Machine Learning
get evaluated again testing data.
6. Mostly used for research purposes Mostly used in production environment
It is not best suited to a large amount of It can range from small to large amounts
7.
data. of data sets
Implicit programming requires human Explicit programming requires less human
8.
efforts to do statistical modeling effort.
Best estimate relationship between Strong predictive ability due to the ability
9.
variables to learn from past data.
Mathematics behind Statistical Modeling
Mean, variance, standard deviation, and weighted averaging are
important statistical concepts used to analyze data. These
statistical measures are essential tools for summarizing and
analyzing data, providing insights into the distribution and
characteristics of datasets.
Mean (Average): The mean is a measure of central tendency that
represents the average value of a dataset. It is calculated by
summing up all the values in the dataset and dividing by the
total number of values.
Formula:
Mean = (Sum of all values) / (No. of Values)
Example of Mean Calculation:
Let's calculate the mean of the following set of numbers:
5, 8, 10, 12, 15.
1. Add all the numbers together:
5 + 8 + 10 + 12 + 15 = 50
2. Count the total number of values, which is 5 in this case.
3. Calculate the mean:
Mean = 50 /5
=10
Therefore, the mean (average) of the numbers is 10.
Link to understand arithmetic mean
Ref: https://www.geeksforgeeks.org/arithmetic-mean-formula/
Variance: Variance measures the spread or dispersion of a set of
data points. It quantifies how much the values in a dataset differ
from the mean. A higher variance indicates that the data points
are more spread out from the mean.
Formula:
The formula to calculate the variance of a set of numbers is:
Where:
xi : represents each individual value in the dataset.
_
x : is the mean of the dataset.
n : is the total number of values in the dataset.
Example:
Let's calculate the variance of the following set of numbers:
2, 4, 6, 8, 10.
1. Calculate the mean:
Mean = (2 + 4 + 6 + 8 + 10) / 5
= 30 / 5
=6
2. Calculate the squared differences from the mean for each
value:
(2 − 6) 2 = 16
(4 − 6) 2 =4
(6 – 6) 2 = 0
(8 – 6) 2 =4
(10 – 6) 2 = 16
3. Sum up the squared differences:
16 + 4 + 0 + 4 + 16 = 40
4. Divide by the total number of values (5) to get the variance:
Variance = 40 / 5
=8
Therefore, the variance of the numbers is 8.
Link to understand variance
Ref: https://www.indeed.com/career-advice/career-development/how-to-
calculate-variance
Ref: https://www.cuemath.com/data/variance/
Standard Deviation: The standard deviation is another measure
of the spread of data points in a dataset. It is the square root of
the variance and provides a more interpretable measure of
dispersion. A higher standard deviation indicates greater
variability in the dataset.
Standard deviation is a statistical measurement that looks at
how far individual points in a dataset are dispersed from the
mean of that set. If data points are further from the mean, there
is a higher deviation within the data set. It is calculated as the
square root of the variance.
Formula:
The formula to calculate the standard deviation of a set of
numbers is the square root of the variance:
Example:
Let's continue with the set of numbers we used to calculate the
variance: 2, 4, 6, 8, 10.
1. Calculate the variance (as we did earlier):
Variance = 8
2. Calculate the standard deviation by taking the square root of
the variance:
Therefore, the standard deviation of the numbers is 2.83
Mode
Mode is a measure of central tendency that represents the most
frequently occurring value in a dataset. The mode can be useful
in identifying the most common value or values in a set of data.
Formula:
In a dataset, the mode is the value that appears most frequently.
Example of Mode Calculation:
Let's find the mode of the following set of numbers:
3, 5, 7, 5, 9, 5, 11.
In this dataset, the number 5 appears most frequently, three
times. Therefore, the mode of this dataset is 5.
If there are multiple values that occur with the same highest
frequency, the dataset is considered multimodal. For example, in
the dataset: 2, 4, 6, 4, 8, 6, 10, both 4 and 6 appear twice,
making this dataset multimodal with modes 4 and 6.
Median:
The median is a measure of central tendency in a dataset that
represents the middle value when the data is arranged in
ascending or descending order.
To find the median:
For an odd number of data points, the median is the middle
value.
For an even number of data points, the median is the
average of the two middle values.
For example, in the dataset: 3, 7, 12, 15, 18, the median is 12.
In the dataset: 2, 4, 6, 9, 11, 13, the median is (6 + 9) / 2 = 7.5.