Introduction to Machine Learning, ML Workflow & Problem Formulation

Comprehensive foundation covering classical rules vs pattern learning, real-life analogies, ML types, Amazon enterprise use cases, problem formulation & feature space.

What is Machine Learning?

Machine Learning (ML) is a branch of Artificial Intelligence (AI) where computers learn patterns from data instead of being explicitly programmed with rules.

Instead of writing every rule manually, we provide examples (data), and the computer learns how to make predictions or decisions.

Arthur Samuel (1959) Definition

"A field of study that gives computers the ability to learn without being explicitly programmed."

Even today, this is one of the most accepted definitions.

Traditional Programming vs Machine Learning

Traditional Logic vs Machine Learning

Traditional Programming

In traditional programming, we write all the rules ourselves.

Input + Rules ---> Output

Example:

javascript
if (email.contains("Win Money")) {
    return Spam;
} else {
    return Not Spam;
}

Problems:

  • Impossible to write every rule.
  • Rules become very complex.
  • Hard to maintain.

Machine Learning

Instead of writing rules, we provide many examples.

Input + Correct Output → ML Algorithm → Learns Rules Automatically → Prediction

Example:

text
Email 1 → Spam
Email 2 → Spam
Email 3 → Not Spam
...
The model automatically learns what makes an email spam.
Interactive Comparison: Rules vs ML

Real-Life Analogy: Teaching a Child to Recognize Cats

Traditional Programming

You tell the child explicitly:

  • Cats have two ears.
  • Cats have whiskers.
  • Cats have four legs.
  • Cats have a tail.
Machine Learning

Instead, you simply show thousands of cat images and say "This is a cat."

Eventually, the child learns the pattern automatically. Machine learning works in the same way.

Why Do We Need Machine Learning?

Many real-world problems are too complicated for manually written rules.

ProblemWhy ML is Needed
Face RecognitionMillions of different faces
Speech RecognitionDifferent accents and voices
Fraud DetectionFraudsters constantly change strategies
Product RecommendationEvery customer behaves differently
Self Driving CarsInfinite driving situations

Machine Learning allows computers to continuously improve as more data becomes available.

Types of Machine Learning

Machine Learning is mainly divided into three categories.

Machine Learning Taxonomy

1. Supervised Learning

This is the most commonly used type of Machine Learning. Here, every training example has:

  • Input (Features)
  • Correct Output (Label)

The model learns the relationship between input and output:

X -----> Model -----> Y     (Where X = Features, Y = Labels)
House Price Prediction

Input: Area = 1500 sq ft, Bedrooms = 3, Bathrooms = 2

Output: Price = ₹80 Lakhs

The model learns how house features affect the price.

Spam Detection

Email → Model → Spam / Not Spam

Applications:

House Price Prediction, Disease Prediction, Stock Prediction, Spam Detection, Image Classification, Sentiment Analysis

2. Unsupervised Learning

In Unsupervised Learning, data has no labels. The model tries to discover hidden patterns or structures.

Input Data → Find Similarity → Groups (Clusters)

E-Commerce Customer Example:

Customer A, B, C, D. Nobody tells the model which customers are similar. The algorithm automatically groups customers:

Group 1: High spenders | Group 2: Occasional buyers | Group 3: New customers

Real-Life Applications

Spotify groups users with similar music tastes.

Netflix groups users with similar watching behavior.

Amazon groups customers with similar shopping habits.

3. Reinforcement Learning

Reinforcement Learning is inspired by how humans learn through rewards and punishments. Instead of labeled data, the agent interacts with an environment.

State → Agent → Action → Reward → Learn Better Policy
Teaching a Dog Analogy:

Correct action (Sit) → Reward. Wrong action → No Reward. Eventually, the dog learns. Machine Learning agents learn similarly.

Applications:

Self Driving Cars, Robotics, Chess AI, AlphaGo, Game Playing, Recommendation Optimization

Comparison of ML Types

SupervisedUnsupervisedReinforcement
Labeled DataNo LabelsRewards
Predict OutputFind PatternsLearn Actions
Spam DetectionCustomer SegmentationRobot Navigation
ClassificationClusteringDecision Making

Machine Learning in Amazon

Machine Learning powers many Amazon products.

Product Recommendation

When Amazon recommends products, it predicts:

Users with similar interests → Likely Product → Recommendation

Example: You bought Laptop → Amazon recommends Laptop Bag, Wireless Mouse, Keyboard.

Fraud Detection

Every transaction is classified as Fraud or Safe. This is a classification problem.

Alexa

Alexa understands speech using Natural Language Processing, Speech Recognition, and Machine Learning.

Delivery Optimization & Demand Forecasting

Predicts best delivery route, delivery time, traffic conditions, and how many products customers will buy next week to manage inventory efficiently.

Machine Learning Workflow

Every ML project follows a structured workflow.

Iterative ML Workflow Cycle
8-Step Machine Learning Workflow Inspector
Step 1Problem Definition

Ask: What problem are we solving? Is it Classification or Regression? What is expected output?

InputBusiness Goal / Raw Idea
Output Classification or Regression Task
Important Insight

Machine Learning is iterative, not linear. A typical cycle is:

Train → Evaluate → Improve Features → Retrain → Evaluate Again

Improving features or collecting better data often gives larger gains than switching algorithms.

Problem Formulation

Problem formulation is one of the most critical steps in any ML project. A poorly defined problem can lead to poor results, even with advanced algorithms.

Features (X) → Label (Y) → Hypothesis Space (Model Family)

Features (X)

Features are the input variables provided to the model. Also called Independent Variables, Predictors, or Inputs.

Example: Loan ApprovalAge: 28 | Income: ₹12,00,000 | Credit Score: 780 | Employment: Salaried

Good features should be Relevant, Informative, Available at prediction time, and Free from leakage.

Label (Y)

The label is the value the model tries to predict. Also called Target Variable, Output, or Dependent Variable.

House Price: Y = ₹85 Lakhs
Spam Detection: Y = Spam
Loan Approval: Y = Approved

The choice of label determines whether the task is classification or regression.

Hypothesis Space

The hypothesis space is the set of all possible functions that a model can learn.

ModelCan Learn
Linear RegressionLinear relationships
Decision TreeRule-based partitions
Neural NetworkComplex non-linear relationships

Key Takeaways

  • Machine Learning learns patterns from data instead of manually written rules.
  • The three main types are Supervised, Unsupervised, and Reinforcement Learning.
  • Every ML project follows an iterative workflow: define problem, collect data, engineer features, select model, train, evaluate, deploy, and monitor.
  • Feature engineering converts raw data into numerical representations that models can understand.
  • Clearly defining Features (X), Label (Y), and Model Family is essential for a successful ML project.
  • Better data and better features often improve performance more than simply using a more complex algorithm.

Interview Questions and Answers