cover photo

COURSEWORK

Nithish's AI-ML-001 course work. Lv 2

Nithish N SAUTHORACTIVE
This Report is yet to be approved by a Coordinator.

MARVEL AIML Level 1 Tasks Report (Monthly)

20 / 3 / 2025


Nithish N S - AIML Level 1 Tasks Report


TASK 1: Numpy

I used numpy for efficient array manipulation, including repeating , reshaping , and generating sequences. The shape function retrieves array dimensions, while the prod(shape) computes total elements for reshaping and arange() creates a sequential array. Numpy improves speed, memory efficiency, and eliminates the need for loops.

NumPy


TASK 2: Matplotlib and Data Visualisation

I used matplotlib for quick and flexible data visualization. It helps create simple plots, like line and bar charts, with full control over labels, colors, and legends. It integrates well with numpy and forms the base for advanced libraries like seaborn. My key learning is that matplotlib is great for basic plotting, while seaborn enhances aesthetics and statistical insights.

AreaPlot ScatterBubblePlot SimpleBarPlot GroupedBarPlot StackedBarPlot Histogram PiePlot BoxPlot MarginalPlot ContourPlot Heatmapt 3dPlot


TASK 3: Linear and Logistic Regression - HelloWorld for AIML

Linear Regression

In linear regression, I learned how the cost function helps measure prediction errors, and how algorithms like gradient descent achieve convergence. I understood the role of learning rate in controlling the speed and stability of training. To evaluate models, I explored performance metrics like R² and adjusted R². I also grasped the importance of avoiding overfitting and underfitting for better generalization.

LinearRegression

Logistic Regression

In logistic regression, I learned how the sigmoid function is used for squashing outputs between 0 and 1. I understood the cost function that helps measure classification error. I explored performance metrics like the confusion matrix, including true positives, true negatives, false positives, and false negatives. I also learned to calculate precision, recall, and the F1-score to evaluate model performance.

LogisticRegression


TASK 4: Metrics and Performance Evaluation

Regression Metrics

In regression, I evaluate how well my model predicts continuous values.

  • Mean Absolute Error (MAE): It tells me the average difference between the predicted and actual prices.
  • Mean Squared Error (MSE): This squares the errors, so bigger mistakes are penalized more.
  • Root Mean Squared Error (RMSE): It gives me the error in the same unit as house prices.
  • R-squared (R²): This shows how much of the price variation is explained by my model.

Classification Metrics

In classification, I measure how accurately my model predicts categories or class labels.

  • Accuracy: It tells me the overall correctness of my model.
  • Precision: It shows how many of my positive predictions were actually correct.
  • Recall: It helps me understand how well I’m capturing the actual positive cases.
  • F1 Score: It balances precision and recall for a more reliable performance measure.
  • Confusion Matrix: It gives me a clear breakdown of true and false positives and negatives.

TASK 5: An elementary step towards understanding Neural Networks

Neural Network

Imagine a neural network as a learned function that predicts, based on how the human brain functions.

Simple Analogy:
Visualize a system of light switches (neurons). Each switch receives some electricity (input), makes a tiny decision (weights + bias), and sends it down. Lots of switches in layers collaborate to determine what the ultimate light (output) should be.

Main Concepts:

  • Neuron: One thing that accepts inputs, scales them with weights, adds a bias, and activates.
  • Weights: Values that indicate how significant every input is.
  • Activation Function: A function which determines whether the neuron fires or not.
  • Layers:
    • Input layer: Accepts raw data.
    • Hidden layers: Performed computations.
    • Output layer: Produces end result (say, cat or dog).

ANN (Artificial Neural Network)

It is employed for numbers or word data (e.g. predicting prices, detecting spam)

Structure: Input → Hidden Layers → Output

Thinks like: A calculator working problems in stages.

CNN (Convolutional Neural Network)

It is employed for images and visual information (e.g. facial recognition, image classification)

Structure: Convolution → Pooling → Dense Layers

Thinks like: An eye that acquires patterns in pictures.

How Large Language Models Such As GPT-4 Work

A language model is a form of artificial intelligence that can comprehend and create human language. If you've ever chatted with ChatGPT, you're conversing with a large language model (LLM).

GPT-4 (Generative Pretrained Transformer 4) is a very large language model trained on huge amounts of text from books, websites, and conversations.

  • Answer questions
  • Write essays and code
  • Translate languages
  • Understand images (in newer versions)

Building GPT-4 is very complex, but let's simplify it into 5 simple steps:

Collect a Huge Amount of Text Data

To train a model such as GPT-4, you require a tremendous amount of text consider

  • Books, articles, websites, Wikipedia
  • Code, math, even forum dialog

This serves to allow the model to "read" the world and become educated on the nature of language.

Construct the Transformer Architecture

GPT-4 employs what's known as a Transformer, a type of neural network for processing sequences (such as sentences). It functions by:

  • Tokenizing text (cutting text up into pieces of words)
  • Understanding how words are connected with each other through attention (e.g. "The cat sat on its mat" → who is its?)

Pretrain the Model

The model now learns by predicting the next word in a sentence. For instance:

Input: "The sun rises in the…" Target: "east"

It does this millions or billions of times, slowly tweaking its internal math (weights) to get better.

Fine-tune and Align

After pretraining, the model is fine-tuned to better execute instructions. This could involve:

  • Additional training in dialogue and question-answering
  • Reinforcement Learning from Human Feedback (RLHF) — where humans sort model responses to assist it in learning behavior

Scale It Up

GPT-4 has hundreds of billions of parameters (such as the "settings" within the model). More parameters means more brainpower, yet it also implies:

  • More GPUs (graphics cards)
  • More memory and computing time
  • Enormous energy and financial expenses

Tools You'd Need

  • High-performance servers with GPUs (such as NVIDIA A100s)
  • Billions of words of training data
  • ML libraries such as PyTorch or TensorFlow
  • Huge distributed training infrastructure

TASK 6: Mathematics behind machine learning

Curve Fitting

I plotted a set of data points and used linear regression to find the best fit line that represents the trend.

CurveFit

Fourier Transforms

First, it generates a 5 Hz sine wave in the time domain. Next, it employs the Fourier Transform (through fft) to examine that signal. This provides the frequency content of the signal. Lastly, it plots the frequency spectrum, which indicates a peak at 5 Hz, which verifies the signal has that frequency.

Ft1 Ft2


To be continued!!!

UVCE,
K. R Circle,
Bengaluru 01