Skip to content
New
Latest News || 27 October 2026: Dr Soumava Mukherjee's invited talk at Queen's University Belfast joined device-level hardware innovation with channel-level control. || 22 October 2026: I received a Certificate of Appreciation for serving as a reviewer for IEEE IMAS 2026. || 15 October 2026: I presented a poster on beam-domain ML fingerprinting for RIS-aided mmWave localisation at the Centre for Wireless Innovation's annual symposium. || 15 October 2026: CWI's annual symposium brought research and industry perspectives on 6G, ISAC, optical wireless, AI, and future networks to Queen's University Belfast. || 14 October 2026: Erik Nordell of Ericsson visited our Keysight Lab for a live RIS-assisted video streaming demonstration.
Knowledge Hubmachine learning8. Classification, Regression and Compute Cost

machine learning learning note

8. Classification, Regression and Compute Cost

A practical comparison of classifiers and regressors, including output type, metrics, computational efficiency, and model-selection guidance.

At a glance

  • The target decides the taskA class label needs classification; a numeric measurement needs regression. Neither task is inherently faster.
  • Match metrics to units and error costsClassification uses confusion-based or ranking metrics; regression uses numeric error metrics. Accuracy and MAE are not interchangeable.
  • Measure the resource boundaryCompare latency, memory and training cost under the same hardware and workload; model-size proxies are not benchmarks.

The Core Difference

Classifiers and regressors are both supervised learning models. The difference is the type of target they predict.

QuestionModel typeOutput
Is this sample LOS or NLOS?ClassifierClass label
What is the received signal strength?RegressorContinuous number
Which disease category is present?ClassifierClass label
What is the expected localization error?RegressorContinuous number

A classifier predicts categories. A regressor predicts quantities.

References for this section3
  • Scikit-learn documentation, "Supervised learning".
  • T. Hastie, R. Tibshirani, and J. Friedman, The Elements of Statistical Learning, 2nd ed., Springer, 2009.
  • C. M. Bishop, Pattern Recognition and Machine Learning, Springer, 2006.

Classifier Outputs

A classifier usually returns one or both of these:

  • A class label, such as 0, 1, "normal", or "fault".
  • A class probability, such as P(class = fault) = 0.82.

The decision can depend on a threshold. For example, a binary classifier may predict class 1 when the probability is above 0.5, but a high-risk system may use a lower or higher threshold depending on the cost of mistakes.

References for this section3
  • T. Hastie, R. Tibshirani, and J. Friedman, The Elements of Statistical Learning, 2nd ed., Springer, 2009.
  • C. M. Bishop, Pattern Recognition and Machine Learning, Springer, 2006.
  • Scikit-learn documentation, "Supervised learning".

Regressor Outputs

A regressor returns a numerical value:

predicted house price = 315000
predicted temperature = 21.4
predicted positioning error = 0.73 meters

The output is not a class. It is a value on a continuous scale.

References for this section3
  • T. Hastie, R. Tibshirani, and J. Friedman, The Elements of Statistical Learning, 2nd ed., Springer, 2009.
  • C. M. Bishop, Pattern Recognition and Machine Learning, Springer, 2006.
  • Scikit-learn documentation, "Supervised learning".

Evaluation Metrics

Classifiers and regressors need different metrics.

GoalClassifier metricsRegressor metrics
General performanceAccuracy, balanced accuracyMAE, RMSE, R-squared
Imbalanced dataPrecision, recall, F1-score, ROC-AUCNot directly applicable
Error costConfusion matrix, false-positive rate, false-negative rateResidual plots, absolute error, squared error
InterpretabilityFeature importance, coefficients, decision rulesFeature importance, coefficients, residual behavior

Accuracy is not meaningful for continuous regression. RMSE is not meaningful for class labels unless the labels have a real numeric distance.

