Hello everyone this repo will contain my journey of machine learning and DeepLearning with some exciting projects
Jupyter Notebook
74
697 commits
updated Apr 7, 2025

| Books and Resources | Status of Completion |
|---|---|
| 1. Machine Learning Specialization | ✅ |
| 2.Hands-On Machine Learning with Scikit-Learn and TensorFlow | ✅ |
| 3.Intro to DeepLearning | ✅ |
| 4.Deep Learning Specialization | ✅ |
| 5.LLM from Scratch | ✅ |
| 6.Hugging face Nlp course | ✅ |
| 7.LLM course | 🏊 |
| 8.Efficiently Serving LLMs | ✅ |
| 9.Langchain docs | ✅ |
| Days | Topics Covered | Resources |
|---|---|---|
| Day1 | Superviesed learning, regression, classification | Machine Learning Specialization |
| Day2 | Univariate Linear regression, Cost function | Machine Learning Specialization |
| Day3 | Gradient descent | Machine Learning Specialization |
| Day4 | Learning rate | Machine Learning Specialization |
| Day5 | Multiple linear regression, Vectorization | Machine Learning Specialization |
| Day6 | Feature scaling, Choosing correct learning rate | Machine Learning Specialization |
| Day7 | Feature engineering, Polynomial regression | Machine Learning Specialization |
| Day8 | Classification, Logistic regression | Machine Learning Specialization |
| Day9 | Sigmoid function, Decision boundary | Machine Learning Specialization |
| Day10 | Gradient descent in Logistic regression, Cost function in Logistic regression | Machine Learning Specialization |
| Day11 | Gradient descent in logistic regression Implementation | Machine Learning Specialization |
| Day12 | Underfitting,Overfitting, Addressing overfitting, Plotting overfitting,Regularization implementation | Machine Learning Specialization |
| Day13 | Neural Network Introduction , Why neural network? | Machine Learning Specialization |
| Day14 | Neural Network notation, forward propagation, Neuron Layer implementation | Machine Learning Specialization |
| Day15 | Neural network implementation for digit classification, Classification of AI | Machine Learning Specialization |
| Day16 | Vectorization in Neural Network , Neural network of Handwritten Binary Digit Classification | Machine Learning Specialization |
| Day17 | Model Training Steps, Activation Function , Implementation of ReLU | Machine Learning Specialization |
| Day18 | Multi Class classification, soft max regression, cost for softmax regression | Machine Learning Specialization |
| Day19 | Improved Implementation of softmax/logistic regression in neural network,multilabel classification, Advanced optimization, Additional layer types | Machine Learning Specialization |
| Day20 | BackpropagationImplementation of Backpropagation, Debugging a learning algorithm, Model selection and Machine learning diagnostic | Machine Learning Specialization |
| Day21 | Bias/Variance , choosing regularization parameter | Machine Learning Specialization |
| Day22 | Diagonising Bias and Variance ,Labs on Diagonising Bias and Variance , Choosing regularization parameter | Machine Learning Specialization |
| Day23 | Iterative loop of ML Development, Error analysis, Transfer Learning | Machine Learning Specialization |
| Day24 | Full cycle of Machine learning projects,Precison and Recall , Trading off precison and recall , Lab on Full Machine Learning Cycle | Machine Learning Specialization |
| Day25 | Decision Tree, Decision Tree Learning | Machine Learning Specialization |
| Day26 | Measuring Impurity, Information Gain, Decision Tree Learning, Recursive Splitting | Machine Learning Specialization |
| Day27 | One hot encoding, Splitting for continous variable, Regression Tree | Machine Learning Specialization |
| Day28 | Tree ensemble , Random Forest Algorithm, XG boost, when to use decision tree | Machine Learning Specialization |
| Day29 | Unsupervised Learning, K means clustering Algorithm, cost function for k means clustering,Labs on K means Clustering | Machine Learning Specialization |
| Day30 | Anamoly detection, Anamoly detection vs supervised Learning use case | Machine Learning Specialization |
| Day31 | Recommender system, Content based Recommendation, Collaborative Filtering Recommender Systems | Machine Learning Specialization |
| Day32 | Normalization, Limitation of Collaborative Filtering,Lab Collabrative filetering recommender system, Content base recommendation for large items | Machine Learning Specialization |
| Day33 | Tensorflow implementation of Collaborative Filtering,Dimensonality Reduction, PCA | Machine Learning Specialization |
| Day34 | Step by step calculation of PCA , Implementation of PCA, | Machine Learning Specialization |
| Day35 | Reinforcement Learning, Markov Decision Process | Machine Learning Specialization |
| Day36 | State Action Value Function, Bellman Function, Random stochastic environment,State Action value function Implementation | Machine Learning Specialization |
| Day37 | Discrete State and Continuous State, Refinement of reinforcement learning by minibatches and softupdate | Machine Learning Specialization |
| Day38 | Building a Book Recommender System using Collaborative Filtering | Machine Learning Specialization |
| Day39 | California Housing Price Prediction : Batch learning vs online learning, Cost for Linear regression (RMSE and MAE) usecase,fetching and loading of data with EDA | Hands-On Machine Learning with Scikit-Learn and TensorFlow |
| Day40 | California Housing Price Prediction (Continued) : Created test data , and splitted data on the basis of train-test-split and also with stratifcation split to remove imbalance in data and create same proportion. | Hands-On Machine Learning with Scikit-Learn and TensorFlow |
| Day41 | California Housing Price Prediction (Continued) : data visualization, EDA | Hands-On Machine Learning with Scikit-Learn and TensorFlow |
| Day42 | California Housing Price Prediction (Continued) : feature engineering, using simple imputer, handling categorical data by encoding | Hands-On Machine Learning with Scikit-Learn and TensorFlow |
| Day43 | California Housing Price Prediction (Continued) :Feature Scaling and Bucket Binning | Hands-On Machine Learning with Scikit-Learn and TensorFlow |
| Day44 | California Housing Price Prediction (Continued) : Data preprocessing pipeling development | Hands-On Machine Learning with Scikit-Learn and TensorFlow |
| Day45 | California Housing Price Prediction (Continued) : Selection, training and evaluation of model | Hands-On Machine Learning with Scikit-Learn and TensorFlow |
| Day46 | Binary Classification, measuring accuracy using Confusion matrix and ROC curve | Hands-On Machine Learning with Scikit-Learn and TensorFlow |
| Day47 | Multiclass classification, Multilablel classification, Multioutput classification Classification Implementation | Hands-On Machine Learning with Scikit-Learn and TensorFlow |
| Day48 | Linear Regression, Gradient descent, Stochastic Gradient descent and SGD regressor, Implementation | Hands-On Machine Learning with Scikit-Learn and TensorFlow |
| Day49 | Polynomial Regression, Learning curve, overfitting , underfitting and its solution | Hands-On Machine Learning with Scikit-Learn and TensorFlow |
| Day50 | Ridge Regression and its Implementation with SGD Regressor | Hands-On Machine Learning with Scikit-Learn and TensorFlow |
| Day51 | Lasso Regression, elastic net regression and early stopping | Hands-On Machine Learning with Scikit-Learn and TensorFlow |
| Day52 | Revision on logistic regression and softmax regression, logloss, Implementing logistic regression | Hands-On Machine Learning with Scikit-Learn and TensorFlow |
| Day53 | SVM, kernel function and kernel trick | Hands-On Machine Learning with Scikit-Learn and TensorFlow |
| Day54 | Polynomial kernel and RBF kernel | Hands-On Machine Learning with Scikit-Learn and TensorFlow |
| Day55 | Support Vector Machine and It classes | Hands-On Machine Learning with Scikit-Learn and TensorFlow |
| Day56 | Decision Tree and regularization in decision tree and its implementation | Hands-On Machine Learning with Scikit-Learn and TensorFlow |
| Day57 | Decision Tree for regression , hyperparameter tuning and its implementation. | Hands-On Machine Learning with Scikit-Learn and TensorFlow |
| Day58 | Ensemble Learning and Voting classifier | Hands-On Machine Learning with Scikit-Learn and TensorFlow |
| Day59 | Bootstrap Aggregation | Hands-On Machine Learning with Scikit-Learn and TensorFlow |
| Day60 | Random patches and random subspaces | Hands-On Machine Learning with Scikit-Learn and TensorFlow |
| Day61 | Random Forest | Hands-On Machine Learning with Scikit-Learn and TensorFlow |
| Day62 | Boosting | Hands-On Machine Learning with Scikit-Learn and TensorFlow |
| Day63 | History based gradient boosting and stacking | Hands-On Machine Learning with Scikit-Learn and TensorFlow |
| Day64 | Dimensionality Reduction and PCA | Hands-On Machine Learning with Scikit-Learn and TensorFlow |
| Day65 | Local Linear embeddings and K means | Hands-On Machine Learning with Scikit-Learn and TensorFlow |
| Day66 | Supervised Learning in Neural Network | Deep Learning Specialization |
| Day67 | Image Classifier using sequential API | Hands-On Machine Learning with Scikit-Learn and TensorFlow |
| Day68 | Vectorization and Broadcasting in python | Hands-On Machine Learning with Scikit-Learn and TensorFlow |
| Day69 | Deep Learning Api to create complex model | Hands-On Machine Learning with Scikit-Learn and TensorFlow |
| Day70 | Perceptron as a binary classifier | Deep Learning Specialization |
| Day71 | Perceptron trick , Loss function in perceptron, Gradient descent, Backpropagation, Batching and regularization, | Hands-On Machine Learning with Scikit-Learn and TensorFlow |
| Day72 | RNNS, Encoding, Embeddings, Implementing simple RNN | Introduction to Deeplearning |
| Day73 | Backpropagation through time, Gradient issues | Introduction to Deeplearning |
| Day74 | LSTM, self attention | Introduction to Deeplearning) |
| Day75 | Convolution Neural Network(CNN) | Introduction to Deeplearning) |
| Day76 | Convolution Neural Network(CNN) Implementation and deeper understanding | Introduction to Deeplearning) |
| Day77 | Steps of CNN and deeper intuition | Introduction to Deeplearning) |
| Day78 | R-CNN | Introduction to Deeplearning) |
| Day79 | Bird species classification using CNN | Introduction to Deeplearning) |
| Day80 | Generative Modeling, Auto encoder and Variational Auto encoders | Introduction to Deeplearning) |
| Day81 | prior on latent distribution , Regualrization and normal prior , Reparametrization, Latent peturbation and entanglement | Introduction to Deeplearning) |
| Day82 | Generative Adversarial Networsk (GANS) | Introduction to Deeplearning) |
| Day83 | Challenges for robust deep learning, algorithmic bias,Class Imbalance, Class Imbalance solution | Introduction to Deeplearning) |
| Day84 | Debiasing VAES and uncertainity | Introduction to Deeplearning) |
| Day85 | Auto encoders | Introduction to Deeplearning) |
| Day86 | Unsupervised retraining using stacked autoencoders and Tying Weights | Introduction to Deeplearning) |
| Day87 | Training autoencoders at a time,convolutional autoencoders, denoising autoencoder | Hands-On Machine Learning with Scikit-Learn and TensorFlow |
| Day88 | Sparsity autoencoders | Hands-On Machine Learning with Scikit-Learn and TensorFlow |
| Day89 | variable autoencoders and its implementation | Hands-On Machine Learning with Scikit-Learn and TensorFlow |
| Day90 | GAN implementation | Hands-On Machine Learning with Scikit-Learn and TensorFlow |
| Day91 | sigmoid function,sigmoid derivative, image to vector conversion, normalizing rows, softmax function, vectorization, L1 loss, L2 loss | Deep Learning Specialization |
| Day92 | shallow neural network and implemented logistic regression on neural network | Deep Learning Specialization |
| Day93 | Optimization ,EWMA | Deep Learning Specialization |
| Day94 | SGD momentum,Nesterov Accelerated Gradient (NAG),Adaptive Gradient(ADaGrad) | Deep Learning Specialization |
| Day95 | Adam optimizer,RMSProp optimizer | Deep Learning Specialization |
| Day96 | Regularization of neural network ,L1 and L2 regularization , Dropout regularzation, data augementation , early stopping for reducing overfitting and orthogonalization | Deep Learning Specialization |
| Day97 | Normalizing input features to make gradinet descent faster , Vanishing and exploding of gradients, Checking of gradient descent | Deep Learning Specialization |
| Days | Topics Covered | Resources |
|---|---|---|
| Day211 | Multiagent soft start | Agent Course) |
Learns from being given right answers.
Supervised machine learning is based on the basis of labeled data.First the data is fed to the model with both input and output and later on test data is given to make prediction by model.
some algorithm used in supervised learning with their uses are :
Learns by finding pattern in unlabelled data.
Unsupervised learning is different from supervised learning as it is not provided with labelled data.The algorithm work by finding pattern in data.
some algorithm used in unsupevised learning with it uses are:
Univariate linear regression has one dependent variable and one independent variable. With the help of indendent variable also known as input,feature we predict the output. Firstly we provide training set to our model and later on we predict the output using training set.
A cost function is a measure of how well a machine learning model performs by quantifying the difference between predicted and actual outputs.
lower the value of cost function better the model


