🔥Limited Offer: Get 50% OFFon AI & Full Stack Courses🔥
Back to Machine Learning Notes
Topic #206

Hyperparameter vs Parameter

A parameter is learned automatically from data during training; a hyperparameter is set before training begins and controls how that learning happens — a distinction that trips up beginners constantly, but is simple once the examples click.

The Core Distinction

ParameterHyperparameter
Set byThe training algorithm, automaticallyYou, before training starts
Found viaOptimization (e.g. gradient descent)Search (grid/random/Bayesian tuning)
Changes during training?Yes — this IS what training doesNo — fixed for the whole training run

Examples Across Algorithms

AlgorithmParameters (learned)Hyperparameters (you choose)
Linear RegressionCoefficients \(b_0, b_1, \dots\)Regularization strength (if using Ridge/Lasso)
Logistic RegressionWeights \(w\), bias \(b\)Regularization type and strength, solver
Decision TreeSplit thresholds, leaf valuesmax_depth, min_samples_leaf, criterion
Random ForestEvery individual tree's learned splitsn_estimators, max_features, tree hyperparameters
KNNNone — it's a lazy learner, nothing is "learned" during trainingk, distance metric
SVMSupport vector weightsC, kernel type, gamma
Neural NetworkAll the connection weightsLearning rate, number of layers, layer sizes, batch size

A Genuinely Instructive Edge Case — KNN

KNN has essentially no learned parameters at all — "training" just stores the data. Every meaningful setting (\(k\), the distance metric) is a hyperparameter you choose. This is exactly why KNN is called a "lazy" or "non-parametric" learner — see K-Nearest Neighbors.

Checking Both in scikit-learn

from sklearn.linear_model import LogisticRegression

model = LogisticRegression(C=1.0, penalty="l2")   # C and penalty are hyperparameters, set before fitting
model.fit(X_train, y_train)

print(model.coef_, model.intercept_)   # these ARE the learned parameters, only available AFTER fitting
print(model.get_params())               # the hyperparameters -- available even before fitting

Notice: hyperparameters are visible via get_params() immediately, since they were set at construction; parameters like coef_ only exist after .fit() has actually run, since they're the output of training, not an input to it.

Practical Use Cases

  • Correctly identifying what a specific "tuning" task is actually adjusting — hyperparameters, never parameters directly
  • Understanding why hyperparameter search requires actually training multiple models, unlike parameter learning which happens within a single training run

Common Mistakes

  • Referring to a model's learned coefficients as "hyperparameters" — a common, easy-to-catch terminology slip in interviews and technical writing.
  • Assuming every algorithm has meaningful hyperparameters to tune — some (like plain linear regression via the Normal Equation, with no regularization) have essentially none.

Interview Relevance

Q: "Is the learning rate a parameter or a hyperparameter?" A hyperparameter — it's set before training begins and controls how the optimization proceeds (step size in gradient descent), but is never itself learned or adjusted by the training algorithm the way weights and coefficients are.

Practice Question

For a Random Forest, classify each as a parameter or hyperparameter: (a) the split threshold chosen at a specific node, (b) n_estimators, (c) the majority class predicted at a specific leaf.

Want to go beyond the notes?

Join CodingNow 2.0's Machine Learning course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available

Hyperparameter vs Parameter – FAQs

Quick answers about learning Hyperparameter vs Parameter in Machine Learning.

This free note from CodingNow 2.0 explains Hyperparameter vs Parameter in Machine Learning — concept, syntax and worked code examples you can copy, run and revise before interviews.
Yes. Every Machine Learning topic on CodingNow 2.0, including Hyperparameter vs Parameter, is 100% free with no signup required.
With focused practice, most students grasp Hyperparameter vs Parameter in 1–3 days from these notes; pairing it with CodingNow 2.0's mentor-led course takes you to job-ready depth faster.
Use the code examples in this note, then ask doubts for free on the CodingNow 2.0 Community (/community) — expert instructors answer within 24 hours.
WhatsApp
Call NowEnroll Now