Introduction To Machine Learning
Introduction To Machine Learning
MACHINE LEARNING
-Shalom Albert
HOW DOES BRAIN WORK?
WE DON’T KNOW!!!
According to Google Search
The brain sends and receives chemical and electrical signals throughout the body.
Different signals control different processes, and your brain interprets each. Some
make you feel tired, for example, while others make you feel pain.
ARTIFICIAL INTELLIGENCE
DEFINITION
Artificial intelligence (AI) refers to the simulation or approximation of human intelligence in
machines
HUMAN INTELLIGENCE
MACHINE LEARNING
Machine learning (ML) is a field of artificial intelligence (AI) that provides
machines with the ability to automatically learn from data and past experiences
while identifying patterns to make predictions with minimal human
intervention.
How Do We Learn?
WE LEARN BY ….
EXAMPLES EXPERIENCE
HOW DOES MACHINE
LEARNING MODELS LEARN?
Machine learning (ML) is a field of artificial intelligence (AI) that provides
machines with the ability to automatically learn from data and past experiences
Training Data: Used to train the model, i.e., the model learns patterns from this
data.
•Typically 70-80% of the Data is called Training Set
When a model performs very well for •When a model has not learned the patterns
training data but has poor performance in the training data well and is unable to
with test data it is known as overfitting generalize well on the new data(test data),
it is known as underfitting.
In this case, the machine learning
•poor performance on the training data will
model learns the unnecessary details and
result in unreliable predictions which
noise in the training data such that it affects the performance of the model on
negatively affects the performance of test data(poor performance with test data)
the model on test data
HI
Validation Data:
Used to fine-tune the model's hyperparameters and avoid overfitting during training
Train-Validation-Test Split
CODE:
from sklearn.model_selection import train_test_split
#Assuming 'X' is your feature matrix and 'y' is your target variable
# First split: 80% training and 20% (validation + test)
X_train, X_temp, y_train, y_temp = train_test_split(X, y, test_size=0.2)
# Second split: Divide the 20% into 50-50 for validation and test
X_validation, X_test, y_validation, y_test = train_test_split(X_temp, y_temp,
test_size=0.5)
MACHINE LEARNING
WORKFLOW
MODEL EVALUATION
TECHNIQUES
Model evaluation is the process that uses some metrics which help us to analyze the
performance of the model
BASIC CONFUSION MATRIX
To understand
https://www.geeksforgeeks.org/confusio
n-matrix-machine-learning/
MODEL EVALUATION
TECHNIQUES
https://www.geeksforgeeks.org/machine-learning-model-evaluation/
CROSS VALIDATION
SUPERVISED LEARNING
machines are trained on labeled datasets and
enabled to predict outputs based on the
provided training
UNSUPERVISED LEARNING
In This type of ML, the machine is trained using an unlabeled dataset and is enabled
to predict the output without any supervision. An unsupervised learning algorithm
aims to group the unsorted dataset based on the input’s similarities, differences, and
patterns.
SEMI-SUPERVISED LEARNING
This is a machine learning algorithm that works between the
supervised and unsupervised learning so it uses both labelled and un-
labelled data
REINFORCEMENT LEARNING
Reinforcement learning is a feedback-based process
where an agent learns to make decisions by interacting with an environment. The
agent receives feedback in the form of rewards or penalties based on its actions, and
the goal is to discover a policy that maps states to actions to maximize cumulative
rewards over time
USE CASE:
Supervised Learning:
Classification: Predicting whether an email is spam or not.
Regression: Predicting the price of a house based on its features.
Unsupervised Learning:
Clustering: Grouping customers based on their purchasing behavior.
Dimensionality Reduction: Reducing the number of features in an image dataset.
Generative Modeling: Generating new images similar to existing ones.
Reinforcement Learning:
Game Playing: Teaching an agent to play chess or video games.
Robotics: Training a robot to perform tasks such as grasping objects.
Steps:
K-MEANS CLUSTERING
1) Decide how many clusters you want,
i.e. choose k
2) Randomly assign a centroid to each
of the k clusters
3) Calculate the distance of all
observation to each of the k centroids
4) Assign observations to the closest
centroid
5) Find the new location of the centroid
by taking the mean of all the
observations in each cluster
6) Repeat steps 3-5 until the centroids
do not change position
HOW WE CALCULATE THE
DISTANCE?
Euclidean distance. That’s right! The same one we are taught when learning the
Pythagorean theorem. Let us take a look and consider two data observations over
two attributes a and b. Point p1 has coordinates (a1,b1) and point p2=(a2,b2).
HANDS ON K-MEANS
CLUSTERING
https://www.datacamp.com/tutorial/k-means-clustering-python
HIERARCHICAL CLUSTERING
https://datatab.net/tutorial/hierarchical-cluster-analysis
HANDS ON HIERARCHICAL
CLUSTERING
https://www.upgrad.com/blog/hierarchical-clustering-in-python/