Gradient descent is an algorithm for finding values of parameters w and b that minimize the cost function J.It is made cleared in below image.

Learning rate alpha in gradient descent should be optimal.
If learning rate is too small gradient descent may be too slow and take much time.
If learning rate is too large gradient descent may overshoot and never reach minimum i.e fail to converge,diverge.

📚Resources
course:Machine Learning Specialization
Multiple linear regression in machine learning model that uses multiple variables called as features to predicts the output.

In muliple linear regression calculation is done using vectorization as it perform all calculation simultaneously and parallely and speed up the arithmetic operations.

When you data features has very large range,too small range gradient descent may take large time so data is rescaled to normal similar range called feature scaling. some popular feature scaling techniques are:


First we make sure gradient descent is decreasing over the iteration by looking at learning curve if it is working properly we choose correct learning rate by starting with smaller learning rate and increase it gradually.
Feature engineering means designing newfeatures by transforming or combining original features which maybe very important in prediciting the output.
for e.g: we have to predict the price of swimming pool and we have length breadth and height of swimming pool as features now we can used feature engineering to create our new feature which is volume which is very important in predicting the price of swimming pool.
Polynomial Regression is a regression algorithm that models the relationship between a dependent(y) and independent variable(x) as nth degree polynomial. The Polynomial Regression equation is given below:
y= b0+b1x1+ b2x12+ b2x13+...... bnx1n
It is used incase of non linear dataset.

Classification is a type of supervised learning in machine learning, where the goal is to predict the class label of an input data point.For example, we may want to classify emails as spam or not spam, or classify images as cats or dogs.
Logistic regression is a type of algorithm used for classification problems. It works by estimating the probability of an input data point belonging to a particular class. For example, it may estimate the probability that an email is spam or not spam, or the probability that an image is a cat or a dog.
To estimate these probabilities, logistic regression uses a mathematical function called the logistic function, which maps the input data to the probability space. The logistic regression algorithm then learns the relationships between the input features and the target class by adjusting weights, or coefficients, assigned to each input feature. These weights are adjusted to maximize the probability of the correct classification.
In the end, logistic regression outputs the predicted class for each input data point, based on the estimated probabilities. This can be useful for a wide range of classification tasks, from predicting diseases to detecting fraud.

The sigmoid function is a mathematical function that maps any input value to a value between 0 and 1. It is commonly used in logistic regression to model the probability of a binary outcome. The sigmoid function has an S-shaped curve and is defined as follows:
σ(z) = 1 / (1 + e^(-z))
where z is the input value to the function. The output of the sigmoid function, σ(z), is a value between 0 and 1, with a midpoint at z=0.
The sigmoid function has several important properties that make it useful in logistic regression. First, it is always positive and ranges between 0 and 1, which makes it suitable for modeling probabilities. Second, it is differentiable, which means that it can be used in optimization algorithms such as gradient descent. Finally, it has a simple derivative that can be expressed in terms of the function itself:
d/dz σ(z) = σ(z) * (1 - σ(z))
This derivative is used in logistic regression to update the model coefficients during the optimization process.
The decision boundary is the line that separates the area where y=0 and where y=1.It is create by our hypothesis function.
In logistic regression, the decision boundary is the line (or hyperplane in higher dimensions) that separates the different classes of the target variable. The decision boundary is determined by the logistic regression model, which uses the input variables to predict the probability of belonging to a certain class.

Logistic Regression Ŷi is a nonlinear function(Ŷ=1/1+ e-z), if we put this in the above MSE equation it will give a non-convex function as shown:

When we try to optimize values using gradient descent it will create complications to find global minima.
Another reason is in classification problems, we have target values like 0/1, So (Ŷ-Y)2 will always be in between 0-1 which can make it very difficult to keep track of the errors and it is difficult to store high precision floating numbers.
The cost function used in Logistic Regression is Log Loss.

Cost function for logistic regression

Gradient Descent in Logistic Regression is an iterative optimisation algorithm used to find the local minimum of a function. It works by tweaking parameters w and b iteratively to minimize a cost function by taking steps proportional to the negative of the gradient at the current point.
Gradient descent in logistic regression looks similar to gradient descent in linear regression but it has different value for function.

It is a situtation when the training set doesnot fit well. It happen when data has high bias.
It is a situation when the training set fit extremely well . It is also known as data with high variance.
Regularization is a technique to reduce the parameter and prevent overfitting of data. It has a term called lambda whose value if larger result underfitting and smaller result overfitting it also called penalty term.

