Machine Learning Basics

Chapter 1
Foundations and Landscape of Machine Learning

Bachelors Program in AI & ML
Machine Learning Basics   •   Bachelor

Foundations and Landscape of Machine Learning

Introduction and Context

Artificial intelligence (AI) has moved from a specialized research field into a general-purpose technology used in search, recommendation, medicine, finance, manufacturing, education, transportation, and public administration. Despite this visibility, the terms artificial intelligence, machine learning, and deep learning are often used as if they were interchangeable. They are related, but they describe different scopes of ideas.

AI is the broadest concept: it concerns computational systems that perform tasks associated with human or animal intelligence, such as perception, reasoning, language use, planning, and decision-making. Machine learning (ML) is an approach within AI in which systems improve their performance by learning patterns from data rather than relying entirely on manually written rules. Deep learning is a family of machine-learning methods based primarily on multilayer neural networks that learn increasingly abstract representations from data.

This chapter establishes the conceptual vocabulary required for later study of algorithms and models. It explains what it means for a system to learn, distinguishes major learning paradigms, and separates three goals that are frequently confused: prediction, inference, and optimization. It also introduces features, labels, parameters, training, testing, generalization, and the practical responsibilities involved in deploying ML systems.

Learning Objectives

By the end of this chapter, you should be able to:

1. Define artificial intelligence, machine learning, and deep learning and explain their relationship.

2. Distinguish supervised, unsupervised, semi-supervised, and reinforcement learning.

3. Explain features, labels, examples, parameters, hyperparameters, training, validation, testing, and generalization.

4. Differentiate prediction, inference, and optimization as distinct objectives.

5. Describe a typical machine-learning workflow and identify sources of error and bias.

6. Analyze a practical ML application and discuss its technical, organizational, ethical, and regulatory implications.

From Artificial Intelligence to Machine Learning

Artificial intelligence

Artificial intelligence is the field concerned with designing computational agents that perceive environments, represent or process information, and produce actions or outputs aimed at achieving goals. The definition is intentionally broad. A system may be considered intelligent because it recognizes speech, recommends a product, proves a theorem, navigates a vehicle, or assists a human decision-maker.

AI includes several traditions. Symbolic or rule-based AI represents knowledge explicitly through rules, logic, ontologies, or search procedures. Statistical AI represents uncertainty and learns relationships from data. Robotics combines perception, planning, control, and physical action. Modern systems frequently combine these traditions. For example, an autonomous vehicle may use learned perception models, geometric algorithms, maps, optimization, and rule-based safety constraints.

Intelligence in an engineered system does not necessarily imply consciousness, understanding in the human sense, or general-purpose reasoning. A model can perform a narrow task effectively while having no ability to transfer its competence to unrelated situations. This distinction between narrow competence and general intelligence is important when evaluating claims about AI.

Machine learning

Machine learning is a field of AI that develops algorithms capable of improving their performance through experience, usually represented by data or interaction. A conventional program is often described as applying manually specified instructions to input data to produce outputs. In machine learning, the designer specifies a learning procedure and a representation, while the system estimates useful relationships from examples.

A useful abstract view is:

data + learning algorithm + objective = trained model

The data provide evidence, the algorithm determines how that evidence is used, and the objective defines what counts as a good result. The resulting model can then be applied to new cases.

Learning does not mean that the system discovers truth without assumptions. Every ML system depends on choices about what data to collect, which variables to represent, what outcome to measure, how errors are weighted, and when performance is acceptable. These choices can introduce both technical and social consequences.

Deep learning

Deep learning is machine learning using neural networks with multiple computational layers. A neural network transforms inputs through successive parameterized functions. Early layers may detect relatively simple patterns, while later layers combine them into more abstract representations. In image analysis, for example, a model may progress from edges to textures to object parts and then to object categories, although the precise representations are learned rather than manually assigned.

