Docsity

Machine learning intro basics, Lecture notes of Mathematics

Partial preview of the text

Download Machine learning intro basics and more Lecture notes Mathematics in PDF only on Docsity!

Machine Learning

Based on the Machine Learning Specialization by Andrew Ng

Lecture 1: Introduction to Machine Learning

Instructor : Dr Nausheen Saba Shahid

Learning Outcomes By the end of this lecture, students should be able to:

  • Define machine learning and explain how it differs from traditional programming.
  • Identify supervised, unsupervised, and reinforcement learning.
  • Explain the role of a training set, features, labels, and a model.
  • Recognize common machine-learning applications and problem types.
  • Describe a basic machine-learning workflow from data to deployment.

Traditional Programming vs Machine Learning Two ways to build a solution

  • Traditional programming: Rules + Data → Output.
  • Machine learning: Data + Desired outputs/examples → Learned rules/model.
  • Traditional approach is effective when rules are clear and stable.
  • ML is especially useful when the rules are complex, difficult to specify, or change with data.
  • Important: ML still requires human decisions about data, objectives, features, evaluation, and deployment.

Regression Example Predicting a numerical value

  • Suppose x = house size in square feet and y = selling price.
  • Training examples: (x¹,y¹), (x²,y²), …, (xᵐ,yᵐ).
  • Linear regression may learn: ŷ = wx + b.
  • w and b are parameters learned from the training data.
  • Prediction for a new house: plug its size into the learned function.
  • More realistic models can use multiple features: size, bedrooms, location, age, etc.

Classification Example Predicting a category

  • Email classification: x = email content/features; y ∈ {spam, not spam}.
  • Medical screening: x = patient/test information; y = diagnostic category.
  • Image classification: x = pixels; y = object class.
  • Binary classification has two classes; multiclass classification has more than two.
  • Modern classifiers can learn highly nonlinear decision boundaries.

Clustering Example Customer segmentation

  • Input: customer attributes such as spending, visit frequency, and product preferences.
  • No predefined customer-group labels are supplied.
  • K-means clustering can discover groups by repeatedly assigning points to clusters and updating cluster centroids.
  • Possible result: budget shoppers, frequent high-value shoppers, occasional shoppers.
  • Clusters are useful only when they are meaningful for the application.

Anomaly Detection Finding unusual behavior

  • Learn what normal data looks like.
  • Assign a score representing how unusual a new example is.
  • Flag examples whose score exceeds a selected threshold.
  • Applications: fraud detection, manufacturing defects, network intrusion detection, unusual equipment behavior.
  • Evaluation becomes challenging when anomalies are rare and labels are limited.

Reinforcement Learning Learning through interaction

  • An agent interacts with an environment.
  • At each step it observes a state, selects an action, and receives a reward.
  • The objective is to learn a policy that maximizes expected cumulative reward.
  • Applications: robotics, games, control, recommendation, resource allocation.
  • Unlike supervised learning, correct action labels are generally not supplied for every state.

AI, Machine Learning, and Deep Learning How the terms relate

  • Artificial Intelligence (AI): broad field of building systems that perform tasks associated with intelligence.
  • Machine Learning (ML): approaches that learn from data.
  • Deep Learning (DL): ML based primarily on multilayer neural networks.
  • Generative AI: models that generate text, images, audio, code, or other content.
  • These categories overlap; they are not interchangeable terms.

Training Set, Validation Set, Test Set Why separate datasets?

  • Training set: used to learn model parameters.
  • Validation/development set: used to choose models, features, and hyperparameters.
  • Test set: final unbiased estimate of performance after decisions are made.
  • Do not repeatedly tune to the test set; doing so can make test performance overly optimistic.
  • Data leakage occurs when information unavailable at prediction time enters training or evaluation.

Model and Parameters What does a model learn?

  • A model is a mathematical/computational function used to make predictions.
  • Parameters are values learned from training data.
  • Example: linear regression ŷ = wx + b has parameters w and b.
  • Hyperparameters are configuration choices set outside the parameter-learning process.
  • Examples: learning rate, regularization strength, tree depth, number of neural-network layers.

Gradient Descent A central optimization idea

  • Gradient descent iteratively changes parameters to reduce the cost function.
  • Update rule: θ := θ − α ∇J(θ).
  • θ represents model parameters; α is the learning rate; J is the cost.
  • The gradient indicates the direction of greatest increase, so we move in the opposite direction.
  • Variants include batch, stochastic, and mini-batch gradient descent.

Overfitting and Underfitting Generalization matters

  • Underfitting: model is too simple to capture important patterns; training error is often high.
  • Overfitting: model fits training data too closely, including noise; performance on new data is poor.
  • Good generalization means performing well on unseen examples from the target distribution.
  • Common remedies for overfitting: more data, regularization, simpler models, data augmentation, early stopping.
  • Always evaluate using an appropriate validation/test strategy.