Neural network is an computer algorithms that try to mimic the brain.neural network is made of a input layer that take input data and hidden layer does all the computation and output layer displays the output.
Why neural network ?
Neural network is necessary because it increase performance of machine learning algorithm compared to traditional algorithm like linear regression and logistic regression because it uses multiple and more algorithm in a neural network to make better prediction and performances.

In neural network.
Forward propagation refers to storage and calculation of input data which is fed in forward direction through the network to generate an output. Hidden layers in neural network accepts the data from the input layer, process it on the basis of activation function and pass it to the output layer or the successive layers. Data flows in forward direction so as to avoid circular shape flow of data which will not generate an output. The network configuration that helps in forward propagation is known as feed-forward network.
📚Resources
course:Machine Learning Specialization
Neural network can be easily implemented in tensorflow as below:
AI is mainly classified into two type: ANI and AGI
AGI:An AGI is a hypothetical intelligent agent that can learn to accomplish any intellectual task that human beings or other animals can perform. It is defined as an autonomous system that surpasses human capabilities in the majority of economically valuable tasks
📚Resources
course:Machine Learning Specialization
In neural network vectorization helps to perform calculation simultaneously and save a lot of time. It can implemented as :



Model training is simplified in 3 steps :
There are different activation function for different purpose some of the most commonly used are :
For hidden layer we choose ReLU as activation and for output layer we choose activation according to our problems,because if we choose sigmoid in hidden layer than neural network becomes very slow so it better to choose Relu in hidden layer
Target y can take on more than two possible values. In this case of multiclass classification we use Softmax regression.
Softmax regression is the generalization of logistic regression for multiple classs.
Its output is calculated as:

Cost for softmax regression is also known as cross-entropy loss. It is obtained as.

Our normal implementation of softmax cause some of numerical roundoff error so for the more numerical accurate implementation of softmax regression we use linear activation in output layer and passing from_logits = True as parameter in loss at model.compile().
You can get more insight by looking at image below:

Multilabel classification is a type of classification problem in machine learning where each instance can be assigned to multiple classes or labels simultaneously. In other words, instead of predicting a single class for an instance, the goal is to predict a set of labels that are applicable to that instance.
Here is difference between multiclass and multilable classfication

Adam algorithm is used for advanced optimization in neural network.
model.compile( optimizer=tf.keras.optimizers.Adam(learning_rate=1e-3), loss = tf.kearas.losses.SparseCategoricalCrossentropy(from_logits=True))
Some of layer types of neural network are :
Dense Layer (Fully Connected Layer): A dense layer is a basic layer where each neuron is connected to every neuron in the previous layer. It is characterized by its weight matrix, bias vector, and activation function. Dense layers are commonly used in feedforward neural networks and can learn complex patterns and relationships in the data.
Convolutional Layer: Convolutional layers are primarily used in convolutional neural networks (CNNs) for analyzing grid-like data, such as images. These layers perform convolutions, applying filters to the input data, and capturing local patterns and features. Convolutional layers are effective in image recognition, object detection, and other computer vision tasks.
Convaulational neural network are faster in computation and need less training data as compared to Dense Layer.
📚Resources
course:Machine Learning Specialization
Backpropagation, or backward propagation of errors, is an algorithm used in machine learning to adjust the parameters of a neural network by calculating the gradients of a loss function with respect to the network's weights and biases. It propagates the error from the output layer to the input layer, allowing the network to learn and improve its predictions.
When we have large error in prediction we can debugg or learning algorithm as follow:
You can evaluate a model by splitting data into trian/test and calculating cost for both training set and test set .
The most effective way of model selection is by
A test that you can run to gain insight into what is/isn't working with a learning algorithm to gain guidance into improving its performance .
Ml model can be diagonse by looking at bias and variance:
When model has high bias and variance it is not doing well.


To choose good regularization paramter.

Ml development revolve around following steps:

It is the process to isolate,observe and diagnose erroneous ML predictions to understand pockets of high and low performance to the model.
Adding more data is mostly useful to make better predictions and data can be added by following ways:
Transfer learning is a machine learning method where a model developed for a task is reused as the starting point for a model on a second task.
It is a popular approach in deep learning where pre-trained models are used as the starting point on computer vision and natural language processing tasks given the vast compute and time resources required to develop neural network models on these problems and from the huge jumps in skill that they provide on related problems.
Machine learning project is iterative process which is as below:

Mlops focuses on making ml model to be used in largescale and deployment is basically done by:

While developing machine learning application we have to take care of biasness and negative case like :
1.Deepfake
2.Genrating fake content for commercial and political purposes
3.Ml model biasing in loan provider,job selection.

F1 score which is the harmonic mean of precision and recall.A decision tree is a type of supervised machine learning used to categorize or make predictions based on how a previous set of questions were answered. The model is a form of supervised learning, meaning that the model is trained and tested on a set of data that contains the desired categorization.

In decision tree entropy is the measure of level of impurity and helps to find purity of classes. lower impurity means higher purity.

We can calculate the information gain by subtracting the weighted average entropy of the resulting subsets from the entropy of the original node. The formula for information gain is:
Information Gain = Entropy(node) - Σ((subset_size/total_size) * Entropy(subset))

Recursive splitting refers to the iterative process in decision tree construction where a dataset is divided into smaller subsets based on specific conditions. It involves recursively selecting attributes to split on and creating branches that further partition the data until a stopping criterion is met, resulting in a tree-like structure.
If a categorical features can take on k values, create k binary features(0 or 1 values) is call one hot encoding.
For continuous variable we have to choose threshold with higher information gain and split on the basis of that threshold.
It is a decision based tree used to predict continous variables.
Single decision tree is very sensitive to data so the process of combining many decision tree to build more robust system is called tree ensemble. the prediciton of tree ensemble is obtained by majority result of tree.
A random forest algorithm is a machine learning technique that combines the predictions of multiple decision trees to make more accurate and robust predictions. It works by creating an ensemble of decision trees, where each tree is trained on a random subset of the data and uses a random subset of features. The final prediction is then made by averaging or voting the predictions of all the trees in the forest. The random forest algorithm is effective at handling complex datasets, handling missing values, and avoiding overfitting.

In XG boost we basically pick the training examples that were misclassified previously instead of training all samples.
It is implemented as :

Machine leanring algorithm that find patterns on unlabelled data.
K-means clustering is an unsupervised machine learning algorithm used for partitioning a dataset into K distinct non-overlapping clusters. Each data point in the dataset is assigned to the cluster with the nearest mean (centroid). The algorithm aims to minimize the within-cluster variance, also known as the "inertia."
Here's a step-by-step overview of the k-means clustering algorithm:
Initialization: Randomly select K data points from the dataset as the initial cluster centroids.
Assignment: Assign each data point to the nearest centroid. This is done by calculating the Euclidean distance (or other distance metrics) between each data point and each centroid, and assigning the data point to the cluster with the closest centroid.
Update: Recalculate the centroids of each cluster by taking the mean of all the data points assigned to that cluster.
Repeat: Repeat steps 2 and 3 until convergence or a maximum number of iterations is reached. Convergence occurs when the centroids no longer move significantly between iterations or when the algorithm reaches the predefined maximum number of iterations.
Final Clusters: Once convergence is achieved, the algorithm outputs the final cluster assignments, where each data point belongs to one of the K clusters.