Accuracy=correct predictionstotal predictions\mathrm{Accuracy}=\frac{\mathrm{correct\ predictions}}{\mathrm{total\ predictions}} F1=2 Precision RecallPrecision+RecallF_1=\frac{2\,\mathrm{Precision}\,\mathrm{Recall}}{\mathrm{Precision}+\mathrm{Recall}}
  • Accuracy: fraction of all predictions that are correct.
  • Precision: true positives divided by predicted positives
  • Recall: true positives divided by actual positives.
  • F1: harmonic mean of precision and recall; useful when both error types matter.
MAE=1n∑i=1n∣yi−y^i∣\mathrm{MAE}=\frac1n\sum_{i=1}^n\lvert y_i-\widehat y_i\rvert RMSE=1n∑i=1n(yi−y^i)2\mathrm{RMSE}=\sqrt{\frac1n\sum_{i=1}^n(y_i-\widehat y_i)^2}
  • nn is the number of samples
  • yiy_{i} is a measured value and ŷᵢ its prediction.
  • ∑i\sum _{i} adds errors across samples; absolute value gives MAE, while squaring then taking the square root gives RMSE.
References for this section3
  • Scikit-learn documentation, "Model evaluation".
  • T. Hastie, R. Tibshirani, and J. Friedman, The Elements of Statistical Learning, 2nd ed., Springer, 2009.
  • C. M. Bishop, Pattern Recognition and Machine Learning, Springer, 2006.

Efficiency Means More Than Accuracy

Efficiency can mean several things:

  • Training time.
  • Prediction latency.
  • Memory usage.
  • Amount of preprocessing.
  • Amount of labeled data needed.
  • Ease of tuning.
  • Interpretability per unit of complexity.

A model with slightly lower accuracy may be better if it is faster, easier to maintain, and more stable.

References for this section3
  • Scikit-learn documentation, "Model evaluation".
  • T. Hastie, R. Tibshirani, and J. Friedman, The Elements of Statistical Learning, 2nd ed., Springer, 2009.
  • C. M. Bishop, Pattern Recognition and Machine Learning, Springer, 2006.

Computational Efficiency by Model Family

Model familyClassifier exampleRegressor exampleEfficiency notes
Linear modelsLogistic RegressionLinear/Ridge RegressionFast, scalable, interpretable
KNNKNeighborsClassifierKNeighborsRegressorCheap training, slow prediction on large data
TreesDecisionTreeClassifierDecisionTreeRegressorFast, interpretable, can overfit
Random forestsRandomForestClassifierRandomForestRegressorStrong but heavier than one tree
BoostingGradientBoostingClassifierGradientBoostingRegressorAccurate, needs tuning, sequential training
Kernel methodsSVCSVR/Kernel RidgePowerful but expensive for large datasets
Neural networksMLP/CNN classifierMLP regressorEfficient at scale with hardware, data-hungry
References for this section3
  • Scikit-learn documentation, "Model evaluation".
  • T. Hastie, R. Tibshirani, and J. Friedman, The Elements of Statistical Learning, 2nd ed., Springer, 2009.
  • C. M. Bishop, Pattern Recognition and Machine Learning, Springer, 2006.

Which Is Usually Faster?

There is no universal winner. The task type does not determine speed by itself; the algorithm and dataset do.

For example:

  • Logistic Regression and Ridge Regression are both usually fast.
  • KNN classification and KNN regression both become slow at prediction time as the training set grows.
  • Random Forest classifiers and regressors have similar computational patterns.
  • Kernel classifiers and kernel regressors can both be expensive on large datasets.
  • Neural classifiers and neural regressors can both require significant compute.

The model family matters more than whether the task is classification or regression.

References for this section3
  • Scikit-learn documentation, "Model evaluation".
  • T. Hastie, R. Tibshirani, and J. Friedman, The Elements of Statistical Learning, 2nd ed., Springer, 2009.
  • C. M. Bishop, Pattern Recognition and Machine Learning, Springer, 2006.

Data Efficiency

Data efficiency asks how much data a model needs before it performs well.