Deep learning has been especially successful where large datasets, substantial computational resources, and high-dimensional inputs are available, including images, audio, natural language, and biological sequences. Its strengths include representation learning and flexible function approximation. Its limitations include data and computational requirements, sensitivity to distribution changes, difficulty of interpretation in some settings, and vulnerability to poorly designed objectives or adversarial inputs.

Deep learning is therefore a subset of machine learning, and machine learning is a subset of AI. Not every AI system uses ML, not every ML system uses deep learning, and a more complex model is not automatically a better solution.

The Machine-Learning Problem

A machine-learning task begins with a population of possible cases and an objective. Suppose a hospital wants to estimate whether a patient is at high risk of readmission. Each patient is represented by an input vector, such as age, previous admissions, laboratory measurements, medications, and diagnosis codes. The desired outcome may be a binary label indicating whether readmission occurs within a specified time window.

An individual data record is called an example, instance, or observation. The input variables are features. In supervised learning, the known outcome is the label, target, or response variable. A model uses features to produce a prediction of the target.

For a supervised task, one can write the conceptual relationship as

ŷ = fθ(x)

where x is an input feature vector, ŷ is the model’s output, f is the model family, and θ represents learned parameters. The notation does not imply that the relationship is deterministic in the real world. It expresses the model’s mapping from inputs to outputs. A probability model might return the estimated probability of a class rather than a single class decision.

A parameter is a value learned from training data, such as a coefficient in linear regression or a weight in a neural network. A hyperparameter is a setting chosen outside the ordinary parameter-learning process, such as a tree’s maximum depth, a regularization strength, or a neural network’s learning rate. Confusing these terms can lead to incorrect descriptions of model development.

Objectives and loss functions

A learning algorithm requires a way to measure undesirable performance. A loss function assigns a numerical penalty to a model’s output. For example, in regression, squared error for one observation can be written as

L(y, ŷ) = (y − ŷ)²

where y is the observed value and ŷ is the prediction. This loss penalizes larger errors more strongly than smaller errors and is appropriate in some settings, but not all. If extreme errors should not dominate, an absolute-error loss may be preferable. For classification, a probabilistic model is commonly trained with cross-entropy loss. The choice must reflect the task, data, and consequences of errors.

Training generally seeks parameter values that reduce average loss on the training data. In simplified form:

θ̂ = argminθ (1/n) Σᵢ L(yᵢ, fθ(xᵢ))

Here, n is the number of training examples, yᵢ and xᵢ are the observed label and features for example i, and θ̂ denotes the learned parameter values. This expression describes an empirical objective; it does not guarantee that the model will perform well on future data. Generalization must be assessed separately.

Major Learning Paradigms

Supervised learning

In supervised learning, the training data contain input-output pairs. The algorithm learns to predict a label or target from features. The two principal forms are:

  • Classification: predicting a category, such as fraudulent or legitimate.
  • Regression: predicting a numerical quantity, such as delivery time or electricity demand.

Supervised learning is appropriate when reliable labels exist and the desired outcome is clearly defined. Its central difficulty is that labels may be expensive, delayed, subjective, incomplete, or affected by past decisions. A dataset of loan approvals, for instance, may reflect historical institutional policy rather than an unbiased measure of applicants’ ability to repay.

Unsupervised learning

Unsupervised learning uses data without a provided target label. The aim may be to discover structure, summarize observations, identify unusual cases, or represent data in a lower-dimensional form. Common tasks include clustering, density estimation, dimensionality reduction, and anomaly detection.

A clustering algorithm may group customers according to purchasing behavior, but the groups are not automatically meaningful customer segments. Interpretation requires domain knowledge and validation. Unsupervised results are often exploratory rather than definitive. They can reveal patterns, but they do not by themselves establish causal explanations.

Semi-supervised learning

Semi-supervised learning uses a relatively small collection of labeled examples together with a larger collection of unlabeled examples. This arrangement is common when labeling requires expert time, as in medical imaging, while raw data are abundant.