The cost function for k-means clustering is commonly referred to as the "inertia" or "within-cluster sum of squares." It measures the sum of squared distances between each data point and its assigned centroid within each cluster. The goal of k-means clustering is to minimize this cost function.
Mathematically, the cost function (J) for k-means clustering can be defined as:
J = Σᵢ Σⱼ ||xᵢ - μⱼ||²
Anomaly Detection is the technique of identifying rare events or observations which can raise suspicions by being statistically different from the rest of the observations. Such “anomalous” behaviour typically translates to some kind of a problem like a credit card fraud, failing machine in a server, a cyber attack, etc.
We will use anamoly detection when there are very small number of example that are positive(anamoly) and large number of negative example .Since small number of positive examples it is hard to learn from training examples.e.g: fraud detection
We will use supervised learning when large number of positive and negative examples are present. Since there are enough positive examples to train model and predict supervised learning is effective. e.g Email spam detection
Recommender systems are a type of machine learning algorithm used to suggest items to users based on their preferences or behavior. These systems are widely used in various applications like e-commerce, movie streaming platforms, music apps, and more.
In content-based recommender systems, the algorithm recommends items based on the similarity between the content/features of the items and the user's preferences. The similarity is typically computed using techniques such as cosine similarity or Euclidean distance. Here's an overview of the mathematical steps involved:
a. Feature Representation: Each item and user is represented as a feature vector. Let's denote an item's feature vector as x and a user's preference vector as p. These vectors consist of numerical values that represent the attributes or characteristics of items or users.
b. Similarity Measure: The similarity between two feature vectors, x and p, can be computed using cosine similarity. The cosine similarity between x and p is defined as:
similarity(x, p) = (x · p) / (||x|| * ||p||)
where (x · p) represents the dot product of vectors x and p, and ||x|| and ||p|| denote their respective Euclidean norms.
Collaborative filtering recommender systems make recommendations based on the preferences or behavior of other similar users or items. Let's explore the two main approaches: user-based and item-based collaborative filtering.
In user-based collaborative filtering, the algorithm finds similar users based on their past interactions or ratings and recommends items that the similar users have liked. Here are the mathematical steps involved:
i. User Similarity: The similarity between two users, u and v, can be computed using techniques such as cosine similarity or Pearson correlation. The similarity score measures the likeness of their past interactions.
ii. Prediction: To predict a user's preference for a particular item, the system combines the ratings of similar users. The predicted rating, denoted as r_hat(u, i), for user u and item i is calculated as a weighted average of the ratings of similar users:
r_hat(u, i) = ∑ (sim(u, v) * r(v, i)) / ∑ |sim(u, v)|
#where sim(u, v) represents the similarity between users u and v, r(v, i) denotes the rating of user v for item i, and the summation is performed # over all similar users v.
where sim(u, v) represents the similarity between users u and v, r(v, i) denotes the rating of user v for item i, and the summation is performed over all similar users v. iii. Recommendation: The system recommends items with the highest predicted ratings to the active user.
In item-based collaborative filtering, the algorithm identifies similar items based on the past interactions or ratings of users. It then recommends items that are similar to the ones the user has already liked. Here's a summary of the mathematical steps involved:
i. Item Similarity: The similarity between two items, i and j, can be computed using techniques such as cosine similarity or Pearson correlation. The similarity score measures the likeness of user preferences for the items.
ii. Prediction: To predict a user's preference for a particular item, the system considers the user's past ratings for similar items. The predicted rating, denoted as r_hat(u, i), for user u and item i is calculated as a weighted average of the user's ratings for similar items:
r_hat(u, i) = ∑ (sim(i, j) * r(u, j)) / ∑ |sim(i, j)|
#where sim(i, j) represents the similarity between items i and j, r(u,
Normalization is a technique often applied as part of data preparation for machine learning. The goal of normalization is to change the values of numeric columns in the dataset to use a common scale, without distorting differences in the ranges of values or losing information.
How to
It uses both content and user data and using neural network create vector for content and vector for user and its dot product give prediction.
When our website or app has large number of content to recommend like thousands and millon of item it is carried out in two steps:
From large number of content retrival is carried out for selective content for further ranking. for e.g:
For movies recommendation:
1.for 10 movies watched by user retrieve similar movies.
2.for most viewed 3 genres find top 10 movies.
3.find top 20 movies in country.
At last combined retrived item in list and remove duplicated and items already purchased.
Apply model to retrived data to find suitable item and display ranked item to user.
Note: Retriving more items result in better recommendation but takes more time to analyse try it offline and find suitable number of retrival for better and relevant recommendations.
Dimensionality reduction is a technique used to reduce the number of features in a dataset while retaining as much of the important information as possible. In other words, it is a process of transforming high-dimensional data into a lower-dimensional space that still preserves the essence of the original data
Feature selection : Feature selection involves selecting a subset of the original features that are most relevant to the problem at hand. The goal is to reduce the dimensionality of the dataset while retaining the most important features. There are several methods for feature selection, including filter methods, wrapper methods, and embedded methods. Filter methods rank the features based on their relevance to the target variable, wrapper methods use the model performance as the criteria for selecting features, and embedded methods combine feature selection with the model training process.
Feature Extraction: Feature extraction involves creating new features by combining or transforming the original features. The goal is to create a set of features that captures the essence of the original data in a lower-dimensional space. There are several methods for feature extraction, including principal component analysis (PCA), linear discriminant analysis (LDA), and t-distributed stochastic neighbor embedding (t-SNE). PCA is a popular technique that projects the original features onto a lower-dimensional space while preserving as much of the variance as possible.
Principal component analysis, or PCA, is a statistical procedure that allows you to summarize the information content in large data tables by means of a smaller set of “summary indices” that can be more easily visualized and analyzed.
PCA is used to reduce higher dimension data to lower dimension without losing it essence. PCA can be calculated in following steps:

|

Reinforcement learning is a machine learning training method based on rewarding desired behaviors and/or punishing undesired ones. In general, a reinforcement learning agent is able to perceive and interpret its environment, take actions and learn through trial and error.
It reward is calculated as:
It state that future depends on current state .

In state action value function, represented by Q(s,a)
Q(s,a) = Return , If you

Bellman equation explain the return in two step first one is immediate reward and second one is reward from behaving optimally starting from state s.

Due randomness and uncertainity in enviroment it becomes diffcult for reinforcement learning so to avoid this we caluclate Expected return(i.e average return) in placce of return only .
It is calculated as : Q*(s, a) = E[R(s, a, s') + γ ∑ P(s'|s, a) max(Q*(s', a'))],
Discrete state spaces can often be represented using tabular methods, where the agent maintains a value function or a Q-table to learn and update action values for each state. On the other hand, dealing with continuous state spaces often requires function approximation techniques, such as using neural networks, to approximate the value function or policy. Continuous state spaces also pose challenges for exploration strategies, as the agent needs to explore a potentially infinite space effectively.
It also know as epsilorn greedy policy
When we have large number of training examples our iterative process like gradient descent and other iterative process on reinforcement learning like trainin neural network becomes slower so we divide main training examples to differen subsets called mini batches
Soft update in reinforcement learning refers to a technique used to refine the learning algorithm by updating the parameters of a target network gradually. This process involves interpolating between the parameters of the target network and the parameters of the online network.
Collaborative filtering recommender systems make recommendations based on the preferences or behavior of other similar users or items. In this book recommendation system I calculated similarity scores between two users to find the euclidean distance and recommendation was made on the basis on two nearer items and most of the collaborative recommender system work like this.

Started my project on California housing price and cleared my concepts on data pipeling, Batch learning and Online learning, perfomed the fetching and loading of data with EDA to gain some insight on data.
NOTE

Creating Training and test data with random sampling and stratification sampling

1.Random sampling 2.Systematic sampling 3.Stratified sampling


Here is code hope you gain some insight from it :



Text and categorical data can be handled by using ordinal encoder and One Hot encoding but incase of ordinal encoder it think data nearby data are more similar than far data which is not the case in Oceanproximity so we use onehot encoding.

📚Resources Hands-On Machine Learning with Scikit-Learn and TensorFlow
Never use fit() or fit_transform() for anything else than training set.

The transformation of numeric features into categorical features, using a set of thresholds, is called bucketing (or binning)





Classification implemetation codewhile using gradient descent all features most have same scale e.g use standardscaler or it will took very long time to converge. Batch gradient descent takes whole batch of training data at each steps so it is terribly slow during large datasets.To use stochastic gradient descent with linear regression we can use SGDRegressor.
Implementation of code









for soft voting we have to set hyperparameter as 'soft' and for svc you have to set probability hyperparameter to True.
Implementation of my learning is given below hope you get some insight from it.







I have already mentioned and studied about dimensionality reduction technique using pca today I am going to revised and implement it. Dimensionality reduction is process of reducing dimension of data without losing it essence and it is done to speed up training and somtime to reduce noise. Two methods of dimensionality reduction are projection and manifold learning.
It is the most popular technique for dimension reduction it reduce dimension by choosing hyperplane that is closest to the data by preserving variance.
You can find the number of components/features to use by setting ratio of variance to preserve ideally 95 % in parameter n_components. You can gain some insight form below code.







Attending the most important part of input. It captures long-range dependencies and allow parallelization.

CNN are deeplearning algorithm that takes images and videos as input and perfrom further analysis and processing on it trying to mimic human visual system.





continuity : points that are close in latent space are consider similar after decoding and completeness: sampling from latent space turn into meaningful content after decoding .









When we have symmetrical autoencoder we can tie the weights of decoder layer to encoder layers this halves the number of weights in the model speeding up training and limiting the overfitting.

** Denoising autoencoders : Autoencoder can simply be useful to recover noisy image or reconstruct full image by denoising.




📚Resources
Deep Learning Specialization








training-dev set which contains training data and dev data, training error and training-dev error will show variance situation which help to see variance problem and the gap between training-dev and dev/test set will show data mismatch situation .


convolution layer in such layer pooling layer is applied to reduce dimension this combination of convolution + pooling is taken as 1 layer and many such layer are obtained which generate a final convolution layer that is then flatten and provided to fully connected layer and at last require prediction is made.Zero padding and convolution single step

convolution forward prop

📚Resources Deep Learning Specialization


Seqeuntial API use to detect smily face:
Functional API use to detect sign language:







Let's breakdown the steps:
.png)
.png)
.png)
.png)
















