EASYTUTORGUIDE

Practical tutorials, tools, courses, digital skills, and business promotion.

Free Learning
Google Translate

Chapter 17: Supervised Learning Fundamentals

Learn Machine Learning from very beginner to expert with detailed topic guidance, practical examples, practice exercises, and review questions.

Beginner FriendlyExamplesPracticeExpert Topics
Estimated reading time0% read

What this chapter covers

This chapter contains 13 topics. Technical terms are followed by plain-language meanings in parentheses where they first appear. Code is included only when it naturally helps demonstrate the concept; architecture, workflow, governance, and comparison topics use practical scenarios instead.

17.1 Labeled Data

Labeled Data (a practical concept used within supervised learning, evaluation, and ensemble methods). Within Chapter 17, this topic connects directly to supervised learning, evaluation, and ensemble methods. The important goal is to understand what information goes into the method, what transformation or decision happens, and what output should be checked.

When using this idea, separate training data from evaluation data and compare performance on examples the model did not train on. Pay attention to assumptions, important settings, error patterns, and whether the method is appropriate for classification, regression, ranking, or probability estimation.

Example

Imagine a small machine-learning project. Use Labeled Data to decide what information is needed, what step happens next, and what result should be checked.

Coding example

// Labeled Data
const records = [3, 5, 7, 9, 11];
const transform = value => ({ input: value, output: value * 2 + 1 });
const results = records.map(transform);

console.log(results);

Code explanation

  1. The sample starts with a small list of inputs so every result can be checked manually.
  2. `transform()` represents the main operation for this topic in a deliberately simple form.
  3. `map()` applies the same rule consistently to every item and returns a new result array.
  4. Use this pattern to focus on input, transformation, and output before replacing the toy rule with a more advanced method.

Expected result: A transformed result is printed for each input value.

Practice exercise

Create a small real-world example for Labeled Data. Write the input, the goal, the main steps, and the result you would check. Then list one limitation or mistake a beginner should watch for.

17.2 Features

Features (an input value or measurable property given to a model). Within Chapter 17, this topic connects directly to supervised learning, evaluation, and ensemble methods. The important goal is to understand what information goes into the method, what transformation or decision happens, and what output should be checked.

When using this idea, separate training data from evaluation data and compare performance on examples the model did not train on. Pay attention to assumptions, important settings, error patterns, and whether the method is appropriate for classification, regression, ranking, or probability estimation.

Example

Imagine a small machine-learning project. Use Features to decide what information is needed, what step happens next, and what result should be checked.

Coding example

// Features
const rows = [
  { age: 22, score: 71 },
  { age: null, score: 88 },
  { age: 35, score: 93 }
];

const knownAges = rows.filter(r => r.age !== null).map(r => r.age);
const fallbackAge = knownAges.reduce((a,b) => a+b, 0) / knownAges.length;
const cleaned = rows.map(r => ({ ...r, age: r.age ?? fallbackAge }));

console.log(cleaned);

Code explanation

  1. The sample rows deliberately contain one missing value so you can see a preprocessing decision.
  2. Known ages are separated and averaged to create a simple fallback value.
  3. `map()` builds a new cleaned dataset instead of modifying the original rows in place.
  4. The final log lets you verify that every row now has a usable numeric age.

Expected result: A cleaned array is printed with the missing age filled.

Practice exercise

Create a small real-world example for Features. Write the input, the goal, the main steps, and the result you would check. Then list one limitation or mistake a beginner should watch for.

17.3 Targets

Targets (the value or class a supervised model is trained to predict). Within Chapter 17, this topic connects directly to supervised learning, evaluation, and ensemble methods. The important goal is to understand what information goes into the method, what transformation or decision happens, and what output should be checked.

When using this idea, separate training data from evaluation data and compare performance on examples the model did not train on. Pay attention to assumptions, important settings, error patterns, and whether the method is appropriate for classification, regression, ranking, or probability estimation.

Example

Imagine a small machine-learning project. Use Targets to decide what information is needed, what step happens next, and what result should be checked.

Coding example