SituationMore data-efficient choices
Small tabular datasetLinear models, Ridge, Logistic Regression, trees
Strong domain featuresLinear models and tree ensembles
Complex images/audio/textNeural networks, usually with transfer learning
Smooth non-linear dataKernel methods or gradient boosting
Noisy measurementsRegularized models and ensembles

Regularization improves data efficiency because it reduces overfitting.

References for this section3
  • T. Hastie, R. Tibshirani, and J. Friedman, The Elements of Statistical Learning, 2nd ed., Springer, 2009.
  • C. M. Bishop, Pattern Recognition and Machine Learning, Springer, 2006.
  • Scikit-learn documentation, "Supervised learning".

Prediction Efficiency

Prediction efficiency matters when a model runs in real time, on embedded hardware, or inside a large simulation loop.

ModelPrediction behavior
Linear/Logistic/RidgeVery fast matrix multiplication
Decision treeFast path through tree nodes
Random forestSlower because many trees vote or average
Gradient boostingSlower than one tree, often faster than large forests
KNNCan be slow because it compares against stored samples
Kernel RidgeCan be slow because prediction depends on training examples
Neural networkFast on GPUs, may be heavy on small CPUs

What grows when a model keeps every training example?

1. Formula and symbols
Nlinear=d+1,CKNN∼ndN_{\rm linear}=d+1,\quad C_{\rm KNN}\sim nd
Mkernel=8n2 bytesM_{\rm kernel}=8n^2\ \mathrm{bytes}
  • dd: features
  • nn: stored training examples

The linear count includes an intercept

KNN counts coordinate comparisons

the kernel matrix uses 8-byte values. These different size proxies are not runtime measurements.

Linear dot product20KNN distances20,000KRR kernel entries1,000,000Bar length is log₁₀(count); these are different cost proxies, not timings.
2. Work with the current inputs
Clinear∼d=20,CKNN∼nd=1000×20=20000C_{\rm linear}\sim d=20,\quad C_{\rm KNN}\sim nd=1000\times20=20000
MK=8n2=8×10002 bytes=7.63 MiBM_K=8n^2=8\times1000^2\ \mathrm{bytes}=7.63\ \mathrm{MiB}
3. Result
Linear coefficient slots21
Brute-force KNN coordinate comparisons20,000
Dense KRR matrix only7.63 MiB
Algorithmic size proxies, not measured runtime or a claim that classification is faster than regression. A dense linear predictor stores d+1 coefficients; brute-force KNN examines about nd coordinate differences per query; dense KRR stores n² double-precision kernel entries before solver overhead. Indexes, batching, hardware, sparsity and approximations change real costs.
References for this section3
  • Scikit-learn documentation, "Model evaluation".
  • T. Hastie, R. Tibshirani, and J. Friedman, The Elements of Statistical Learning, 2nd ed., Springer, 2009.
  • C. M. Bishop, Pattern Recognition and Machine Learning, Springer, 2006.

Choosing Between Classification and Regression

Choose classification when the real target is a category:

  • Fault type.
  • Link state.
  • Object class.
  • User activity.
  • Disease category.

Choose regression when the real target is a quantity:

  • Distance.
  • Power.
  • Temperature.
  • Price.
  • Latency.
  • Error magnitude.

If a numeric value is later converted into categories, regression may preserve more information. If only the category matters, classification is usually simpler.

References for this section3
  • T. Hastie, R. Tibshirani, and J. Friedman, The Elements of Statistical Learning, 2nd ed., Springer, 2009.
  • C. M. Bishop, Pattern Recognition and Machine Learning, Springer, 2006.
  • Scikit-learn documentation, "Supervised learning".

Borderline Cases

Some problems can be framed either way.

ProblemClassification framingRegression framing
Signal qualitypoor / fair / goodSINR value
Risklow / medium / highprobability or score
Localizationroom IDx-y coordinates
Demandlow / normal / highnumber of units

The better framing depends on the decision that follows the prediction.