Truncated — view the full README on GitHub.
692 commits
5 commits
Jupyter Notebook
99.8%
Hello everyone this repo will contain my journey of machine learning and DeepLearning with some exciting projects
Jupyter Notebook
74
697 commits
updated Apr 7, 2025

| Books and Resources | Status of Completion |
|---|---|
| 1. Machine Learning Specialization | ✅ |
| 2.Hands-On Machine Learning with Scikit-Learn and TensorFlow | ✅ |
| 3.Intro to DeepLearning | ✅ |
| 4.Deep Learning Specialization | ✅ |
| 5.LLM from Scratch | ✅ |
| 6.Hugging face Nlp course | ✅ |
| 7.LLM course | 🏊 |
| 8.Efficiently Serving LLMs | ✅ |
| 9.Langchain docs | ✅ |
| Days | Topics Covered | Resources |
|---|---|---|
| Day1 | Superviesed learning, regression, classification | Machine Learning Specialization |
| Day2 | Univariate Linear regression, Cost function | Machine Learning Specialization |
| Day3 | Gradient descent | Machine Learning Specialization |
| Day4 | Learning rate | Machine Learning Specialization |
| Day5 | Multiple linear regression, Vectorization | Machine Learning Specialization |
| Day6 | Feature scaling, Choosing correct learning rate | Machine Learning Specialization |
| Day7 | Feature engineering, Polynomial regression | Machine Learning Specialization |
| Day8 | Classification, Logistic regression | Machine Learning Specialization |
| Day9 | Sigmoid function, Decision boundary | Machine Learning Specialization |
| Day10 | Gradient descent in Logistic regression, Cost function in Logistic regression | Machine Learning Specialization |
| Day11 | Gradient descent in logistic regression Implementation | Machine Learning Specialization |
| Day12 | Underfitting,Overfitting, Addressing overfitting, Plotting overfitting,Regularization implementation | Machine Learning Specialization |
| Day13 | Neural Network Introduction , Why neural network? | Machine Learning Specialization |
| Day14 | Neural Network notation, forward propagation, Neuron Layer implementation | Machine Learning Specialization |
| Day15 | Neural network implementation for digit classification, Classification of AI | Machine Learning Specialization |
| Day16 | Vectorization in Neural Network , Neural network of Handwritten Binary Digit Classification | Machine Learning Specialization |
| Day17 | Model Training Steps, Activation Function , Implementation of ReLU | Machine Learning Specialization |
| Day18 | Multi Class classification, soft max regression, cost for softmax regression | Machine Learning Specialization |
| Day19 | Improved Implementation of softmax/logistic regression in neural network,multilabel classification, Advanced optimization, Additional layer types | Machine Learning Specialization |
| Day20 | BackpropagationImplementation of Backpropagation, Debugging a learning algorithm, Model selection and Machine learning diagnostic | Machine Learning Specialization |
| Day21 | Bias/Variance , choosing regularization parameter | Machine Learning Specialization |
| Day22 | Diagonising Bias and Variance ,Labs on Diagonising Bias and Variance , Choosing regularization parameter | Machine Learning Specialization |
| Day23 | Iterative loop of ML Development, Error analysis, Transfer Learning | Machine Learning Specialization |
| Day24 | Full cycle of Machine learning projects,Precison and Recall , Trading off precison and recall , Lab on Full Machine Learning Cycle | Machine Learning Specialization |
| Day25 | Decision Tree, Decision Tree Learning | Machine Learning Specialization |
| Day26 | Measuring Impurity, Information Gain, Decision Tree Learning, Recursive Splitting | Machine Learning Specialization |
| Day27 | One hot encoding, Splitting for continous variable, Regression Tree | Machine Learning Specialization |
| Day28 | Tree ensemble , Random Forest Algorithm, XG boost, when to use decision tree | Machine Learning Specialization |
| Day29 | Unsupervised Learning, K means clustering Algorithm, cost function for k means clustering,Labs on K means Clustering | Machine Learning Specialization |
| Day30 | Anamoly detection, Anamoly detection vs supervised Learning use case | Machine Learning Specialization |
| Day31 | Recommender system, Content based Recommendation, Collaborative Filtering Recommender Systems | Machine Learning Specialization |
| Day32 | Normalization, Limitation of Collaborative Filtering,Lab Collabrative filetering recommender system, Content base recommendation for large items | Machine Learning Specialization |
| Day33 | Tensorflow implementation of Collaborative Filtering,Dimensonality Reduction, PCA | Machine Learning Specialization |
| Day34 | Step by step calculation of PCA , Implementation of PCA, | Machine Learning Specialization |
| Day35 | Reinforcement Learning, Markov Decision Process | Machine Learning Specialization |
| Day36 | State Action Value Function, Bellman Function, Random stochastic environment,State Action value function Implementation | Machine Learning Specialization |
| Day37 | Discrete State and Continuous State, Refinement of reinforcement learning by minibatches and softupdate | Machine Learning Specialization |
| Day38 | Building a Book Recommender System using Collaborative Filtering | Machine Learning Specialization |
| Day39 | California Housing Price Prediction : Batch learning vs online learning, Cost for Linear regression (RMSE and MAE) usecase,fetching and loading of data with EDA | Hands-On Machine Learning with Scikit-Learn and TensorFlow |
| Day40 | California Housing Price Prediction (Continued) : Created test data , and splitted data on the basis of train-test-split and also with stratifcation split to remove imbalance in data and create same proportion. | Hands-On Machine Learning with Scikit-Learn and TensorFlow |
| Day41 | California Housing Price Prediction (Continued) : data visualization, EDA | Hands-On Machine Learning with Scikit-Learn and TensorFlow |
| Day42 | California Housing Price Prediction (Continued) : feature engineering, using simple imputer, handling categorical data by encoding | Hands-On Machine Learning with Scikit-Learn and TensorFlow |
| Day43 | California Housing Price Prediction (Continued) :Feature Scaling and Bucket Binning | Hands-On Machine Learning with Scikit-Learn and TensorFlow |
| Day44 | California Housing Price Prediction (Continued) : Data preprocessing pipeling development | Hands-On Machine Learning with Scikit-Learn and TensorFlow |
| Day45 | California Housing Price Prediction (Continued) : Selection, training and evaluation of model | Hands-On Machine Learning with Scikit-Learn and TensorFlow |
| Day46 | Binary Classification, measuring accuracy using Confusion matrix and ROC curve | Hands-On Machine Learning with Scikit-Learn and TensorFlow |
| Day47 | Multiclass classification, Multilablel classification, Multioutput classification Classification Implementation | Hands-On Machine Learning with Scikit-Learn and TensorFlow |
| Day48 | Linear Regression, Gradient descent, Stochastic Gradient descent and SGD regressor, Implementation | Hands-On Machine Learning with Scikit-Learn and TensorFlow |
| Day49 | Polynomial Regression, Learning curve, overfitting , underfitting and its solution | Hands-On Machine Learning with Scikit-Learn and TensorFlow |
| Day50 | Ridge Regression and its Implementation with SGD Regressor | Hands-On Machine Learning with Scikit-Learn and TensorFlow |
| Day51 | Lasso Regression, elastic net regression and early stopping | Hands-On Machine Learning with Scikit-Learn and TensorFlow |
| Day52 | Revision on logistic regression and softmax regression, logloss, Implementing logistic regression | Hands-On Machine Learning with Scikit-Learn and TensorFlow |
| Day53 | SVM, kernel function and kernel trick | Hands-On Machine Learning with Scikit-Learn and TensorFlow |
| Day54 | Polynomial kernel and RBF kernel | Hands-On Machine Learning with Scikit-Learn and TensorFlow |
| Day55 | Support Vector Machine and It classes | Hands-On Machine Learning with Scikit-Learn and TensorFlow |
| Day56 | Decision Tree and regularization in decision tree and its implementation | Hands-On Machine Learning with Scikit-Learn and TensorFlow |
| Day57 | Decision Tree for regression , hyperparameter tuning and its implementation. | Hands-On Machine Learning with Scikit-Learn and TensorFlow |
| Day58 | Ensemble Learning and Voting classifier | Hands-On Machine Learning with Scikit-Learn and TensorFlow |
| Day59 | Bootstrap Aggregation | Hands-On Machine Learning with Scikit-Learn and TensorFlow |
| Day60 | Random patches and random subspaces | Hands-On Machine Learning with Scikit-Learn and TensorFlow |
| Day61 | Random Forest | Hands-On Machine Learning with Scikit-Learn and TensorFlow |
| Day62 | Boosting | Hands-On Machine Learning with Scikit-Learn and TensorFlow |
| Day63 | History based gradient boosting and stacking | Hands-On Machine Learning with Scikit-Learn and TensorFlow |
| Day64 | Dimensionality Reduction and PCA | Hands-On Machine Learning with Scikit-Learn and TensorFlow |
| Day65 | Local Linear embeddings and K means | Hands-On Machine Learning with Scikit-Learn and TensorFlow |
| Day66 | Supervised Learning in Neural Network | Deep Learning Specialization |
| Day67 | Image Classifier using sequential API | Hands-On Machine Learning with Scikit-Learn and TensorFlow |
| Day68 | Vectorization and Broadcasting in python | Hands-On Machine Learning with Scikit-Learn and TensorFlow |
| Day69 | Deep Learning Api to create complex model | Hands-On Machine Learning with Scikit-Learn and TensorFlow |
| Day70 | Perceptron as a binary classifier | Deep Learning Specialization |
| Day71 | Perceptron trick , Loss function in perceptron, Gradient descent, Backpropagation, Batching and regularization, | Hands-On Machine Learning with Scikit-Learn and TensorFlow |
| Day72 | RNNS, Encoding, Embeddings, Implementing simple RNN | Introduction to Deeplearning |
| Day73 | Backpropagation through time, Gradient issues | Introduction to Deeplearning |
| Day74 | LSTM, self attention | Introduction to Deeplearning) |
| Day75 | Convolution Neural Network(CNN) | Introduction to Deeplearning) |
| Day76 | Convolution Neural Network(CNN) Implementation and deeper understanding | Introduction to Deeplearning) |
| Day77 | Steps of CNN and deeper intuition | Introduction to Deeplearning) |
| Day78 | R-CNN | Introduction to Deeplearning) |
| Day79 | Bird species classification using CNN | Introduction to Deeplearning) |
| Day80 | Generative Modeling, Auto encoder and Variational Auto encoders | Introduction to Deeplearning) |
| Day81 | prior on latent distribution , Regualrization and normal prior , Reparametrization, Latent peturbation and entanglement | Introduction to Deeplearning) |
| Day82 | Generative Adversarial Networsk (GANS) | Introduction to Deeplearning) |
| Day83 | Challenges for robust deep learning, algorithmic bias,Class Imbalance, Class Imbalance solution | Introduction to Deeplearning) |
| Day84 | Debiasing VAES and uncertainity | Introduction to Deeplearning) |
| Day85 | Auto encoders | Introduction to Deeplearning) |
| Day86 | Unsupervised retraining using stacked autoencoders and Tying Weights | Introduction to Deeplearning) |
| Day87 | Training autoencoders at a time,convolutional autoencoders, denoising autoencoder | Hands-On Machine Learning with Scikit-Learn and TensorFlow |
| Day88 | Sparsity autoencoders | Hands-On Machine Learning with Scikit-Learn and TensorFlow |
| Day89 | variable autoencoders and its implementation | Hands-On Machine Learning with Scikit-Learn and TensorFlow |
| Day90 | GAN implementation | Hands-On Machine Learning with Scikit-Learn and TensorFlow |
| Day91 | sigmoid function,sigmoid derivative, image to vector conversion, normalizing rows, softmax function, vectorization, L1 loss, L2 loss | Deep Learning Specialization |
| Day92 | shallow neural network and implemented logistic regression on neural network | Deep Learning Specialization |
| Day93 | Optimization ,EWMA | Deep Learning Specialization |
| Day94 | SGD momentum,Nesterov Accelerated Gradient (NAG),Adaptive Gradient(ADaGrad) | Deep Learning Specialization |
| Day95 | Adam optimizer,RMSProp optimizer | Deep Learning Specialization |
| Day96 | Regularization of neural network ,L1 and L2 regularization , Dropout regularzation, data augementation , early stopping for reducing overfitting and orthogonalization | Deep Learning Specialization |
| Day97 | Normalizing input features to make gradinet descent faster , Vanishing and exploding of gradients, Checking of gradient descent | Deep Learning Specialization |
| Days | Topics Covered | Resources |
|---|---|---|
| Day211 | Multiagent soft start | Agent Course) |
Learns from being given right answers.
Supervised machine learning is based on the basis of labeled data.First the data is fed to the model with both input and output and later on test data is given to make prediction by model.
some algorithm used in supervised learning with their uses are :
Learns by finding pattern in unlabelled data.
Unsupervised learning is different from supervised learning as it is not provided with labelled data.The algorithm work by finding pattern in data.
some algorithm used in unsupevised learning with it uses are:
Univariate linear regression has one dependent variable and one independent variable. With the help of indendent variable also known as input,feature we predict the output. Firstly we provide training set to our model and later on we predict the output using training set.
A cost function is a measure of how well a machine learning model performs by quantifying the difference between predicted and actual outputs.
lower the value of cost function better the model


