0% found this document useful (0 votes)
27 views45 pages

Machine Learning Fundamentals Explained

Machine Learning (ML) is a subset of artificial intelligence focused on creating systems that learn from data to make predictions. It encompasses various types including supervised, unsupervised, and reinforcement learning, each with specific algorithms and applications. Key concepts include model training, overfitting, underfitting, and the importance of hyperparameters in optimizing performance.

Uploaded by

palemac773
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views45 pages

Machine Learning Fundamentals Explained

Machine Learning (ML) is a subset of artificial intelligence focused on creating systems that learn from data to make predictions. It encompasses various types including supervised, unsupervised, and reinforcement learning, each with specific algorithms and applications. Key concepts include model training, overfitting, underfitting, and the importance of hyperparameters in optimizing performance.

Uploaded by

palemac773
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Machine Learning Basics

Machine Learning Basics:

Definition:

Machine Learning (ML) is a branch of artificial intelligence (AI) that focuses on


building systems that can learn from data, identify patterns, and make
decisions or predictions without being explicitly programmed for every specific
task.

Mitchell (1997): “A computer program is said to learn from experience E with


respect to some class of tasks T and performance measure P, if its performance
at tasks in T, as measured by P, improves with experience E.” 2
Machine Learning Basics:
Types of Machine Learning

1. Supervised Learning
Data: Labeled (input + correct output)
Goal: Learn a function that maps inputs to outputs.
Examples:
Spam detection (Email → Spam/Not Spam)
Predicting house prices

2. Unsupervised Learning
Data: Unlabeled
Goal: Find hidden patterns or groupings in data.
Example
Dept. of Computer Science, YIASCM 3

Customer segmentation
Market basket analysis
Machine Learning Basics:
Types of Machine Learning

3. Reinforcement Learning
Learning by trial and error
Agent learns by interacting with the environment and getting feedback (rewards or
penalties).
Examples:
Game playing (e.g., chess, Go)
Robotics

Dept. of Computer Science, YIASCM


Machine Learning Basics:
Key ML Terminology
Term Description
Model : The ML algorithm + learned patterns from data

Training : Teaching the model using historical data

Testing : Evaluating how well the model performs

Features : Input variables used for prediction

Labels : Target values in supervised learning

Overfitting : When a model learns too much from training data 5

(including noise), and fails to generalize

Underfitting : When a model is too simple and can't capture the


Dept. of Comuter Science, YIASCM
Machine Learning Basics:
Machine Learning Process

• Collect Data

• Prepare Data (cleaning, transforming, splitting)

• Choose a Model (e.g., Decision Tree, SVM, Neural Network)

• Train the Model

• Evaluate the Model (using metrics like accuracy, precision, etc.)

• Tune Parameters (optimize model performance) 6

• Deploy the Model (use it in real-world applications)

Dept. of Comuter Science, YIASCM


Machine Learning Basics:
Common Algorithms

• Linear Regression
• Logistic Regression
• Decision Trees
• Support Vector Machines (SVM)
• K-Nearest Neighbors (KNN)
• Naive Bayes
• K-Means Clustering
• Neural Networks 7

Dept. of Comuter Science, YIASCM


Learning Algorithms in Machine Learning

Learning algorithms are the core techniques that enable machines to


learn patterns from data and make decisions. They are categorized based
on the type of learning and task involved.

Dept. of Comuter Science, YIASCM


Learning Algorithms in Machine Learning
1. Supervised Learning Algorithms
These algorithms learn from labeled data (input-output pairs).
Algorithm Description Use Case

Linear Regression Predicts a continuous value House price prediction

Predicts probability of class


Logistic Regression Email spam detection
membership
Splits data into branches to
Decision Tree Loan approval
make decisions

Random Forest Ensemble of decision trees Fraud detection

K-Nearest Neighbors Classifies based on closest data