The underlying assumption is usually that unlabeled data contain information about the structure relevant to the task. However, the assumption may fail if the unlabeled examples come from a different population or if the classes overlap substantially. Semi-supervised methods must therefore be evaluated carefully, especially when automated pseudo-labels may reinforce early errors.

Reinforcement learning

Reinforcement learning (RL) concerns an agent that interacts with an environment over time. At each step, the agent observes a state, selects an action, receives a reward or penalty, and moves to a subsequent state. The objective is to learn a policy that achieves high cumulative reward.

RL differs from ordinary supervised learning because the correct action is not usually supplied for every state. Feedback may be delayed, and actions influence future observations. The agent must balance exploration, trying actions to gain information, with exploitation, selecting actions already believed to be effective.

RL is used in game playing, robotics, resource allocation, and some recommendation or control problems. It can be unsafe when exploration has real-world costs. Simulated environments, safety constraints, human oversight, and offline evaluation are therefore important in high-risk applications.

Comparison of paradigms

The paradigms differ primarily in the form of feedback. Supervised learning receives explicit target values; unsupervised learning receives no target labels; semi-supervised learning combines labeled and unlabeled data; reinforcement learning receives evaluative feedback through rewards over time. These categories are useful, but modern systems may combine them. A language model, for example, may use self-supervised pretraining, supervised instruction data, and human preference feedback.

Prediction, Inference, and Optimization

These three terms describe different purposes and should not be treated as synonyms.

Prediction

Prediction asks what will happen, or what value or category should be assigned to a new case. Predictive performance is assessed by comparing outputs with outcomes that were not used during training. The emphasis is often on accuracy, calibration, ranking, speed, and robustness.

A model can be highly predictive without representing a causal relationship. For example, an online search behavior may predict illness because it correlates with symptoms, even though changing the search behavior would not change the illness.

Inference

Inference asks what can be learned about a process, relationship, parameter, or cause. Statistical inference may involve estimating uncertainty, testing hypotheses, or interpreting relationships. In causal inference, the question may be whether changing one variable would change an outcome under specified conditions.

A predictive model’s feature importance is not automatically a causal effect. If hospital location predicts health outcomes, the relationship may reflect access, socioeconomic conditions, referral patterns, or other factors. Causal conclusions require an appropriate design, assumptions, and analysis.

Optimization and decision-making

Optimization asks which action, allocation, or configuration best satisfies an objective subject to constraints. A predictive model may estimate demand, while an optimization procedure uses those estimates to schedule staff or stock inventory.

The distinction matters because optimizing an imperfect prediction can amplify errors. Further, the best action depends on costs, benefits, constraints, uncertainty, and fairness requirements—not merely predictive accuracy. A recruitment system, for example, must consider legal restrictions and equal-opportunity goals in addition to estimated job performance.

Training, Evaluation, and Generalization

Training and the data split

Training is the process of using data to estimate model parameters. A dataset is commonly divided into training, validation, and test portions. The training set is used to fit parameters. The validation set supports choices such as model type or hyperparameters. The test set is reserved for final evaluation.

The test set should represent the intended deployment population and must not influence model selection. If repeated experimentation gradually adapts decisions to test results, the test set ceases to be an independent evaluation resource. In time-dependent problems, a chronological split may be more appropriate than a random split. In patient-level data, all records from one patient may need to remain in the same partition to prevent information leakage.

Generalization

Generalization is the ability of a trained model to perform well on new cases drawn from the relevant deployment setting. A model may memorize training examples and still generalize poorly. This is called overfitting. A model that is too simple to capture important regularities may underfit.

Regularization, simpler models, more representative data, appropriate feature design, and careful validation can reduce overfitting. However, regularization cannot correct a fundamentally biased target, data leakage, or a major shift between training and deployment populations.

Distribution shift

A model assumes, explicitly or implicitly, that future cases resemble the data used for development. In practice, the data distribution may change. Covariate shift occurs when feature distributions change; label shift occurs when class proportions change; and broader concept or relationship drift occurs when the relationship between features and outcomes changes.