Gradient descent is an algorithm for finding values of parameters w and b that minimize the cost function J.It is made cleared in below image.

Learning rate alpha in gradient descent should be optimal.
If learning rate is too small gradient descent may be too slow and take much time.
If learning rate is too large gradient descent may overshoot and never reach minimum i.e fail to converge,diverge.

📚Resources
course:Machine Learning Specialization
Multiple linear regression in machine learning model that uses multiple variables called as features to predicts the output.

In muliple linear regression calculation is done using vectorization as it perform all calculation simultaneously and parallely and speed up the arithmetic operations.

When you data features has very large range,too small range gradient descent may take large time so data is rescaled to normal similar range called feature scaling. some popular feature scaling techniques are:


First we make sure gradient descent is decreasing over the iteration by looking at learning curve if it is working properly we choose correct learning rate by starting with smaller learning rate and increase it gradually.
Feature engineering means designing newfeatures by transforming or combining original features which maybe very important in prediciting the output.
for e.g: we have to predict the price of swimming pool and we have length breadth and height of swimming pool as features now we can used feature engineering to create our new feature which is volume which is very important in predicting the price of swimming pool.
Polynomial Regression is a regression algorithm that models the relationship between a dependent(y) and independent variable(x) as nth degree polynomial. The Polynomial Regression equation is given below:
y= b0+b1x1+ b2x12+ b2x13+...... bnx1n
It is used incase of non linear dataset.

Classification is a type of supervised learning in machine learning, where the goal is to predict the class label of an input data point.For example, we may want to classify emails as spam or not spam, or classify images as cats or dogs.
Logistic regression is a type of algorithm used for classification problems. It works by estimating the probability of an input data point belonging to a particular class. For example, it may estimate the probability that an email is spam or not spam, or the probability that an image is a cat or a dog.
To estimate these probabilities, logistic regression uses a mathematical function called the logistic function, which maps the input data to the probability space. The logistic regression algorithm then learns the relationships between the input features and the target class by adjusting weights, or coefficients, assigned to each input feature. These weights are adjusted to maximize the probability of the correct classification.
In the end, logistic regression outputs the predicted class for each input data point, based on the estimated probabilities. This can be useful for a wide range of classification tasks, from predicting diseases to detecting fraud.

The sigmoid function is a mathematical function that maps any input value to a value between 0 and 1. It is commonly used in logistic regression to model the probability of a binary outcome. The sigmoid function has an S-shaped curve and is defined as follows:
σ(z) = 1 / (1 + e^(-z))
where z is the input value to the function. The output of the sigmoid function, σ(z), is a value between 0 and 1, with a midpoint at z=0.
The sigmoid function has several important properties that make it useful in logistic regression. First, it is always positive and ranges between 0 and 1, which makes it suitable for modeling probabilities. Second, it is differentiable, which means that it can be used in optimization algorithms such as gradient descent. Finally, it has a simple derivative that can be expressed in terms of the function itself:
d/dz σ(z) = σ(z) * (1 - σ(z))
This derivative is used in logistic regression to update the model coefficients during the optimization process.
The decision boundary is the line that separates the area where y=0 and where y=1.It is create by our hypothesis function.
In logistic regression, the decision boundary is the line (or hyperplane in higher dimensions) that separates the different classes of the target variable. The decision boundary is determined by the logistic regression model, which uses the input variables to predict the probability of belonging to a certain class.

Logistic Regression Ŷi is a nonlinear function(Ŷ=1/1+ e-z), if we put this in the above MSE equation it will give a non-convex function as shown:

When we try to optimize values using gradient descent it will create complications to find global minima.
Another reason is in classification problems, we have target values like 0/1, So (Ŷ-Y)2 will always be in between 0-1 which can make it very difficult to keep track of the errors and it is difficult to store high precision floating numbers.
The cost function used in Logistic Regression is Log Loss.

Cost function for logistic regression

Gradient Descent in Logistic Regression is an iterative optimisation algorithm used to find the local minimum of a function. It works by tweaking parameters w and b iteratively to minimize a cost function by taking steps proportional to the negative of the gradient at the current point.
Gradient descent in logistic regression looks similar to gradient descent in linear regression but it has different value for function.

It is a situtation when the training set doesnot fit well. It happen when data has high bias.
It is a situation when the training set fit extremely well . It is also known as data with high variance.
Regularization is a technique to reduce the parameter and prevent overfitting of data. It has a term called lambda whose value if larger result underfitting and smaller result overfitting it also called penalty term.

