TRACK A · Composite source · mapped to lessons 1.4.1, 1.4.2, 1.4.5 and 3.1.6 · KNOWLEDGE PLANET
What Is a Machine Learning Model?
After learning how training works, discover what it produces: a model with an architecture and learned parameters. Explore hyperparameters, model families, inference and the complete AI system.
- Define the key concepts accurately
- Distinguish methods and system components
- Explain the main workflow using diagrams
- Identify limitations and describe validation
1. Model, algorithm and data
Data are examples used for learning. The learning algorithm is the procedure that searches for a suitable solution. The trained model is the resulting computational relationship with concrete parameter values. These concepts are related but not interchangeable.
2. Architecture and parameters
Architecture describes the structure and order of computations. Parameters are internal values adjusted during training. For a one-feature linear model, ŷ = w·x + b: x is the input, w is the weight and b is the bias. Changing w or b changes the specific line represented by the model.
3. Parameters versus hyperparameters
Parameters are learned from training data, such as weights and biases. Hyperparameters configure the model or training procedure, such as learning rate, tree depth or batch size. They are selected before or around training, often using validation.
4. Model families
Linear models compute weighted combinations of features and are often easy to inspect. Decision trees apply feature tests and predict at a leaf. Neural networks compose layers of parameterized transformations and can represent complex nonlinear patterns, usually with higher data and computation demands.
5. Training and inference
Training uses examples, a loss function and an optimizer to estimate parameters. Inference applies the fixed trained model to new inputs. Ordinary inference does not update weights. Online learning or fine-tuning is a separate controlled process.
6. What must be saved?
A reproducible deployment may require weights, architecture configuration, preprocessing, category mappings, tokenizer, library versions and experiment metadata. A model file alone may be insufficient: inputs must be transformed in the same way as during training.
7. A model is not the whole product
A deployed system includes input validation, preprocessing, inference, postprocessing, business rules, interface, monitoring and human review. A unit mismatch can cause failure even when the model is mathematically correct.
8. Python walkthrough
The example below creates and trains a linear regression model, inspects learned parameters and predicts energy use for a new temperature. fit() performs training; predict() performs inference. X is two-dimensional: rows are observations and columns are features.
9. Experiment and review
Train decision trees with maximum depths 1, 2, 3 and 5. Keep the same train/validation split and compare errors. A deeper tree often reduces training error, but may fit noise and perform worse on unseen examples. Change one hyperparameter at a time.
Python practice
import numpy as np
from sklearn.linear_model import LinearRegression
X = np.array([[-10], [-5], [0], [5], [10], [15]])
y = np.array([2100, 1950, 1780, 1600, 1450, 1280])
model = LinearRegression().fit(X, y)
print("weight:", model.coef_[0])
print("bias:", model.intercept_)
print("prediction:", model.predict([[7]])[0])fit() estimates parameters; predict() performs inference on a new input.
Review
Define the key terms in your own words, give a real-world example and explain how you would validate the system's output.
Why the saved pipeline matters
Suppose training data were standardized using a fitted scaler. At deployment, the same scaler and feature order must be used. Recomputing the mean and standard deviation on every request changes the input representation and can make predictions inconsistent. Save the preprocessing configuration with the model and test the complete pipeline, not just the model object.
Next lesson: 1.2.4 · 1.2.6 · 1.4.3 · 1.5.1–1.5.7 · How to Evaluate a Machine Learning Model? ↗
Complete lesson: what a model contains and how it is used
Keep data, learning algorithm and model separate
Training data are examples used to construct a model. A learning algorithm is the procedure that searches for a suitable model or parameter values. The trained model is the resulting computational object: an architecture together with learned parameters and, in some cases, other state. During inference, the model receives new inputs and computes outputs. These terms describe different roles. A dataset is not a model, an algorithm is not the fitted result, and a trained model is not the entire application.
Architecture, parameters and hyperparameters
The architecture defines the model's structure and the operations through which information flows. Parameters are learned from data: coefficients, biases, tree split values or neural-network weights. Hyperparameters configure the architecture or learning procedure, such as tree depth, regularization strength, number of layers, batch size or learning rate. Hyperparameters are selected through a development process; they are not normally estimated as ordinary model weights in the same training step. The distinction depends on the model family, so document exactly what was learned and what was configured.
Three model families
A linear model combines features using learned coefficients. It is often a useful baseline and can be relatively easy to inspect, although its assumptions may be too restrictive for complex relationships. A decision tree applies a sequence of feature-based conditions and ends at a leaf with a prediction. It can represent nonlinear interactions and provide readable paths, but deep trees can become unstable and overfit. A neural network applies layers of parameterized transformations. It can learn rich representations, particularly for unstructured inputs, but may require more data, computation and careful evaluation.
These families are not a universal ranking. For a small structured dataset, a gradient-boosted tree may outperform a neural network with less effort. For image recognition, a neural architecture may be more appropriate. For a safety-critical decision, a transparent rule or constrained model may be preferable. Compare candidates against the same baseline and data split.
Training and inference are different processes
During training, the algorithm uses examples and a loss function to adjust parameters. Training may include optimization, validation, hyperparameter selection and early stopping. After the model is accepted, inference applies the saved parameters to new inputs. Ordinary inference does not update the model. Online learning or periodic retraining is a separate, controlled process that needs monitoring, versioning and rollback procedures.
What should be saved?
A deployable model is more than a weight file. Save the model architecture and parameters, feature names and order, preprocessing steps, category encodings, units, target definition, training-data version, software dependencies, random seeds where relevant, evaluation results and model version. If a scaler was fitted during training, inference must reuse that fitted scaler rather than calculating new statistics for each request. Otherwise the model receives inputs in a different representation from the one it learned.
The model is one component of an AI system
A production pipeline may validate input, handle missing values, transform features, call a model, apply business or safety rules, format the result and present it to a user. Logging, monitoring, human review and feedback surround the pipeline. A technically accurate model can still be part of an unreliable system if upstream data are wrong, the model is used outside its intended range or the output is interpreted incorrectly. This is also why explanations must state what component they describe.
Compare three models for one energy task
Suppose the task is to estimate daily building energy use from weather, floor area and occupancy. A linear regression provides a transparent baseline. A decision tree can capture threshold effects, such as heating demand increasing sharply below a temperature. A neural network can represent more complex interactions but may be harder to justify on a small dataset. Compare MAE or RMSE on the same held-out cases, inspect residuals by operating condition and document training cost and inference latency. Select the simplest model that meets the real requirement.
Practical experiment
Train a decision tree with several maximum-depth values. Keep the same training and test split. Record training and test error for each depth. If training error keeps decreasing while test error begins to increase, the tree is likely overfitting. Explain which hyperparameter changed, which learned parameters changed during fitting, and what additional validation would be needed before deployment.
Model comparison and reproducibility checklist
Compare models as complete candidates
When comparing a linear model, a decision tree and a neural network, keep the target, input features, train/test split and evaluation metric consistent. Otherwise, a score difference may be caused by a different experiment rather than a better model. Start with a simple baseline. Record not only predictive quality but also training time, inference latency, memory use, ease of inspection and the effort required to maintain the model.
Inspect errors by relevant operating conditions. A model may have a good average error while performing poorly during extreme weather, at low occupancy or for a particular equipment type. Averages can hide groups of cases where the system is unreliable. The model's intended operating range should be documented, and cases outside that range should trigger a fallback or human review.
What belongs in a model release
- Versioned model artifact and architecture/configuration.
- Exact feature schema, ordering, units and preprocessing pipeline.
- Training data reference, code version and dependency versions.
- Evaluation report with baseline, split design, metrics and error analysis.
- Intended use, known limitations, monitoring signals and rollback procedure.
A model that cannot be reproduced or traced is difficult to audit. Saving the artifact without the feature definitions and preprocessing steps is not sufficient: the same input must be transformed in the same way at training and inference time.
Questions before deployment
- Does the evaluation data represent the actual users, equipment and operating conditions?
- Can a user recognize when the model is uncertain or outside its intended scope?
- Who is responsible for reviewing consequential outputs?
- How will drift, missing inputs and unusual predictions be detected?
- Can the previous model version be restored safely?
10. Lesson glossary
A computational relationship that transforms input data into an output.
The structure of a model and the order of its computations.
An internal value adjusted by the learning algorithm using training data.
A model or training configuration selected separately from ordinary parameter updates.
A parameter that determines the contribution of a feature or connection.
An additional parameter that shifts the model output.
The process of fitting model parameters using training data.
Applying a trained model to new input data.
Transformations applied to data before it is passed to a model.
A change in data properties between training and real-world use.
A saved state of a model or training process.
Transforming a model output after computation.
11. Interactive self-check
Question 1
What is the result of a learning algorithm?
Question 2
Which values are usually parameters of a linear model?
Question 3
Are model parameters changed during ordinary inference?
Question 4
What may be needed for reproducible model use?
Question 5
Is this statement true: “A larger neural network is always better for every task”?
Question 6
Which components may surround a model in a production AI system?