Image classification
(KNN) points
9
Support Vector Machine Finds the best boundary
Face recognition
(SVM) between classes
Based on probability and Bayes
Naive Bayes Text classification
Dept. of Comuter Science, YIASCM theorem
Learning Algorithms in Machine Learning
2. Unsupervised Learning Algorithms
These algorithms work on unlabeled data to discover hidden patterns.
Algorithm Description Use Case
Groups data into k
K-Means Clustering Customer segmentation
clusters
Builds a hierarchy of
Hierarchical Clustering Gene expression data
clusters
PCA (Principal
Reduces data dimensions Feature reduction
Component Analysis)
Apriori Finds frequent itemsets Market basket analysis

1
0

Dept. of Comuter Science, YIASCM


Learning Algorithms in Machine Learning
3. Reinforcement Learning Algorithms
These algorithms learn by interacting with an environment and receiving
rewards or penalties.

Algorithm Description Use Case


Game playing (e.g., Pac-
Q-Learning Learns the value of actions
Man)
SARSA Similar to Q-Learning, but updates
Robot navigation
based on actual policy
Deep Q-Network (DQN) Uses deep learning with Q-learning Self-driving cars

1
1

Dept. of Comuter Science, YIASCM


Learning Algorithms in Machine Learning
4. Deep Learning Algorithms
Used for complex tasks like image, speech, and text processing.

Algorithm Description Use Case


Artificial Neural Network Inspired by brain neurons Handwritten digit
(ANN) recognition
Convolutional Neural
Great for image processing Face detection
Network (CNN)
Recurrent Neural Network
Good for sequential data Language modeling
(RNN)
Advanced RNNs for long
LSTM / GRU Machine translation
sequences
1
2

Dept. of Comuter Science, YIASCM


Fundamentals of Machine Learning Concepts
Capacity : The capacity of a machine learning model is its ability to fit
wide variety of functions.

• High capacity models (e.g., deep neural networks) can learn very
complex functions and fit training data very well.

• Low capacity models (e.g., linear models) can only represent simple f
functions.

• Proper capacity should match the complexity of the task to avoid


underfitting or overfitting.
1
3

Dept. of Comuter Science, YIASCM


Fundamentals of Machine Learning Concepts
Overfitting and Underfitting
Overfitting
When a model learns the training data too well, including its noise
and outliers, and fails to generalize to unseen data.

High accuracy on training data, poor accuracy on test data.

Underfitting
When a model is too simple to capture the underlying patterns in
the data.
1
4
Poor performance on both training and test data.

Dept. of Comuter Science, YIASCM


Fundamentals of Machine Learning Concepts
Hyperparameters and Validation Sets

Hyperparameters
Settings that are used to control the training process and model
structure but are not learned from the data.
Examples: Learning rate, number of hidden layers, number of neighbors
(in KNN).

Validation Set
A portion of the dataset (different from training and test sets) used
to tune hyperparameters and prevent overfitting.
1
5
Use: Model selection and evaluation during development.

Dept. of Comuter Science, YIASCM


Fundamentals of Machine Learning Concepts
Estimator
An estimator is a function or algorithm that estimates parameters
of a model based on the data.

In ML:
An estimator refers to any algorithm (like a classifier or regressor)
that can learn from data.

1
6

Dept. of Comuter Science, YIASCM


Fundamentals of Machine Learning Concepts
Bias and Variance

Bias
Error due to incorrect assumptions in the learning algorithm.

High bias → Underfitting

Variance
Error due to the model being too sensitive to small fluctuations in
the training set.

High variance → Overfitting 1


7

Dept. of Comuter Science, YIASCM


Fundamentals of Machine Learning Concepts
Maximum Likelihood Estimation (MLE)

MLE is a method of estimating the parameters of a model by


maximizing the likelihood function, i.e., the probability of observing the
given data under a specific model.

• Suppose you assume data follows a normal distribution.


• MLE finds the mean (μ) and variance (σ²) that make the observed
data most probable.

1
8

Dept. of Comuter Science, YIASCM


Fundamentals of Machine Learning Concepts
Bayesian Statistics
Bayesian statistics is a framework that updates the probability of a
hypothesis as more evidence (data) becomes available, using
Bayes' Theorem.

