machine learning report including usin linear c;assification model with python coding, Lab Reports of Machine Learning

MOdel traning ang guessing on the basis of regression and using linear classification model..

Typology: Lab Reports

2024/2025

Uploaded on 04/14/2026

zakoota-raj
zakoota-raj 🇸🇬

5 documents

1 / 7

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
University of
Engineering
and Technology Taxila
Assignment 1
(ML & AI)
Name: Hajra Wajid
Reg. No: 23-CP-60
Section: Omega
Course title: Machine Learning & Artificial Intelligence
Submitted To: Dr. Waqar Ahmad
Course Instructor: Dr. Waqar Ahmad
pf3
pf4
pf5

Partial preview of the text

Download machine learning report including usin linear c;assification model with python coding and more Lab Reports Machine Learning in PDF only on Docsity!

University of

Engineering

and Technology Taxila

Assignment 1

(ML & AI)

Name: Hajra Wajid

Reg. No: 23-CP-

Section: Omega

Course title: Machine Learning & Artificial Intelligence

Submitted To: Dr. Waqar Ahmad

Optimization Algorithms

1. Introduction

Optimization algorithms are at the core of machine learning, enabling models to learn from data. They minimize a loss function by iteratively adjusting model parameters. The choice of optimizer is critical, influencing training speed, convergence, and the final performance of the model. This document provides a detailed overview of a wide range of optimization algorithms, from foundational first-order methods to advanced second-order techniques.

2. First-Order Optimization Methods

First-order methods use the gradient (the first derivative) of the loss function to guide the search for the minimum. They are computationally efficient and widely used in deep learning. 2.1. Gradient Descent (GD) Gradient Descent is the most fundamental optimization algorithm. It works by calculating the gradient of the loss function with respect to the model parameters and moving in the opposite direction of the gradient. Formula: θ_{t+1} = θ_t - η · ∇J(θ_t) Where:

  • θ: Model parameters
  • η: Learning rate (step size)
  • ∇J(θ): Gradient of the loss function J with respect to θ Pros and Cons: Pros:  Simple to understand and implement.  Guaranteed to converge to the global minimum for convex functions. Cons:  Can be slow to converge, especially on flat surfaces.  Sensitive to the choice of learning rate.  Prone to getting stuck in local minima or saddle points in non-convex landscapes. 2.2. Stochastic Gradient Descent (SGD) An extension of GD that updates parameters using only a single training example (or a small mini-batch) at each step. This introduces noise, which can help escape local minima, but also makes the convergence path erratic.

Cons:  Can sometimes fail to converge to the optimal solution (generalization issues).  Weight decay (L2 regularization) is not handled optimally in the original formulation. 2.6. AdamW (Adam with Decoupled Weight Decay) AdamW is a modification of the Adam optimizer that addresses a specific flaw: the way weight decay (L2 regularization) is implemented. In standard Adam, L2 regularization is added to the loss function, which means it gets mixed with the adaptive learning rate logic. AdamW decouples the weight decay from the gradient update step. Why AdamW? By decoupling weight decay, AdamW ensures that the regularization effect is consistent regardless of the adaptive learning rate. This leads to significantly better generalization performance, making it the preferred choice for training modern deep learning models like Transformers. Pros and Cons: Pros:  Better generalization than standard Adam.  More stable training for large-scale models. Cons:  Slightly more complex to implement (though available in all major frameworks).

3. Second-Order and Quasi-Newton Methods

These methods use the second derivative (Hessian matrix) of the loss function to find the minimum. They can converge much faster but are computationally expensive. 3.1. Conjugate Gradient (CG) An iterative algorithm for solving systems of linear equations, which is equivalent to minimizing a quadratic function. It's more efficient than GD as it avoids redundant search directions. Pros and Cons: Pros: Faster than GD, doesn't require storing a Hessian matrix. Cons: Primarily designed for quadratic problems, less common in deep learning. 3.2. BFGS (Broyden–Fletcher–Goldfarb–Shanno)

A powerful quasi-Newton method that approximates the inverse Hessian matrix, avoiding the need to compute it directly. It's very effective for optimization problems. Pros and Cons: Pros: Very fast convergence, highly accurate. Cons: Requires storing the dense inverse Hessian approximation, which is memory-intensive for large models. 3.3. L-BFGS (Limited-memory BFGS) A memory-efficient version of BFGS. Instead of storing the full inverse Hessian approximation, it stores only a few vectors that represent the approximation implicitly. This makes it suitable for large-scale problems. Pros and Cons: Pros: Memory-efficient, suitable for large models. Cons: Can be slower than the full BFGS method.

4. Comparison Summary