Start with a prediction and a cost function. The goal is to connect the error we measure to the parameters we can change. Cost functions We call a cost function 'cost' because the model weights are costing us this much error Learning a regression model — illustration Learning a regression model — illustration using different cost functions models cost graph differently allowing us to optimize better Squared error and absolute error When using squared error, the outliers results in more taller bumps in cost function graph which results is faster convergence Absolute mean square error partial derivate: Learning a regression model — illustration Gradient descent visualization Learning a regression model — illustration Linear regression weight update equation: Multiple features and gradient descent — illustration Multiple features and gradient descent — illustration Multiple features and gradient descent — illustration Multiple-feature gradient descent Multiple features and gradient descent — illustration Normal equation The normal equation is an alternative technique to gradient descent for linear regression. It provides a closed-form solution for the weights (w) and bias (b) without iterations. computationally expensive when the number of features is large (> 10,000). Normal equation uses analytical approach when solving linear regression problems Whereas gradient descent is a numerical approach Feature scaling techniques Relative maximum scaling each feature divided by maximum value, so maximum value becomes 1 Multiple features and gradient descent — illustration Mean Normalization features are centered around zero. Results in values between -1 and 1 after normalization, values of features will be scaled down and centered around zero Z-score Normalization uses mean and std both. Transforms data into standard normal distribution where mean is 0 and std is 1 useful when features have different variances Learning a regression model — illustration How to test if your model has converged? Use learning curve graph Use automatic convergence test let epsilon be 10^-3 if J <= epsilon declare convergence Classification changes the prediction we want to make. The discussion moves from fitting values to estimating class probabilities and controlling overfitting. Why logistic regression is a classifier Regression: act of going back to previous state We are still modelling relationship between independent and dependent variables, instead of predicting continuous outcome, we are predicting probability of binary outcome Classification and regularization — illustration Classification and regularization — illustration Classification and regularization — illustration If we choose different z, we can map complex decision boundries Classification and regularization — illustration Classification and regularization — illustration Logistic loss Squared error function give non convex cost function Classification and regularization — illustration Tou we use Logistic loss function: Classification and regularization — illustration Cost function is average loss of all training examples Classification and regularization — illustration We can simplify above stepwise function into this: Classification and regularization — illustration Classification and regularization — illustration Therefore cost function looks like this: Classification and regularization — illustration Classification and regularization — illustration Bias and variance Variance: how much models predictions vary when its trained on different subsets training data, measure of spread around mean of data. Its the error introduced because model is too sensitive to fluctuations in training data, high variance can lead to overfitting Bias: error introduced by approximating real-world problem. High bias can lead to underfitting, where model doesn’t captures the underlying patterns of data well Goal is to find balance between bias and variance Highly biased ML model makes wrong assumptions leading to underfitting of training data If our ML model has high bias, it might make overly simplistic assumptions such as: All emails with word 'free' are spam All emails from unknown senders are spam All emails with attachments are not spam Model is biased towards specific features/patterns in data and makes predictions solely on those biases, rather than accurately capturing true relationship between features and target variable Classification and regularization — illustration Model with low bias is not biased towards overly simplistic assumptions. A very low bias can introduce overfitting When we say ML model has high variance(overfitting), it means model's predictions vary significantly with different training datasets When training a ML model, we use specific dataset to make predictions. If we train same ML model multiple times using different subsets of avaliable training data, we might obtain different versions of model each time Model with high variance exhibits significant…