Examples include changing consumer behavior, new medical treatments, altered fraud strategies, and economic crises. Monitoring should therefore continue after deployment. Performance, data quality, subgroup outcomes, calibration, and unusual inputs may all require surveillance.

Evaluation metrics

No single metric is universally best. For binary classification, accuracy is the proportion of correct predictions, but it can be misleading when one class is rare. Precision measures the proportion of predicted positives that are actually positive, while recall measures the proportion of actual positives that are detected. The appropriate trade-off depends on consequences. Missing a dangerous disease and unnecessarily testing a healthy person do not have equal costs.

For numerical prediction, mean absolute error summarizes average absolute deviation in the target’s units, while root mean squared error gives greater influence to large errors. Metrics must be selected before evaluation and interpreted in the context of the decision, population, and acceptable risk.

A Typical Machine-Learning Workflow

A responsible workflow is iterative rather than purely linear:

1. Define the problem: identify the decision, users, affected groups, time horizon, and success criteria.

2. Collect and understand data: document sources, sampling, missingness, measurement processes, and potential bias.

3. Prepare data: clean records, encode variables, handle missing values, and prevent leakage from future information.

4. Construct a baseline: compare against a simple rule or established process.

5. Select and train models: choose methods appropriate to data size, structure, interpretability, and operational constraints.

6. Validate and evaluate: use suitable splits and metrics, examine uncertainty and subgroup performance, and perform error analysis.

7. Deploy carefully: integrate the model into a human and technical workflow, with access control and failure procedures.

8. Monitor and improve: track drift, outcomes, feedback, incidents, and whether the original objective remains valid.

A model is not the entire ML system. Data pipelines, interfaces, organizational procedures, human decisions, security controls, and monitoring determine how a model behaves in practice.

Applied Case: Predicting Hospital Readmission

The following is an illustrative case, not a report of a specific hospital.

Background and problem

A regional hospital wants to identify patients who may be readmitted within 30 days of discharge. The stated purpose is to offer additional follow-up support, medication review, and appointment assistance. The hospital has five years of electronic health records, but only a subset has reliable follow-up information.

Analysis

The team defines the label as readmission within 30 days after discharge. Candidate features include age, prior admissions, diagnoses, medication count, length of stay, laboratory measurements, and documented access-to-care indicators. The team recognizes that the label is not the same as “clinical need”: readmission depends partly on discharge practices, transportation, insurance, and availability of outpatient care.

A random record-level split would be inappropriate if several admissions belong to the same patient. The team instead uses patient-level separation and performs a time-based evaluation to approximate future deployment. It establishes a simple baseline based on prior admissions before comparing more complex models.

Approach and solution

A supervised classification model is trained to estimate readmission risk. The hospital chooses a threshold based on the capacity of its follow-up team and the relative consequences of missed high-risk patients versus unnecessary interventions. Performance is assessed using recall, precision, calibration, and subgroup analysis rather than accuracy alone.

The model is not used to deny care. It generates a support list reviewed by clinicians and care coordinators. Staff receive explanations framed as relevant evidence, such as recent admissions or medication complexity, while being warned that associations are not causal conclusions. The system logs overrides and monitors whether performance changes after discharge policies or patient populations change.

Outcome

The pilot identifies some patients who benefit from additional support, but the team discovers that performance is lower for patients whose records contain fewer documented outpatient encounters. Rather than treating this as merely a modeling problem, the hospital investigates unequal documentation and access. It adds a missingness analysis, revises the workflow, and evaluates whether the intervention itself improves outcomes.

Learning points

The case illustrates that defining the target is a substantive decision; labels can encode institutional processes; evaluation design must match deployment; operational capacity affects thresholds; predictive association is not causal explanation; and fairness requires examining both model behavior and the surrounding service system. A model should be judged by whether it improves the intended decision or service, not only by an offline score.

Professional, Ethical, and Governance Considerations