Neural network is an computer algorithms that try to mimic the brain.neural network is made of a input layer that take input data and hidden layer does all the computation and output layer displays the output.
Why neural network ?
Neural network is necessary because it increase performance of machine learning algorithm compared to traditional algorithm like linear regression and logistic regression because it uses multiple and more algorithm in a neural network to make better prediction and performances.

In neural network.
Forward propagation refers to storage and calculation of input data which is fed in forward direction through the network to generate an output. Hidden layers in neural network accepts the data from the input layer, process it on the basis of activation function and pass it to the output layer or the successive layers. Data flows in forward direction so as to avoid circular shape flow of data which will not generate an output. The network configuration that helps in forward propagation is known as feed-forward network.
📚Resources
course:Machine Learning Specialization
Neural network can be easily implemented in tensorflow as below:
AI is mainly classified into two type: ANI and AGI
AGI:An AGI is a hypothetical intelligent agent that can learn to accomplish any intellectual task that human beings or other animals can perform. It is defined as an autonomous system that surpasses human capabilities in the majority of economically valuable tasks
📚Resources
course:Machine Learning Specialization
In neural network vectorization helps to perform calculation simultaneously and save a lot of time. It can implemented as :



Model training is simplified in 3 steps :
There are different activation function for different purpose some of the most commonly used are :
For hidden layer we choose ReLU as activation and for output layer we choose activation according to our problems,because if we choose sigmoid in hidden layer than neural network becomes very slow so it better to choose Relu in hidden layer
Target y can take on more than two possible values. In this case of multiclass classification we use Softmax regression.
Softmax regression is the generalization of logistic regression for multiple classs.
Its output is calculated as:

Cost for softmax regression is also known as cross-entropy loss. It is obtained as.

Our normal implementation of softmax cause some of numerical roundoff error so for the more numerical accurate implementation of softmax regression we use linear activation in output layer and passing from_logits = True as parameter in loss at model.compile().
You can get more insight by looking at image below:

Multilabel classification is a type of classification problem in machine learning where each instance can be assigned to multiple classes or labels simultaneously. In other words, instead of predicting a single class for an instance, the goal is to predict a set of labels that are applicable to that instance.
Here is difference between multiclass and multilable classfication

Adam algorithm is used for advanced optimization in neural network.
model.compile( optimizer=tf.keras.optimizers.Adam(learning_rate=1e-3), loss = tf.kearas.losses.SparseCategoricalCrossentropy(from_logits=True))
Some of layer types of neural network are :
Dense Layer (Fully Connected Layer): A dense layer is a basic layer where each neuron is connected to every neuron in the previous layer. It is characterized by its weight matrix, bias vector, and activation function. Dense layers are commonly used in feedforward neural networks and can learn complex patterns and relationships in the data.
Convolutional Layer: Convolutional layers are primarily used in convolutional neural networks (CNNs) for analyzing grid-like data, such as images. These layers perform convolutions, applying filters to the input data, and capturing local patterns and features. Convolutional layers are effective in image recognition, object detection, and other computer vision tasks.
Convaulational neural network are faster in computation and need less training data as compared to Dense Layer.
📚Resources
course:Machine Learning Specialization
Backpropagation, or backward propagation of errors, is an algorithm used in machine learning to adjust the parameters of a neural network by calculating the gradients of a loss function with respect to the network's weights and biases. It propagates the error from the output layer to the input layer, allowing the network to learn and improve its predictions.
When we have large error in prediction we can debugg or learning algorithm as follow:
You can evaluate a model by splitting data into trian/test and calculating cost for both training set and test set .
The most effective way of model selection is by
A test that you can run to gain insight into what is/isn't working with a learning algorithm to gain guidance into improving its performance .
Ml model can be diagonse by looking at bias and variance:
When model has high bias and variance it is not doing well.


To choose good regularization paramter.

Ml development revolve around following steps:

It is the process to isolate,observe and diagnose erroneous ML predictions to understand pockets of high and low performance to the model.
Adding more data is mostly useful to make better predictions and data can be added by following ways:
Transfer learning is a machine learning method where a model developed for a task is reused as the starting point for a model on a second task.
It is a popular approach in deep learning where pre-trained models are used as the starting point on computer vision and natural language processing tasks given the vast compute and time resources required to develop neural network models on these problems and from the huge jumps in skill that they provide on related problems.
Machine learning project is iterative process which is as below:

Mlops focuses on making ml model to be used in largescale and deployment is basically done by:

While developing machine learning application we have to take care of biasness and negative case like :
1.Deepfake
2.Genrating fake content for commercial and political purposes
3.Ml model biasing in loan provider,job selection.

F1 score which is the harmonic mean of precision and recall.A decision tree is a type of supervised machine learning used to categorize or make predictions based on how a previous set of questions were answered. The model is a form of supervised learning, meaning that the model is trained and tested on a set of data that contains the desired categorization.

In decision tree entropy is the measure of level of impurity and helps to find purity of classes. lower impurity means higher purity.

We can calculate the information gain by subtracting the weighted average entropy of the resulting subsets from the entropy of the original node. The formula for information gain is:
Information Gain = Entropy(node) - Σ((subset_size/total_size) * Entropy(subset))

Recursive splitting refers to the iterative process in decision tree construction where a dataset is divided into smaller subsets based on specific conditions. It involves recursively selecting attributes to split on and creating branches that further partition the data until a stopping criterion is met, resulting in a tree-like structure.
If a categorical features can take on k values, create k binary features(0 or 1 values) is call one hot encoding.
For continuous variable we have to choose threshold with higher information gain and split on the basis of that threshold.
It is a decision based tree used to predict continous variables.
Single decision tree is very sensitive to data so the process of combining many decision tree to build more robust system is called tree ensemble. the prediciton of tree ensemble is obtained by majority result of tree.
A random forest algorithm is a machine learning technique that combines the predictions of multiple decision trees to make more accurate and robust predictions. It works by creating an ensemble of decision trees, where each tree is trained on a random subset of the data and uses a random subset of features. The final prediction is then made by averaging or voting the predictions of all the trees in the forest. The random forest algorithm is effective at handling complex datasets, handling missing values, and avoiding overfitting.

In XG boost we basically pick the training examples that were misclassified previously instead of training all samples.
It is implemented as :

Machine leanring algorithm that find patterns on unlabelled data.
K-means clustering is an unsupervised machine learning algorithm used for partitioning a dataset into K distinct non-overlapping clusters. Each data point in the dataset is assigned to the cluster with the nearest mean (centroid). The algorithm aims to minimize the within-cluster variance, also known as the "inertia."
Here's a step-by-step overview of the k-means clustering algorithm:
Initialization: Randomly select K data points from the dataset as the initial cluster centroids.
Assignment: Assign each data point to the nearest centroid. This is done by calculating the Euclidean distance (or other distance metrics) between each data point and each centroid, and assigning the data point to the cluster with the closest centroid.
Update: Recalculate the centroids of each cluster by taking the mean of all the data points assigned to that cluster.
Repeat: Repeat steps 2 and 3 until convergence or a maximum number of iterations is reached. Convergence occurs when the centroids no longer move significantly between iterations or when the algorithm reaches the predefined maximum number of iterations.
Final Clusters: Once convergence is achieved, the algorithm outputs the final cluster assignments, where each data point belongs to one of the K clusters.