References for this section3
  • T. Hastie, R. Tibshirani, and J. Friedman, The Elements of Statistical Learning, 2nd ed., Springer, 2009.
  • C. M. Bishop, Pattern Recognition and Machine Learning, Springer, 2006.
  • Scikit-learn documentation, "Supervised learning".

Practical Selection Guide

NeedRecommended direction
Need exact numerical estimateRegression
Need category or action labelClassification
Need uncertainty over classesProbabilistic classification
Need simple and fast baselineLogistic Regression or Ridge Regression
Need high tabular accuracyGradient boosting or random forest
Need real-time predictionLinear model, small tree, or compact neural model
Need interpretabilityLinear model, shallow tree, or feature importance analysis
References for this section3
  • Scikit-learn documentation, "Model evaluation".
  • T. Hastie, R. Tibshirani, and J. Friedman, The Elements of Statistical Learning, 2nd ed., Springer, 2009.
  • C. M. Bishop, Pattern Recognition and Machine Learning, Springer, 2006.

Python: Compare Classifier and Regressor Workflows

from sklearn.datasets import load_breast_cancer, fetch_california_housing
from sklearn.linear_model import LogisticRegression, Ridge
from sklearn.metrics import accuracy_score, mean_absolute_error
from sklearn.model_selection import train_test_split
from sklearn.pipeline import make_pipeline
from sklearn.preprocessing import StandardScaler

# Classification task
X_cls, y_cls = load_breast_cancer(return_X_y=True)
Xc_train, Xc_test, yc_train, yc_test = train_test_split(
    X_cls, y_cls, test_size=0.2, random_state=42, stratify=y_cls
)

classifier = make_pipeline(
    StandardScaler(),
    LogisticRegression(max_iter=1000)
)
classifier.fit(Xc_train, yc_train)
cls_pred = classifier.predict(Xc_test)

print("classification accuracy:", accuracy_score(yc_test, cls_pred))

# Regression task
X_reg, y_reg = fetch_california_housing(return_X_y=True)
Xr_train, Xr_test, yr_train, yr_test = train_test_split(
    X_reg, y_reg, test_size=0.2, random_state=42
)

regressor = make_pipeline(
    StandardScaler(),
    Ridge(alpha=1.0)
)
regressor.fit(Xr_train, yr_train)
reg_pred = regressor.predict(Xr_test)

print("regression MAE:", mean_absolute_error(yr_test, reg_pred))
References for this section3
  • Scikit-learn documentation, "Model evaluation".
  • T. Hastie, R. Tibshirani, and J. Friedman, The Elements of Statistical Learning, 2nd ed., Springer, 2009.
  • C. M. Bishop, Pattern Recognition and Machine Learning, Springer, 2006.

Takeaway

  • Classifier: answers "which category?"; evaluate with class-relevant metrics.
  • Regressor: answers "how much?"; evaluate with numeric-error metrics.
  • Efficiency: depends on dataset size, feature count, algorithm, and deployment budget.
  • First decision: choose the right target type, then compare meaningful errors and compute cost.

Continue with Deep Learning Architectures to build on this note.

References for this section3
  • T. Hastie, R. Tibshirani, and J. Friedman, The Elements of Statistical Learning, 2nd ed., Springer, 2009.
  • C. M. Bishop, Pattern Recognition and Machine Learning, Springer, 2006.
  • Scikit-learn documentation, "Supervised learning".

Check your understanding

0 of 4 answered

  1. Predicting distance in metres is which task?

  2. A scalar linear predictor has d=20 features and one intercept. How many coefficients are stored?

  3. For brute-force KNN with n=1,000 and d=20, how many coordinate differences are examined per query?

  4. Doubling n changes the storage of a dense n×n kernel matrix by what factor?

Complete references and further reading

  • T. Hastie, R. Tibshirani, and J. Friedman, The Elements of Statistical Learning, 2nd ed., Springer, 2009.
  • C. M. Bishop, Pattern Recognition and Machine Learning, Springer, 2006.
  • Scikit-learn documentation, "Supervised learning".
  • Scikit-learn documentation, "Model evaluation".