ML professionals need more than algorithmic skill. They must communicate assumptions, document data provenance, reproduce experiments, manage security, and explain limitations to technical and nontechnical stakeholders. Important practices include version control, experiment tracking, clear data dictionaries, model cards or equivalent documentation, access management, and incident-response procedures.

Ethical issues include privacy, consent, surveillance, discrimination, opacity, manipulation, and unequal access to benefits. Removing sensitive attributes does not necessarily remove discrimination because other variables may act as proxies. Fairness cannot be reduced to one universal metric: different definitions can conflict, and the appropriate analysis depends on the decision, legal context, base rates, and harms.

Governance should address who is accountable, what decisions may be automated, how people can challenge outcomes, when human review is required, and how systems are retired. Data-protection and AI regulations vary by jurisdiction and application. High-impact uses may require impact assessments, transparency, records of processing, risk management, and meaningful human oversight. Compliance is not a substitute for technical quality or ethical judgment, but it provides important constraints and accountability mechanisms.

Contemporary Developments and Best Practices

Modern ML increasingly uses foundation models pretrained on broad datasets and adapted to particular tasks. These systems can reduce the need for task-specific training data, but they may inherit biases, reproduce sensitive information, generate plausible errors, and require substantial computational resources. Retrieval systems, tool use, human feedback, and multimodal learning extend capabilities while introducing additional failure modes.

Current best practice emphasizes evaluation under realistic conditions, not only benchmark performance. Teams should test robustness, subgroup outcomes, privacy and security, calibration, distribution shift, and human factors. They should prefer the simplest model that meets the requirements, use representative and legally obtained data, separate development from evaluation, define success with stakeholders, and plan monitoring before deployment. In high-stakes settings, abstention or referral to a human may be safer than forced prediction.

Chapter Summary

Artificial intelligence is the broad field of systems that perform tasks associated with intelligence. Machine learning is an AI approach that learns patterns from data, while deep learning is a machine-learning approach based largely on multilayer neural networks. Machine-learning systems depend on data, representations, objectives, algorithms, and evaluation procedures.

Supervised learning uses labeled examples; unsupervised learning seeks structure without target labels; semi-supervised learning combines labeled and unlabeled data; and reinforcement learning learns through interaction and reward. Features describe inputs, labels describe supervised targets, parameters are learned values, and hyperparameters are externally selected settings.

Prediction concerns estimating outcomes for new cases, inference concerns learning about relationships or processes, and optimization concerns selecting actions under objectives and constraints. Training performance is not sufficient: generalization, leakage prevention, realistic evaluation, distribution-shift analysis, monitoring, and human context are essential. Effective ML practice also requires attention to privacy, fairness, accountability, security, regulation, and the consequences of deploying predictions in real institutions.

Key Terms

Artificial intelligence: The field of designing computational systems that perform tasks associated with intelligence.

Machine learning: An AI approach in which systems learn useful patterns or mappings from data or interaction.

Deep learning: Machine learning based primarily on multilayer neural networks.

Feature: An input variable or measurable attribute used by a model.

Label: The target or outcome provided for a supervised-learning example.

Example: An individual observation or instance in a dataset.

Parameter: A value learned from data during model training.

Hyperparameter: A setting selected outside the parameter-learning process.

Model: A learned or specified representation that maps inputs to outputs.

Training: The process of estimating model parameters using data.

Validation set: Data used to select models or hyperparameters during development.

Test set: Data reserved for final, independent performance evaluation.

Generalization: Performance on new cases relevant to deployment.

Overfitting: Learning training-specific patterns that do not transfer well to new data.

Supervised learning: Learning from input-output pairs.

Unsupervised learning: Learning patterns from data without provided target labels.

Semi-supervised learning: Learning from both labeled and unlabeled data.

Reinforcement learning: Learning actions through interaction and reward feedback.

Prediction: Estimation of an unknown or future outcome.

Inference: Learning about relationships, parameters, or causes from evidence.