// Targets
const records = [3, 5, 7, 9, 11];
const transform = value => ({ input: value, output: value * 2 + 1 });
const results = records.map(transform);

console.log(results);

Code explanation

  1. The sample starts with a small list of inputs so every result can be checked manually.
  2. `transform()` represents the main operation for this topic in a deliberately simple form.
  3. `map()` applies the same rule consistently to every item and returns a new result array.
  4. Use this pattern to focus on input, transformation, and output before replacing the toy rule with a more advanced method.

Expected result: A transformed result is printed for each input value.

Practice exercise

Create a small real-world example for Targets. Write the input, the goal, the main steps, and the result you would check. Then list one limitation or mistake a beginner should watch for.

17.4 Classification

Classification (predicting a category or class). Within Chapter 17, this topic connects directly to supervised learning, evaluation, and ensemble methods. The important goal is to understand what information goes into the method, what transformation or decision happens, and what output should be checked.

When using this idea, separate training data from evaluation data and compare performance on examples the model did not train on. Pay attention to assumptions, important settings, error patterns, and whether the method is appropriate for classification, regression, ranking, or probability estimation.

Example

An email filter receives a new message and decides whether it belongs to the 'spam' class or the 'not spam' class.

Coding example

// Classification
const sigmoid = z => 1 / (1 + Math.exp(-z));
const weights = [0.8, -0.4];
const features = [2, 1];
const bias = -0.2;
const score = weights.reduce((sum, w, i) => sum + w * features[i], bias);
const probability = sigmoid(score);
const predictedClass = probability >= 0.5 ? 1 : 0;

console.log({ probability: probability.toFixed(3), predictedClass });

Code explanation

  1. `weights`, `features`, and `bias` create a simple linear score.
  2. The sigmoid function converts any score into a value between 0 and 1.
  3. A threshold of 0.5 turns the probability into a class label.
  4. Printing both values helps you distinguish a model score from the final classification decision.

Expected result: A probability and a predicted class are printed.

Practice exercise

Create a second example for Classification. Change one important condition or input, predict how the result should change, and explain why. Then identify one limitation or common mistake a beginner should watch for.

17.5 Regression

Regression (predicting a continuous numerical value). Within Chapter 17, this topic connects directly to supervised learning, evaluation, and ensemble methods. The important goal is to understand what information goes into the method, what transformation or decision happens, and what output should be checked.

When using this idea, separate training data from evaluation data and compare performance on examples the model did not train on. Pay attention to assumptions, important settings, error patterns, and whether the method is appropriate for classification, regression, ranking, or probability estimation.

Example

Imagine a small machine-learning project. Use Regression to decide what information is needed, what step happens next, and what result should be checked.

Coding example

// Regression
const records = [3, 5, 7, 9, 11];
const transform = value => ({ input: value, output: value * 2 + 1 });
const results = records.map(transform);

console.log(results);

Code explanation

  1. The sample starts with a small list of inputs so every result can be checked manually.
  2. `transform()` represents the main operation for this topic in a deliberately simple form.
  3. `map()` applies the same rule consistently to every item and returns a new result array.
  4. Use this pattern to focus on input, transformation, and output before replacing the toy rule with a more advanced method.

Expected result: A transformed result is printed for each input value.

Practice exercise

Create a small real-world example for Regression. Write the input, the goal, the main steps, and the result you would check. Then list one limitation or mistake a beginner should watch for.

17.6 Training a Model

Training a Model (the process of learning model parameters from data). Within Chapter 17, this topic connects directly to supervised learning, evaluation, and ensemble methods. The important goal is to understand what information goes into the method, what transformation or decision happens, and what output should be checked.

When using this idea, separate training data from evaluation data and compare performance on examples the model did not train on. Pay attention to assumptions, important settings, error patterns, and whether the method is appropriate for classification, regression, ranking, or probability estimation.

Example

Imagine a small machine-learning project. Use Training a Model to decide what information is needed, what step happens next, and what result should be checked.

Coding example

// Training a Model
const records = [3, 5, 7, 9, 11];
const transform = value => ({ input: value, output: value * 2 + 1 });
const results = records.map(transform);

console.log(results);