The cost function for k-means clustering is commonly referred to as the "inertia" or "within-cluster sum of squares." It measures the sum of squared distances between each data point and its assigned centroid within each cluster. The goal of k-means clustering is to minimize this cost function.
Mathematically, the cost function (J) for k-means clustering can be defined as:
J = Σᵢ Σⱼ ||xᵢ - μⱼ||²
Anomaly Detection is the technique of identifying rare events or observations which can raise suspicions by being statistically different from the rest of the observations. Such “anomalous” behaviour typically translates to some kind of a problem like a credit card fraud, failing machine in a server, a cyber attack, etc.
We will use anamoly detection when there are very small number of example that are positive(anamoly) and large number of negative example .Since small number of positive examples it is hard to learn from training examples.e.g: fraud detection
We will use supervised learning when large number of positive and negative examples are present. Since there are enough positive examples to train model and predict supervised learning is effective. e.g Email spam detection
Recommender systems are a type of machine learning algorithm used to suggest items to users based on their preferences or behavior. These systems are widely used in various applications like e-commerce, movie streaming platforms, music apps, and more.
In content-based recommender systems, the algorithm recommends items based on the similarity between the content/features of the items and the user's preferences. The similarity is typically computed using techniques such as cosine similarity or Euclidean distance. Here's an overview of the mathematical steps involved:
a. Feature Representation: Each item and user is represented as a feature vector. Let's denote an item's feature vector as x and a user's preference vector as p. These vectors consist of numerical values that represent the attributes or characteristics of items or users.
b. Similarity Measure: The similarity between two feature vectors, x and p, can be computed using cosine similarity. The cosine similarity between x and p is defined as:
similarity(x, p) = (x · p) / (||x|| * ||p||)
where (x · p) represents the dot product of vectors x and p, and ||x|| and ||p|| denote their respective Euclidean norms.
Collaborative filtering recommender systems make recommendations based on the preferences or behavior of other similar users or items. Let's explore the two main approaches: user-based and item-based collaborative filtering.
In user-based collaborative filtering, the algorithm finds similar users based on their past interactions or ratings and recommends items that the similar users have liked. Here are the mathematical steps involved:
i. User Similarity: The similarity between two users, u and v, can be computed using techniques such as cosine similarity or Pearson correlation. The similarity score measures the likeness of their past interactions.
ii. Prediction: To predict a user's preference for a particular item, the system combines the ratings of similar users. The predicted rating, denoted as r_hat(u, i), for user u and item i is calculated as a weighted average of the ratings of similar users:
r_hat(u, i) = ∑ (sim(u, v) * r(v, i)) / ∑ |sim(u, v)|
#where sim(u, v) represents the similarity between users u and v, r(v, i) denotes the rating of user v for item i, and the summation is performed # over all similar users v.
where sim(u, v) represents the similarity between users u and v, r(v, i) denotes the rating of user v for item i, and the summation is performed over all similar users v. iii. Recommendation: The system recommends items with the highest predicted ratings to the active user.
In item-based collaborative filtering, the algorithm identifies similar items based on the past interactions or ratings of users. It then recommends items that are similar to the ones the user has already liked. Here's a summary of the mathematical steps involved:
i. Item Similarity: The similarity between two items, i and j, can be computed using techniques such as cosine similarity or Pearson correlation. The similarity score measures the likeness of user preferences for the items.
ii. Prediction: To predict a user's preference for a particular item, the system considers the user's past ratings for similar items. The predicted rating, denoted as r_hat(u, i), for user u and item i is calculated as a weighted average of the user's ratings for similar items:
r_hat(u, i) = ∑ (sim(i, j) * r(u, j)) / ∑ |sim(i, j)|
#where sim(i, j) represents the similarity between items i and j, r(u,
Normalization is a technique often applied as part of data preparation for machine learning. The goal of normalization is to change the values of numeric columns in the dataset to use a common scale, without distorting differences in the ranges of values or losing information.
How to
It uses both content and user data and using neural network create vector for content and vector for user and its dot product give prediction.
When our website or app has large number of content to recommend like thousands and millon of item it is carried out in two steps:
From large number of content retrival is carried out for selective content for further ranking. for e.g:
For movies recommendation:
1.for 10 movies watched by user retrieve similar movies.
2.for most viewed 3 genres find top 10 movies.
3.find top 20 movies in country.
At last combined retrived item in list and remove duplicated and items already purchased.
Apply model to retrived data to find suitable item and display ranked item to user.
Note: Retriving more items result in better recommendation but takes more time to analyse try it offline and find suitable number of retrival for better and relevant recommendations.
Dimensionality reduction is a technique used to reduce the number of features in a dataset while retaining as much of the important information as possible. In other words, it is a process of transforming high-dimensional data into a lower-dimensional space that still preserves the essence of the original data
Feature selection : Feature selection involves selecting a subset of the original features that are most relevant to the problem at hand. The goal is to reduce the dimensionality of the dataset while retaining the most important features. There are several methods for feature selection, including filter methods, wrapper methods, and embedded methods. Filter methods rank the features based on their relevance to the target variable, wrapper methods use the model performance as the criteria for selecting features, and embedded methods combine feature selection with the model training process.
Feature Extraction: Feature extraction involves creating new features by combining or transforming the original features. The goal is to create a set of features that captures the essence of the original data in a lower-dimensional space. There are several methods for feature extraction, including principal component analysis (PCA), linear discriminant analysis (LDA), and t-distributed stochastic neighbor embedding (t-SNE). PCA is a popular technique that projects the original features onto a lower-dimensional space while preserving as much of the variance as possible.
Principal component analysis, or PCA, is a statistical procedure that allows you to summarize the information content in large data tables by means of a smaller set of “summary indices” that can be more easily visualized and analyzed.
PCA is used to reduce higher dimension data to lower dimension without losing it essence. PCA can be calculated in following steps:

|

Reinforcement learning is a machine learning training method based on rewarding desired behaviors and/or punishing undesired ones. In general, a reinforcement learning agent is able to perceive and interpret its environment, take actions and learn through trial and error.
It reward is calculated as:
It state that future depends on current state .

In state action value function, represented by Q(s,a)
Q(s,a) = Return , If you

Bellman equation explain the return in two step first one is immediate reward and second one is reward from behaving optimally starting from state s.

Due randomness and uncertainity in enviroment it becomes diffcult for reinforcement learning so to avoid this we caluclate Expected return(i.e average return) in placce of return only .
It is calculated as : Q*(s, a) = E[R(s, a, s') + γ ∑ P(s'|s, a) max(Q*(s', a'))],
Discrete state spaces can often be represented using tabular methods, where the agent maintains a value function or a Q-table to learn and update action values for each state. On the other hand, dealing with continuous state spaces often requires function approximation techniques, such as using neural networks, to approximate the value function or policy. Continuous state spaces also pose challenges for exploration strategies, as the agent needs to explore a potentially infinite space effectively.
It also know as epsilorn greedy policy
When we have large number of training examples our iterative process like gradient descent and other iterative process on reinforcement learning like trainin neural network becomes slower so we divide main training examples to differen subsets called mini batches
Soft update in reinforcement learning refers to a technique used to refine the learning algorithm by updating the parameters of a target network gradually. This process involves interpolating between the parameters of the target network and the parameters of the online network.
Collaborative filtering recommender systems make recommendations based on the preferences or behavior of other similar users or items. In this book recommendation system I calculated similarity scores between two users to find the euclidean distance and recommendation was made on the basis on two nearer items and most of the collaborative recommender system work like this.

Started my project on California housing price and cleared my concepts on data pipeling, Batch learning and Online learning, perfomed the fetching and loading of data with EDA to gain some insight on data.
NOTE

Creating Training and test data with random sampling and stratification sampling

1.Random sampling 2.Systematic sampling 3.Stratified sampling


Here is code hope you gain some insight from it :



Text and categorical data can be handled by using ordinal encoder and One Hot encoding but incase of ordinal encoder it think data nearby data are more similar than far data which is not the case in Oceanproximity so we use onehot encoding.

📚Resources Hands-On Machine Learning with Scikit-Learn and TensorFlow
Never use fit() or fit_transform() for anything else than training set.

The transformation of numeric features into categorical features, using a set of thresholds, is called bucketing (or binning)





Classification implemetation codewhile using gradient descent all features most have same scale e.g use standardscaler or it will took very long time to converge. Batch gradient descent takes whole batch of training data at each steps so it is terribly slow during large datasets.To use stochastic gradient descent with linear regression we can use SGDRegressor.
Implementation of code









for soft voting we have to set hyperparameter as 'soft' and for svc you have to set probability hyperparameter to True.
Implementation of my learning is given below hope you get some insight from it.







I have already mentioned and studied about dimensionality reduction technique using pca today I am going to revised and implement it. Dimensionality reduction is process of reducing dimension of data without losing it essence and it is done to speed up training and somtime to reduce noise. Two methods of dimensionality reduction are projection and manifold learning.
It is the most popular technique for dimension reduction it reduce dimension by choosing hyperplane that is closest to the data by preserving variance.
You can find the number of components/features to use by setting ratio of variance to preserve ideally 95 % in parameter n_components. You can gain some insight form below code.







Attending the most important part of input. It captures long-range dependencies and allow parallelization.

CNN are deeplearning algorithm that takes images and videos as input and perfrom further analysis and processing on it trying to mimic human visual system.





continuity : points that are close in latent space are consider similar after decoding and completeness: sampling from latent space turn into meaningful content after decoding .









When we have symmetrical autoencoder we can tie the weights of decoder layer to encoder layers this halves the number of weights in the model speeding up training and limiting the overfitting.

** Denoising autoencoders : Autoencoder can simply be useful to recover noisy image or reconstruct full image by denoising.




📚Resources
Deep Learning Specialization








training-dev set which contains training data and dev data, training error and training-dev error will show variance situation which help to see variance problem and the gap between training-dev and dev/test set will show data mismatch situation .


convolution layer in such layer pooling layer is applied to reduce dimension this combination of convolution + pooling is taken as 1 layer and many such layer are obtained which generate a final convolution layer that is then flatten and provided to fully connected layer and at last require prediction is made.Zero padding and convolution single step

convolution forward prop

📚Resources Deep Learning Specialization


Seqeuntial API use to detect smily face:
Functional API use to detect sign language:







Let's breakdown the steps:
.png)
.png)
.png)
.png)
















Truncated — view the full README on GitHub.
692 commits
5 commits
Jupyter Notebook
99.8%