Introducion To ML
Introducion To ML
In the real world, we are surrounded by humans who can learn everything from
their experiences with their learning capability, and we have computers or
machines which work on our instructions. But can a machine also learn from
experiences or past data like a human does? So here comes the role of Machine
Learning.
Arthur Samuel first used the term "machine learning" in 1959. It could be
summarized as follows:
A machine can learn if it can gain more data to improve its performance.
PROF.MISS. RANDIVE T. S. 1
How does Machine Learning work
A machine learning system builds prediction models, learns from previous data,
and predicts the output of new data whenever it receives it. The amount of data
helps to build a better model that accurately predicts the output, which in turn
affects the accuracy of the predicted output.
PROF.MISS. RANDIVE T. S. 2
By providing them with a large amount of data and allowing them to
automatically explore the data, build models, and predict the required output,
we can train machine learning algorithms. The cost function can be used to
determine the amount of data and the machine learning algorithm's
performance. We can save both time and money by using machine learning.
Following are some key points which show the importance of Machine
Learning:
PROF.MISS. RANDIVE T. S. 3
Types of Machine Learning
Supervised Learning
PROF.MISS. RANDIVE T. S. 4
Example: Consider a scenario where you have to build an image classifier to
differentiate between cats and dogs. If you feed the datasets of dogs and cats
labelled images to the algorithm, the machine will learn to classify between a
dog or a cat from these labeled images. When we input new dog or cat images
that it has never seen before, it will use the learned algorithms and predict
whether it is a dog or a cat. This is how supervised learning works, and this is
particularly an image classification.
There are two main categories of supervised learning that are mentioned
below:
Classification
Regression
Classification
Classification deals with predicting categorical target variables, which
represent discrete classes or labels. For instance, classifying emails as spam or
not spam, or predicting whether a patient has a high risk of heart disease.
Classification algorithms learn to map the input features to one of the
predefined classes.
Regression
Regression, on the other hand, deals with predicting continuous target
variables, which represent numerical values. For example, predicting the price
of a house based on its size, location, and amenities, or forecasting the sales of a
product. Regression algorithms learn to map the input features to a continuous
numerical value.
PROF.MISS. RANDIVE T. S. 5
Supervised Learning models can have high accuracy as they are trained
on labelled data.
The process of decision-making in supervised learning models is often
interpretable.
It can often be used in pre-trained models which saves time and resources
when developing new models from scratch.
PROF.MISS. RANDIVE T. S. 6
Unsupervised Learning
Example: Consider that you have a dataset that contains information about the
purchases you made from the shop. Through clustering, the algorithm can group
the same purchasing behavior among you and other customers, which reveals
potential customers without predefined labels. This type of information can help
businesses get target customers as well as identify outliers.
There are two main categories of unsupervised learning that are mentioned
below:
Clustering
Association
Clustering
Clustering is the process of grouping data points into clusters based on their
similarity. This technique is useful for identifying patterns and relationships in
data without the need for labeled examples.
Here are some clustering algorithms:
K-Means Clustering algorithm
Mean-shift algorithm
DBSCAN Algorithm
Principal Component Analysis
Independent Component Analysis
Association
Association rule learning is a technique for discovering relationships between
items in a dataset. It identifies rules that indicate the presence of one item
implies the presence of another item with a specific probability.
Here are some association rule learning algorithms:
Apriori Algorithm
Eclat
FP-growth Algorithm
PROF.MISS. RANDIVE T. S. 7
Advantages of Unsupervised Machine Learning
It helps to discover hidden patterns and various relationships between the
data.
Used for tasks such as customer segmentation, anomaly
detection, and data exploration.
It does not require labeled data and reduces the effort of data labeling.
3. Semi-Supervised Learning
PROF.MISS. RANDIVE T. S. 8
Semi-Supervised learning is a machine learning algorithm that works between
the supervised and unsupervised learning so it uses both labelled and
unlabelled data. It’s particularly useful when obtaining labeled data is costly,
time-consuming, or resource-intensive. This approach is useful when the dataset
is expensive and time-consuming. Semi-supervised learning is chosen when
labeled data requires skills and relevant resources in order to train or learn from
it.
We use these techniques when we are dealing with data that is a little bit labeled
and the rest large portion of it is unlabeled. We can use the unsupervised
techniques to predict labels and then feed these labels to supervised techniques.
This technique is mostly applicable in the case of image data sets where usually
all images are not labeled.
Semi-Supervised Learning
PROF.MISS. RANDIVE T. S. 9
Co-training: This approach trains two different machine learning models on
different subsets of the unlabeled data. The two models are then used to label
each other’s predictions.
Self-training: This approach trains a machine learning model on the labeled
data and then uses the model to predict labels for the unlabeled data. The
model is then retrained on the labeled data and the predicted labels for the
unlabeled data.
Generative adversarial networks (GANs): GANs are a type of deep
learning algorithm that can be used to generate synthetic data. GANs can be
used to generate unlabeled data for semi-supervised learning by training two
neural networks, a generator and a discriminator.
PROF.MISS. RANDIVE T. S. 10
4. Reinforcement Machine Learning
Reinforcement machine learning algorithm is a learning method that interacts
with the environment by producing actions and discovering errors. Trial, error,
and delay are the most relevant characteristics of reinforcement learning. In
this technique, the model keeps on increasing its performance using Reward
Feedback to learn the behavior or pattern. These algorithms are specific to a
particular problem e.g. Google Self Driving car, AlphaGo where a bot competes
with humans and even itself to get better and better performers in Go Game.
Each time we feed in data, they learn and add the data to their knowledge which
is training data. So, the more it learns the better it gets trained and hence
experienced.
Example: Consider that you are training an AI agent to play a game like chess.
The agent explores different moves and receives positive or negative feedback
based on the outcome. Reinforcement Learning also finds applications in which
they learn to perform tasks by interacting with their surroundings.
PROF.MISS. RANDIVE T. S. 11
Types of Reinforcement Machine Learning
There are two main types of reinforcement learning:
Positive reinforcement
Rewards the agent for taking a desired action.
Encourages the agent to repeat the behavior.
Examples: Giving a treat to a dog for sitting, providing a point in a game for
a correct answer.
Negative reinforcement
Removes an undesirable stimulus to encourage a desired behavior.
Discourages the agent from repeating the behavior.
Examples: Turning off a loud buzzer when a lever is pressed, avoiding a
penalty by completing a task.
PROF.MISS. RANDIVE T. S. 12
Game AI: RL can be used to create more intelligent and adaptive NPCs in
video games.
Adaptive Personal Assistants: RL can be used to improve personal
assistants.
Virtual Reality (VR) and Augmented Reality (AR): RL can be used to
create immersive and interactive experiences.
Industrial Control: RL can be used to optimize industrial processes.
Education: RL can be used to create adaptive learning systems.
Agriculture: RL can be used to optimize agricultural operations.
PROF.MISS. RANDIVE T. S. 13
Difference between Supervised & Unsupervised Learning
Supervised Learning Unsupervised Learning
Supervised learning algorithms are Unsupervised learning algorithms are
trained using labeled data. trained using unlabeled data.
Supervised learning model takes direct Unsupervised learning model does not
feedback to check if it is predicting take any feedback.
correct output or not.
Supervised learning model predicts the Unsupervised learning model finds the
output. hidden patterns in data.
In supervised learning, input data is In unsupervised learning, only input
provided to the model along with the data is provided to the model.
output.
The goal of supervised learning is to The goal of unsupervised learning is to
train the model so that it can predict the find the hidden patterns and useful
output when it is given new data. insights from the unknown dataset.
Supervised learning needs supervision Unsupervised learning does not need
to train the model. any supervision to train the model.
Supervised learning can be categorized Unsupervised Learning can be
in Classification and Regression proble classified
ms. in Clustering and Associations proble
ms.
Supervised learning can be used for Unsupervised learning can be used for
those cases where we know the input as those cases where we have only input
well as corresponding outputs. data and no corresponding output data.
Supervised learning model produces an Unsupervised learning model may
accurate result. give less accurate result as compared
to supervised learning.
Supervised learning is not close to true Unsupervised learning is more close to
Artificial intelligence as in this, we first the true Artificial Intelligence as it
train the model for each data, and then learns similarly as a child learns daily
only it can predict the correct output. routine things by his experiences.
It includes various algorithms such as It includes various algorithms such as
Linear Regression, Logistic Regression, Clustering, KNN, and Apriori
Support Vector Machine, Multi-class algorithm.
Classification, Decision tree, Bayesian
Logic, etc.
PROF.MISS. RANDIVE T. S. 14
Applications of Machine learning
1. Image Recognition:
2. Speech Recognition
PROF.MISS. RANDIVE T. S. 15
Speech recognition is a process of converting voice instructions into text, and it
is also known as "Speech to text", or "Computer speech recognition." At
present, machine learning algorithms are widely used by various applications of
speech recognition. Google assistant, Siri, Cortana, and Alexa are using
speech recognition technology to follow the voice instructions.
3. Traffic prediction:
If we want to visit a new place, we take help of Google Maps, which shows us
the correct path with the shortest route and predicts the traffic conditions.
o Real Time location of the vehicle form Google Map app and sensors
o Average time has taken on past days at the same time.
Everyone who is using Google Map is helping this app to make it better. It takes
information from the user and sends back to its database to improve the
performance.
4. Product recommendations:
Google understands the user interest using various machine learning algorithms
and suggests the product as per customer interest.
5. Self-driving cars:
PROF.MISS. RANDIVE T. S. 16
6. Email Spam and Malware Filtering:
o Content Filter
o Header filter
o General blacklists filter
o Rules-based filters
o Permission filters
These assistant record our voice instructions, send it over the server on a cloud,
and decode it using ML algorithms and act accordingly.
Machine learning is making our online transaction safe and secure by detecting
fraud transaction. Whenever we perform some online transaction, there may be
various ways that a fraudulent transaction can take place such as fake
accounts, fake ids, and steal money in the middle of a transaction. So to detect
this, Feed Forward Neural network helps us by checking whether it is a
genuine transaction or a fraud transaction.
For each genuine transaction, the output is converted into some hash values, and
these values become the input for the next round. For each genuine transaction,
there is a specific pattern which gets change for the fraud transaction hence, it
detects it and makes our online transactions more secure.
PROF.MISS. RANDIVE T. S. 17
9. Stock Market trading:
Machine learning is widely used in stock market trading. In the stock market,
there is always a risk of up and downs in shares, so for this machine
learning's long short term memory neural network is used for the prediction
of stock market trends.
In medical science, machine learning is used for diseases diagnoses. With this,
medical technology is growing very fast and able to build 3D models that can
predict the exact position of lesions in the brain. It helps in finding brain tumors
and other brain-related diseases easily.
Nowadays, if we visit a new place and we are not aware of the language then it
is not a problem at all, as for this also machine learning helps us by converting
the text into our known languages. Google's GNMT (Google Neural Machine
Translation) provide this feature, which is a Neural Machine Learning that
translates the text into our familiar language, and it called as automatic
translation.
PROF.MISS. RANDIVE T. S. 18
General steps to follow in a Machine Learning Problem
The Machine Learning pipeline starts with data collection and integration.
After data is collected analysis and visualization of data is done. Further, the
most crucial step feature selection and engineering is performed then the
model is trained. After that model, evaluation is done and our model
becomes ready for prediction!
To understand the pipeline well, consider building an ML model for a
company’s customer care service. Consider a company XYZ, as an online
book shop, that delivers books and kindle to its customer and this company
wants an improved customer care service. It wants that if a customer calls
the helpline for any kind of issue, say for replacement of books, complaint of
kindle purchased or some other services. The company wants to ensure that
the customer’s call gets directed to the right service person in minimum time
and that the process should be smooth. To build a model for customer care
services of the company, we will use the ML pipeline for the systematic
development of the model.
PROF.MISS. RANDIVE T. S. 19
1. Data Collection and integration:
The first step of the ML pipeline involves the collection of data and
integration of data.
Data collected acts as an input to the model (data preparation phase)
Inputs are called features.
Data collected in the case of our considered example involves a lot of data.
The collected data should answer the following questions- What is past
customer history? What were the past orders? Is the customer a prime
member of our bookstore? Does the customer own a kindle? Has the
customer made any previous complaints? What was the most number of
complaints?
The more the data is, more the better our model becomes.
Once the data is collected we need to integrate and prepare the data.
Integration of data means placing all related data together.
Then data preparation phase starts in which we manually and critically
explore the data.
The data preparation phase tells the developer that is the data matching the
expectations. Is there enough info to make an accurate prediction? Is the data
consistent?
PROF.MISS. RANDIVE T. S. 20
Feature engineering is arguably the most crucial and time-consuming step of
the ML pipeline.
Feature selection and engineering answers questions – Are these features
going to make any sense in our prediction?
It deals with the accuracy and precision of data.
4. Model Training:
After the first three steps are done completely we enter the model training
phase.
It is the first step officially when the developer gets to train the model on
basis of data.
To train the model, data is split into three parts- Training data, validation
data, and test data.
Around 70%-80% of data goes into the training data set which is used in
training the model.
Validation data is also known as development set or dev set and is used to
avoid overfitting or underfitting situations i.e. enabling hyperparameter
tuning.
Hyperparameter tuning is a technique used to combat overfitting and
underfitting.
Validation data is used during model evaluation.
Around 10%-15% of data is used as validation data.
Rest 10%-15% of data goes into the test data set. Test data set is used for
testing after the model preparation.
It is crucial to randomize data sets while splitting the data to get an accurate
model.
Data can be randomized using Scikit learn in python.
5. Model Evaluation:
After the model training, validation, or development data is used to evaluate
the model.
To get the most accurate predictions to test data may be used for further
model evaluation.
A confusion matrix is created after model evaluation to calculate accuracy
and precision numerically.
After model evaluation, our model enters the final stage that is prediction.
6. Prediction:
In the prediction phase developer deploys the model.
After model deployment, it becomes ready to make predictions.
Predictions are made on training data and test data to have a better
understanding of the build model.
PROF.MISS. RANDIVE T. S. 21
Challenges or Issues in Machine Learning
"Machine Learning" is one of the most popular technology among all data
scientists and machine learning enthusiasts. It is the most effective Artificial
Intelligence technology that helps create automated learning systems to take
future decisions without being constantly programmed. Machine Learning
offers great opportunities, but some issues need to be solved.
The major issue that comes while using machine learning algorithms is the lack
of quality as well as quantity of data. Although data plays a vital role in the
processing of machine learning algorithms, many data scientists claim that
inadequate data, noisy data, and unclean data are extremely exhausting the
machine learning algorithms. For example, a simple task requires thousands of
sample data, and an advanced task such as speech or image recognition needs
millions of sample data examples. Further, data quality is also important for the
algorithms to work ideally, but the absence of data quality is also found in
Machine Learning applications. Data quality can be affected by some factors as
follows:
PROF.MISS. RANDIVE T. S. 22
3. Non-representative training data
To make sure our training model is generalized well or not, we have to ensure
that sample training data must be representative of new cases that we need to
generalize. The training data must cover all cases that are already occurred as
well as occurring.
Overfitting:
PROF.MISS. RANDIVE T. S. 23
o Constraining the model.
Underfitting:
Underfitting occurs when our model is too simple to understand the base
structure of the data, just like an undersized pant. This generally happens when
we have limited data into the data set, and we try to build a linear model with
non-linear data. In such scenarios, the complexity of the model destroys, and
rules of the machine learning model become too easy to be applied on this data
set, and the model starts doing wrong predictions as well.
As we know that generalized output data is mandatory for any machine learning
model; hence, regular monitoring and maintenance become compulsory for the
same. Different results for different actions require data change; hence editing
of codes as well as resources for monitoring them also become necessary.
PROF.MISS. RANDIVE T. S. 24
7. Lack of skilled resources
8. Customer Segmentation
The machine learning process is very complex, which is also another major
issue faced by machine learning engineers and data scientists. However,
Machine Learning and Artificial Intelligence are very new technologies but are
still in an experimental phase and continuously being changing over time. There
is the majority of hits and trial experiments; hence the probability of error is
higher than expected. Further, it also includes analyzing the data, removing data
bias, training data, applying complex mathematical calculations, etc., making
the procedure more complicated and quite tedious.
Data Biasing is also found a big challenge in Machine Learning. These errors
exist when certain elements of the dataset are heavily weighted or need more
importance than others. Biased data leads to inaccurate results, skewed
outcomes, and other analytical errors. However, we can resolve this error by
determining where data is actually biased in the dataset. Further, take necessary
steps to reduce it.
PROF.MISS. RANDIVE T. S. 25
o Analyze data regularly and keep tracking errors to resolve them easily.
o Review the collected and annotated data.
o Use multi-pass annotation such as sentiment analysis, content
moderation, and intent recognition.
Machine learning life cycle involves seven major steps, which are given below:
o Gathering Data
o Data preparation
o Data Wrangling
o Analyse Data
o Train the model
o Test the model
o Deployment
PROF.MISS. RANDIVE T. S. 26
The most important thing in the complete process is to understand the problem
and to know the purpose of the problem. Therefore, before starting the life
cycle, we need to understand the problem because the good result depends on
the better understanding of the problem.
1. Gathering Data:
Data Gathering is the first step of the machine learning life cycle. The goal of
this step is to identify and obtain all data-related problems.
In this step, we need to identify the different data sources, as data can be
collected from various sources such as files, database, internet, or mobile
devices. It is one of the most important steps of the life cycle. The quantity and
quality of the collected data will determine the efficiency of the output. The
more will be the data, the more accurate will be the prediction.
By performing the above task, we get a coherent set of data, also called as
a dataset. It will be used in further steps.
2. Data preparation
After collecting the data, we need to prepare it for further steps. Data
preparation is a step where we put our data into a suitable place and prepare it to
use in our machine learning training.
In this step, first, we put all data together, and then randomize the ordering of
data.
PROF.MISS. RANDIVE T. S. 27
o Data exploration:
It is used to understand the nature of data that we have to work with. We
need to understand the characteristics, format, and quality of data.
A better understanding of data leads to an effective outcome. In this, we
find Correlations, general trends, and outliers.
o Data pre-processing:
Now the next step is preprocessing of data for its analysis.
3. Data Wrangling
Data wrangling is the process of cleaning and converting raw data into a useable
format. It is the process of cleaning the data, selecting the variable to use, and
transforming the data in a proper format to make it more suitable for analysis in
the next step. It is one of the most important steps of the complete process.
Cleaning of data is required to address the quality issues.
It is not necessary that data we have collected is always of our use as some of
the data may not be useful. In real-world applications, collected data may have
various issues, including:
o Missing Values
o Duplicate data
o Invalid data
o Noise
It is mandatory to detect and remove the above issues because it can negatively
affect the quality of the outcome.
4. Data Analysis
Now the cleaned and prepared data is passed on to the analysis step. This step
involves:
PROF.MISS. RANDIVE T. S. 28
techniques such as Classification, Regression, Cluster analysis, Association,
etc. then build the model using prepared data, and evaluate the model.
Hence, in this step, we take the data and use machine learning algorithms to
build the model.
5. Train Model
Now the next step is to train the model, in this step we train our model to
improve its performance for better outcome of the problem.
We use datasets to train the model using various machine learning algorithms.
Training a model is required so that it can understand the various patterns, rules,
and, features.
6. Test Model
Once our machine learning model has been trained on a given dataset, then we
test the model. In this step, we check for the accuracy of our model by
providing a test dataset to it.
Testing the model determines the percentage accuracy of the model as per the
requirement of project or problem.
7. Deployment
The last step of machine learning life cycle is deployment, where we deploy the
model in the real-world system.
PROF.MISS. RANDIVE T. S. 29