Code explanation

  1. The sample starts with a small list of inputs so every result can be checked manually.
  2. `transform()` represents the main operation for this topic in a deliberately simple form.
  3. `map()` applies the same rule consistently to every item and returns a new result array.
  4. Use this pattern to focus on input, transformation, and output before replacing the toy rule with a more advanced method.

Expected result: A transformed result is printed for each input value.

Practice exercise

Create a small real-world example for Training a Model. Write the input, the goal, the main steps, and the result you would check. Then list one limitation or mistake a beginner should watch for.

17.7 Making Predictions

Making Predictions (the output produced by a trained model for new input). Within Chapter 17, this topic connects directly to supervised learning, evaluation, and ensemble methods. The important goal is to understand what information goes into the method, what transformation or decision happens, and what output should be checked.

When using this idea, separate training data from evaluation data and compare performance on examples the model did not train on. Pay attention to assumptions, important settings, error patterns, and whether the method is appropriate for classification, regression, ranking, or probability estimation.

Example

A model first learns from past houses with known prices. After training, it receives a new house description and produces a predicted price.

Coding example

// Making Predictions
const records = [3, 5, 7, 9, 11];
const transform = value => ({ input: value, output: value * 2 + 1 });
const results = records.map(transform);

console.log(results);

Code explanation

  1. The sample starts with a small list of inputs so every result can be checked manually.
  2. `transform()` represents the main operation for this topic in a deliberately simple form.
  3. `map()` applies the same rule consistently to every item and returns a new result array.
  4. Use this pattern to focus on input, transformation, and output before replacing the toy rule with a more advanced method.

Expected result: A transformed result is printed for each input value.

Practice exercise

Create a second example for Making Predictions. Change one important condition or input, predict how the result should change, and explain why. Then identify one limitation or common mistake a beginner should watch for.

17.8 Loss Functions

Loss Functions (a numerical measure of how wrong a model prediction is). Within Chapter 17, this topic connects directly to supervised learning, evaluation, and ensemble methods. The important goal is to understand what information goes into the method, what transformation or decision happens, and what output should be checked.

When using this idea, separate training data from evaluation data and compare performance on examples the model did not train on. Pay attention to assumptions, important settings, error patterns, and whether the method is appropriate for classification, regression, ranking, or probability estimation.

Example

Imagine a small machine-learning project. Use Loss Functions to decide what information is needed, what step happens next, and what result should be checked.

Coding example

// Loss Functions
const records = [3, 5, 7, 9, 11];
const transform = value => ({ input: value, output: value * 2 + 1 });
const results = records.map(transform);

console.log(results);

Code explanation

  1. The sample starts with a small list of inputs so every result can be checked manually.
  2. `transform()` represents the main operation for this topic in a deliberately simple form.
  3. `map()` applies the same rule consistently to every item and returns a new result array.
  4. Use this pattern to focus on input, transformation, and output before replacing the toy rule with a more advanced method.

Expected result: A transformed result is printed for each input value.

Practice exercise

Create a small real-world example for Loss Functions. Write the input, the goal, the main steps, and the result you would check. Then list one limitation or mistake a beginner should watch for.

17.9 Generalization

Generalization (a practical concept used within supervised learning, evaluation, and ensemble methods). Within Chapter 17, this topic connects directly to supervised learning, evaluation, and ensemble methods. The important goal is to understand what information goes into the method, what transformation or decision happens, and what output should be checked.

When using this idea, separate training data from evaluation data and compare performance on examples the model did not train on. Pay attention to assumptions, important settings, error patterns, and whether the method is appropriate for classification, regression, ranking, or probability estimation.

Example

Imagine a small machine-learning project. Use Generalization to decide what information is needed, what step happens next, and what result should be checked.

Coding example

// Generalization
const records = [3, 5, 7, 9, 11];
const transform = value => ({ input: value, output: value * 2 + 1 });
const results = records.map(transform);

console.log(results);

Code explanation

  1. The sample starts with a small list of inputs so every result can be checked manually.
  2. `transform()` represents the main operation for this topic in a deliberately simple form.
  3. `map()` applies the same rule consistently to every item and returns a new result array.
  4. Use this pattern to focus on input, transformation, and output before replacing the toy rule with a more advanced method.