Formula:

Where:
P(H∣D) = Posterior (updated belief)
P(D∣H) = Likelihood
P(H)= Prior (initial belief)
P(D) = Evidence 1

• MLE gives point estimates.


9

• Bayesian gives a probability distribution over possible parameters.


Dept. of Comuter Science, YIASCM
Supervised Learning Algorithms
Supervised Learning involves training a model on a labeled dataset (i.e.,
inputs and their correct outputs) so it can learn to predict the output for
new, unseen data.

Types of Tasks:

Classification: Predict a category/label


Example: Spam or Not Spam

Regression: Predict a continuous value


Example: House price prediction
2
0

Dept. of Comuter Science, YIASCM


Supervised Learning Algorithms
1. Linear Regression: Predict a continuous numeric value

How it works:
• Assumes a linear relationship between input features (X) and the
output (Y).
• Fits a straight line to the data:

• Finds the best line by minimizing the Mean Squared Error (MSE)
between predicted and actual values.

Use Case: Predicting house prices based on square footage, location, and
2
1
number of rooms.

Dept. of Comuter Science, YIASCM


Supervised Learning Algorithms
2. Logistic Regression : Classify inputs into categories (mainly binary
classification)
How it works:
Uses a sigmoid function to map outputs between 0 and 1
(interpreted as probabilities).

Predicts:

Use Case: Predicting if a customer will buy a product (yes/no)

2
2

Dept. of Comuter Science, YIASCM


Supervised Learning Algorithms
3. Decision Tree : Classify or predict using a tree structure
How it works:
• Splits data based on feature thresholds to reduce impurity (e.g., Gini
index, entropy).
• Each node asks a question like “Is age > 30?” and moves down the tree
accordingly.
Use Case: Credit approval based on age, income, and history

4. Random Forest : Improve accuracy and reduce overfitting using


multiple trees
How it works:
• Builds many decision trees using random subsets of data and features
(bootstrapping + feature randomness). 2
3

• Final prediction is by majority vote (classification) or average


(regression).
[Link]: Customer churn prediction, fraud detection
of Comuter Science, YIASCM
Supervised Learning Algorithms
5. Support Vector Machine (SVM) : Find the optimal boundary
(hyperplane) between classes
How it works:
• Finds the hyperplane that maximizes margin between classes.
• Can use kernels (e.g., RBF) to model non-linear boundaries.
Use Case: Face detection, text classification

6. K-Nearest Neighbors (KNN) : Classify or predict based on proximity to


neighbors
How it works:
• Stores all training data.
• For a new data point, it looks at the k closest points and predicts
based on the majority (classification) or average (regression). 2
4

Use Case: Recommender systems, digit recognition


Dept. of Comuter Science, YIASCM
Supervised Learning Algorithms
7. Naive Bayes : Fast, probabilistic classification based on Bayes’ Theorem
How it works:
• Assumes that features are independent given the class.
• Computes posterior probability for each class and picks the one with
the highest probability.
Use Case: Spam filtering, sentiment analysis

8. Gradient Boosting / XGBoost / LightGBM : Powerful ensemble models


for structured/tabular data
How it works:
• Builds trees sequentially, where each new tree corrects the errors of
the previous ones.
• Uses gradient descent to minimize loss. 2
5

Use Case: Highly competitive ML tasks (e.g., Kaggle), stock prediction


Dept. of Comuter Science, YIASCM
Unsupervised Learning Algorithms
Unsupervised Learning involves training a model on unlabeled data. The
goal is to find hidden patterns, structures, or groupings in the data without
any predefined output.

Common Tasks in Unsupervised Learning:

• Clustering – Group similar data points together


Example: Grouping customers based on buying behavior
• Dimensionality Reduction – Simplify data while preserving important
information
Example: Reducing image data for visualization or faster
computation 2

• Association Rule Learning – Discover rules that describe large portions6 of


