What is Supervised Learning? — ML Technical Interview Questions & Answers

Learning a mapping from labeled input-output pairs.

What is Supervised Learning?

  • Simple meaning: Supervised learning needs a label column y. Each row is (features X, answer y). The model learns X → y. After training, you only have X for a new student and you guess y.
  • Picture: hours + attendance → marks (regression). hours + attendance → pass/fail (classification). Without y, it is not supervised.
  • How you run it: split train/test, fit(X_train, y_train), predict(X_test), compare to y_test with the right metric.
  • Trap: calling clustering supervised. Trap: training without a label and still saying “we classified”.

Technical Interview Tip: Need labels. Then X → y. Number or class.

Code Examples for What is Supervised Learning?

What is Supervised Learning? — working example

def majority_vote(labels):
    return max(set(labels), key=labels.count)

neighbors = [1, 1, 0, 1, 0]
print(majority_vote(neighbors))  # kNN-style vote

# Logistic idea: score → probability via sigmoid
def sigmoid(z):
    return 1 / (1 + 2.718281828 ** (-z))
print(round(sigmoid(0.0), 3), round(sigmoid(2.0), 3))

What is Supervised Learning? — classifiers map features to labels; kNN votes neighbors; logistic uses a sigmoid probability.

How to Explain What is Supervised Learning? to an Interviewer

What does supervised need?

A label y for each training row

Two supervised jobs?

Regression Classification