Expected result: A transformed result is printed for each input value.

Practice exercise

Create a small real-world example for Generalization. Write the input, the goal, the main steps, and the result you would check. Then list one limitation or mistake a beginner should watch for.

17.10 Bias

Bias (a practical concept used within supervised learning, evaluation, and ensemble methods). Within Chapter 17, this topic connects directly to supervised learning, evaluation, and ensemble methods. The important goal is to understand what information goes into the method, what transformation or decision happens, and what output should be checked.

When using this idea, separate training data from evaluation data and compare performance on examples the model did not train on. Pay attention to assumptions, important settings, error patterns, and whether the method is appropriate for classification, regression, ranking, or probability estimation.

Example

Imagine a small machine-learning project. Use Bias to decide what information is needed, what step happens next, and what result should be checked.

Coding example

// Bias
const records = [
  { group:'A', correct:true }, { group:'A', correct:false },
  { group:'B', correct:true }, { group:'B', correct:true }
];
const rate = group => {
  const rows = records.filter(r=>r.group===group);
  return rows.filter(r=>r.correct).length / rows.length;
};
const gap = Math.abs(rate('A') - rate('B'));
console.log({ groupA: rate('A'), groupB: rate('B'), gap });

Code explanation

  1. The example uses only small aggregate outcomes and does not expose personal information.
  2. `rate()` calculates the same quality measure separately for two groups.
  3. The absolute difference highlights a disparity that should be investigated rather than automatically accepted.
  4. For security-related topics, this defensive pattern emphasizes measurement, validation, and safer review instead of demonstrating attack procedures.

Expected result: Two group performance rates and their difference are printed.

Practice exercise

Create a small real-world example for Bias. Write the input, the goal, the main steps, and the result you would check. Then list one limitation or mistake a beginner should watch for.

17.11 Variance

Variance (a measure of how spread out values are). Within Chapter 17, this topic connects directly to supervised learning, evaluation, and ensemble methods. The important goal is to understand what information goes into the method, what transformation or decision happens, and what output should be checked.

When using this idea, separate training data from evaluation data and compare performance on examples the model did not train on. Pay attention to assumptions, important settings, error patterns, and whether the method is appropriate for classification, regression, ranking, or probability estimation.

Example

Imagine a small machine-learning project. Use Variance to decide what information is needed, what step happens next, and what result should be checked.

Coding example

// Variance
const values = [12, 15, 11, 18, 14, 16];
const mean = values.reduce((sum, x) => sum + x, 0) / values.length;
const variance = values.reduce((sum, x) => sum + (x - mean) ** 2, 0) / values.length;
const std = Math.sqrt(variance);

console.log({ mean: mean.toFixed(2), std: std.toFixed(2) });

Code explanation

  1. `values` is a tiny dataset that can be checked manually.
  2. The mean is the total divided by the number of observations.
  3. Variance measures average squared distance from the mean, and the square root of variance gives standard deviation.
  4. These summary values help you understand the scale and spread of data before choosing or evaluating a model.

Expected result: The mean and standard deviation are printed.

Practice exercise

Create a small real-world example for Variance. Write the input, the goal, the main steps, and the result you would check. Then list one limitation or mistake a beginner should watch for.

17.12 Underfitting

Underfitting (a practical concept used within supervised learning, evaluation, and ensemble methods). Within Chapter 17, this topic connects directly to supervised learning, evaluation, and ensemble methods. The important goal is to understand what information goes into the method, what transformation or decision happens, and what output should be checked.

When using this idea, separate training data from evaluation data and compare performance on examples the model did not train on. Pay attention to assumptions, important settings, error patterns, and whether the method is appropriate for classification, regression, ranking, or probability estimation.

Example

Imagine a small machine-learning project. Use Underfitting to decide what information is needed, what step happens next, and what result should be checked.

Coding example

// Underfitting
const records = [3, 5, 7, 9, 11];
const transform = value => ({ input: value, output: value * 2 + 1 });
const results = records.map(transform);

console.log(results);