Optimization: Selecting the best feasible action or configuration according to an objective.

Review Questions

Short Answer Questions

1. Define artificial intelligence, machine learning, and deep learning, and state how they are related.

2. What is the difference between a feature and a label?

3. Distinguish a parameter from a hyperparameter.

4. Why is a test set kept separate from model development?

5. What is meant by generalization?

Long Answer Questions

1. Compare supervised, unsupervised, semi-supervised, and reinforcement learning, including a suitable application for each.

2. Explain why prediction, inference, and optimization are different objectives.

3. Describe a complete machine-learning workflow from problem definition through post-deployment monitoring.

4. Explain overfitting, underfitting, data leakage, and distribution shift.

5. Discuss the ethical and governance issues that arise when ML is used in high-impact decisions.

Analytical / Application Questions

1. A university wants to predict which students may withdraw. Propose a target definition, possible features, an evaluation design, and two risks of using historical data.

2. A fraud model has 99% accuracy, but fraud occurs in only 0.5% of transactions. Explain why accuracy may be inadequate and recommend additional evaluation considerations.

3. A hospital model performs well overall but poorly for a subgroup with sparse records. Analyze possible causes and propose technical and organizational responses.

Multiple Choice Questions with Answers

Question 1

Which statement best describes the relationship among AI, machine learning, and deep learning?

A. AI is a subset of deep learning, which is a subset of machine learning.

B. Machine learning is a subset of AI, and deep learning is a subset of machine learning.

C. Deep learning and AI are unrelated fields.

D. Machine learning includes AI, but not deep learning.

Correct Answer: B. Machine learning is a subset of AI, and deep learning is a subset of machine learning.

Question 2

In supervised learning, what is a label?

A. A learned model parameter

B. A setting chosen before training

C. The target outcome associated with an example

D. A measure of computational cost

Correct Answer: C. The target outcome associated with an example

Question 3

Which learning paradigm uses rewards from interaction with an environment?

A. Unsupervised learning

B. Supervised learning

C. Reinforcement learning

D. Batch normalization

Correct Answer: C. Reinforcement learning

Question 4

What is a hyperparameter?

A. A value learned directly from training examples

B. A setting selected outside ordinary parameter learning

C. The output label of a classifier

D. A record in the test set

Correct Answer: B. A setting selected outside ordinary parameter learning

Question 5

What is the primary purpose of a test set?

A. To fit model parameters

B. To create training labels

C. To select every hyperparameter repeatedly

D. To provide an independent final evaluation

Correct Answer: D. To provide an independent final evaluation

Question 6

A model performs extremely well on training data but poorly on new data. What is the most likely issue?

A. Overfitting

B. Underfitting

C. Clustering

D. Label encoding

Correct Answer: A. Overfitting

Question 7

Which objective asks which action should be selected under constraints?

A. Prediction

B. Optimization

C. Data labeling

D. Feature extraction

Correct Answer: B. Optimization

Question 8

Why can a record-level random split be problematic when a dataset contains multiple records for each patient?

A. It always removes all labels.

B. It can place records from the same patient in both training and test sets, causing leakage.

C. It prevents any model from being trained.

D. It converts regression into clustering.

Correct Answer: B. It can place records from the same patient in both training and test sets, causing leakage.

Question 9

Which statement about predictive association is correct?

A. A predictive feature is automatically a causal factor.

B. Prediction always establishes a mechanism.

C. A feature can improve prediction without its manipulation causing the outcome.

D. Causal inference never requires assumptions.

Correct Answer: C. A feature can improve prediction without its manipulation causing the outcome.

Question 10

A classification problem has a very rare positive class. Which evaluation approach is generally most appropriate?

A. Report accuracy alone.

B. Ignore the positive class.

C. Examine metrics such as precision, recall, calibration, and the costs of errors.

D. Use the training score as the final result.

Correct Answer: C. Examine metrics such as precision, recall, calibration, and the costs of errors.

Machine Learning Basics
Chapter 1 of 15