AI Foundations for Developers COURSE·LESSON 08 OF 410 completed

Regression and Classification

Predicting a quantity

Regression predicts a numerical value, such as ticket resolution time. A linear model takes y_hat = w1×x1 + w2×x2 + b. “Linear” describes how parameters combine with features; you can still engineer nonlinear features such as squared account age.

For an illustrative model minutes = 5 + 2×attachments, three attachments predict 11 minutes. The coefficient describes the fitted relationship, not proof that adding an attachment causes exactly two minutes of work. Correlation does not establish causation.

Squared-error loss gives larger errors disproportionate weight. Absolute error is less sensitive to extreme misses. Outlier handling should reflect whether those cases are data errors or important real situations.

Predicting a category

A binary classifier estimates a score for two classes. Logistic regression maps a linear score through the sigmoid: p = 1/(1+exp(-z)). A threshold then converts probability into an action.

python
import math

def sigmoid(z):
    return 1 / (1 + math.exp(-z))

for refund_words in [0, 1, 2]:
    z = -2 + 1.5 * refund_words
    p = sigmoid(z)
    print(refund_words, round(p, 3), p >= 0.5)
# 0 0.119 False
# 1 0.378 False
# 2 0.731 True

These are hand-chosen weights for explanation, not a trained billing classifier. Run the example in the Python compiler. Increasing the threshold to 0.8 means none of these examples triggers the billing action.

Multiclass and multilabel

Multiclass selects one class among several, such as billing, account, or bug. Softmax maps a vector of scores into probabilities summing to one. Multilabel permits several labels at once: a ticket may involve both billing and a bug. Independent sigmoid outputs are one common approach for multilabel problems.

The model score and the business action are separate. A 0.55 probability might justify manual review rather than automatic routing when mistakes are expensive.

Checkpoint with answers

Why is sigmoid alone not a complete classifier? You still need features, fitted parameters, a decision policy, and evaluation.

Can a regressor predict outside the observed training range? Some can, including linear models, but extrapolation may be unreliable.

Exercise: A ticket has two valid labels. Should you force it into an exclusive softmax category? Answer: only if the business contract requires a single category. Otherwise define a multilabel task and evaluate each label appropriately.

Learn at your own pace0 / 41 lessons complete