Code explanation

  1. The sample starts with a small list of inputs so every result can be checked manually.
  2. `transform()` represents the main operation for this topic in a deliberately simple form.
  3. `map()` applies the same rule consistently to every item and returns a new result array.
  4. Use this pattern to focus on input, transformation, and output before replacing the toy rule with a more advanced method.

Expected result: A transformed result is printed for each input value.

Practice exercise

Create a small real-world example for Underfitting. Write the input, the goal, the main steps, and the result you would check. Then list one limitation or mistake a beginner should watch for.

17.13 Overfitting

Overfitting (a practical concept used within supervised learning, evaluation, and ensemble methods). Within Chapter 17, this topic connects directly to supervised learning, evaluation, and ensemble methods. The important goal is to understand what information goes into the method, what transformation or decision happens, and what output should be checked.

When using this idea, separate training data from evaluation data and compare performance on examples the model did not train on. Pay attention to assumptions, important settings, error patterns, and whether the method is appropriate for classification, regression, ranking, or probability estimation.

Example

Imagine a small machine-learning project. Use Overfitting to decide what information is needed, what step happens next, and what result should be checked.

Coding example

// Overfitting
const records = [3, 5, 7, 9, 11];
const transform = value => ({ input: value, output: value * 2 + 1 });
const results = records.map(transform);

console.log(results);

Code explanation

  1. The sample starts with a small list of inputs so every result can be checked manually.
  2. `transform()` represents the main operation for this topic in a deliberately simple form.
  3. `map()` applies the same rule consistently to every item and returns a new result array.
  4. Use this pattern to focus on input, transformation, and output before replacing the toy rule with a more advanced method.

Expected result: A transformed result is printed for each input value.

Practice exercise

Create a small real-world example for Overfitting. Write the input, the goal, the main steps, and the result you would check. Then list one limitation or mistake a beginner should watch for.

Chapter 17 Review Questions and Answers

Q1. What is Labeled Data?

Answer: Labeled Data is a practical concept used within supervised learning, evaluation, and ensemble methods. In this chapter, focus on the input, the method or decision, and the result that should be checked.

Q2. What is Features?

Answer: Features is an input value or measurable property given to a model. In this chapter, focus on the input, the method or decision, and the result that should be checked.

Q3. What is Targets?

Answer: Targets is the value or class a supervised model is trained to predict. In this chapter, focus on the input, the method or decision, and the result that should be checked.

Q4. What is Classification?

Answer: Classification is predicting a category or class. In this chapter, focus on the input, the method or decision, and the result that should be checked.

Q5. What is Regression?

Answer: Regression is predicting a continuous numerical value. In this chapter, focus on the input, the method or decision, and the result that should be checked.

Q6. What is Training a Model?

Answer: Training a Model is the process of learning model parameters from data. In this chapter, focus on the input, the method or decision, and the result that should be checked.

Q7. What is Making Predictions?

Answer: Making Predictions is the output produced by a trained model for new input. In this chapter, focus on the input, the method or decision, and the result that should be checked.

Q8. What is Loss Functions?

Answer: Loss Functions is a numerical measure of how wrong a model prediction is. In this chapter, focus on the input, the method or decision, and the result that should be checked.

Q9. What is Generalization?

Answer: Generalization is a practical concept used within supervised learning, evaluation, and ensemble methods. In this chapter, focus on the input, the method or decision, and the result that should be checked.

Q10. What is Bias?

Answer: Bias is a practical concept used within supervised learning, evaluation, and ensemble methods. In this chapter, focus on the input, the method or decision, and the result that should be checked.

Q11. What is Variance?

Answer: Variance is a measure of how spread out values are. In this chapter, focus on the input, the method or decision, and the result that should be checked.

Q12. What is Underfitting?

Answer: Underfitting is a practical concept used within supervised learning, evaluation, and ensemble methods. In this chapter, focus on the input, the method or decision, and the result that should be checked.

Q13. What is Overfitting?

Answer: Overfitting is a practical concept used within supervised learning, evaluation, and ensemble methods. In this chapter, focus on the input, the method or decision, and the result that should be checked.