data
Example: Market basket analysis
Dept. of Comuter Science, YIASCM
Unsupervised Learning Algorithms
1. K-Means Clustering : Partition data into K groups (clusters)
How it works:
• Choose K cluster centers randomly
• Assign each data point to the nearest cluster center
• Update the centers as the mean of the assigned points
• Repeat until convergence
Use Case: Customer segmentation, image compression

2. Hierarchical Clustering : Build a tree (dendrogram) of nested clusters


How it works:
• Start with each point as its own cluster
• Repeatedly merge the closest clusters based on distance (agglomerative 2

method) 7

Use Case: Biological taxonomy, document clustering


Dept. of Comuter Science, YIASCM
Unsupervised Learning Algorithms
3. Principal Component Analysis (PCA) : Reduce dimensionality of data
How it works:
• Transforms the data to a new coordinate system
• Keeps only the most important directions (principal components) that
retain the most variance
Use Case: Data visualization, speeding up ML algorithms

4. Apriori Algorithm (Association Rule Learning): Find frequent itemsets


and generate association rules
How it works:
• Iteratively finds common item combinations
• Uses support, confidence, lift as rule metrics 2
8

Use Case: Market basket analysis (e.g., "people who buy milk also buy
bread")
Dept. of Comuter Science, YIASCM
Stochastic Gradient Descent (SGD)
Stochastic Gradient Descent (SGD) is an optimization algorithm used to
train machine learning models, especially those with large datasets.
It aims to minimize the loss (or cost) function by updating model
parameters iteratively using gradients.

Gradient Descent Basics:


• Gradient Descent is a method to find the minimum of a function (like the
loss function).
• It updates parameters in the opposite direction of the gradient.
Update Rule:
θ=θ−η⋅∇J(θ)
Where: 2

θ : Model parameters (weights) 9

η : Learning rate (step size)


∇J(θ) : Gradient of the cost function w.r.t. θ
Dept. of Comuter Science, YIASCM
Stochastic Gradient Descent (SGD)
How SGD Works:

• Shuffle the training data


• For each training example x(i) , y(i)
• Compute the gradient of the loss
• Update the weights using the gradient
• Move to the next example
• Repeat over several epochs (full passes over the data).

3
0

Dept. of Comuter Science, YIASCM


Building a Machine Learning Algorithm
Building a machine learning algorithm involves both mathematical
understanding and practical implementation.
Step 1: Define the Problem
Type: Classification, Regression, Clustering?
Goal: Predict customer churn, classify images, etc.

Step 2: Collect and Prepare the Data


Collect Data:
Use CSV files, databases, APIs, sensors, etc.
Clean and Preprocess:
Handle missing values, remove duplicates
Normalize or standardize features
Convert categorical data using one-hot encoding 3
1
Split data: Training set (e.g., 70%)
Validation set (optional)
Test set (e.g., 30%)
Dept. of Comuter Science, YIASCM
Building a Machine Learning Algorithm
Step 3: Choose a Model
Choose based on the problem type:

Problem Type Suggested Algorithms


Classification Logistic Regression, SVM, Random Forest,KNN
Regression Linear Regression, Decision Tree Regressor
Clustering K-Means, DBSCAN, Hierarchical

3
2

Dept. of Comuter Science, YIASCM


Building a Machine Learning Algorithm
Step 4: Train the Model
• Initialize the model
• Feed it training data
• Use an optimization algorithm like Stochastic Gradient Descent (SGD) to
minimize loss

3
3

Dept. of Comuter Science, YIASCM


Building a Machine Learning Algorithm
Step 5: Evaluate the Model
Use performance metrics to evaluate the trained model:
Classification:
• Accuracy
• Precision, Recall, F1-score
• Confusion Matrix

Regression:
• Mean Squared Error (MSE)
• Mean Absolute Error (MAE)
• R² Score
3
4

Dept. of Comuter Science, YIASCM


Building a Machine Learning Algorithm
Step 6: Tune Hyperparameters (Optional)
• Use Grid Search or Random Search to find the best hyperparameters
• Can also use cross-validation to reduce overfitting

Step 7: Make Predictions


Use the trained model on unseen/test data.
3
5

Dept. of Comuter Science, YIASCM


Building a Machine Learning Algorithm
Step 8: Deploy the Model
• Once satisfied with accuracy:
• Export the model (.pkl, .joblib, etc.)
• Serve it through an API (Flask/FastAPI)
• Integrate into applications or dashboards

3
6

Dept. of Comuter Science, YIASCM


Challenges Motivating Deep Learning.
Deep Learning has emerged as a powerful subset of machine learning,
especially for tasks like image recognition, natural language processing, and
speech synthesis.

why was deep learning necessary in the first place?

3
7

Dept. of Comuter Science, YIASCM


Challenges Motivating Deep Learning.
1. Manual Feature Extraction

Challenge:
• Traditional machine learning models (e.g., SVM, decision trees) require
manual feature engineering.
• This is time-consuming, domain-specific, and error-prone.

How Deep Learning Helps:


• Deep learning models automatically learn features from raw data (e.g.,
pixels, sound waves).
• Example: CNNs learn edges, textures, and shapes directly from images.
3
8

Dept. of Comuter Science, YIASCM


Challenges Motivating Deep Learning.
2. Poor Performance on Unstructured Data

Challenge:
Traditional ML performs well on structured/tabular data but struggles with:
Images
Text
Audio
Video

How Deep Learning Helps:


• Deep Neural Networks are designed for unstructured data.
• RNNs/LSTMs handle sequences (e.g., language, time series). 3
9

• CNNs dominate image and video analysis.


Dept. of Comuter Science, YIASCM
Challenges Motivating Deep Learning.

3. Scalability with Large Datasets


Challenge:
• Classical models often hit a performance plateau as data volume
increases.
• Many models do not scale well with massive datasets.

How Deep Learning Helps:


• Deep learning models improve performance with more data (data-
hungry).
• Models like transformers scale well on huge text/image corpora. 4
0

Dept. of Comuter Science, YIASCM


Challenges Motivating Deep Learning.

4. Complex Pattern Learning


Challenge:
• Shallow models can only learn simple, linear, or shallow patterns.
• Difficult to capture hierarchical or abstract representations.

How Deep Learning Helps:


• Deep networks can model multiple levels of abstraction.
• Each layer learns increasingly complex representations
(e.g., in NLP: characters → words → sentences → meaning).
4
1

Dept. of Comuter Science, YIASCM


Challenges Motivating Deep Learning.

5. Generalization and Transfer Learning


Challenge:
• Classical models usually retrain from scratch for every new task.
• Limited reuse of learned knowledge.

How Deep Learning Helps:


• Deep learning enables transfer learning: reusing pre-trained models.
Example: Use a pre-trained ResNet for various vision tasks.

4
2

Dept. of Comuter Science, YIASCM


Challenges Motivating Deep Learning.
6. Lack of End-to-End Learning
Challenge:
• Traditional ML often involves separate stages: preprocessing → feature
extraction → modeling → evaluation.
• Each stage may need manual tuning.

How Deep Learning Helps:


• Deep learning allows end-to-end training.
Input raw data → Output prediction → Learn everything in between
automatically.

4
3

Dept. of Comuter Science, YIASCM


Challenges Motivating Deep Learning.
7. Increased Computational Power

Historical Limitation:
Training deep models was computationally expensive and
impractical.

Recent Developments:
Availability of GPUs/TPUs, cloud computing, and optimized libraries
(like TensorFlow, PyTorch) now make deep learning feasible at scale.

4
4

Dept. of Comuter Science, YIASCM


Challenges Motivating Deep Learning.
8. Challenges in Language Understanding
Challenge:
Traditional NLP models couldn’t understand context or long-term
dependencies.

Deep Learning Response:


• Use of RNNs, LSTMs, GRUs, and now Transformers (e.g., BERT, GPT).
• These models capture context, sequence, and meaning effectively.

4
5

Dept. of Comuter Science, YIASCM

You might also like