AI models and machine learning, for analysts

Listen to this lesson

Episode 10 · 60:24

Every episode of this course is also a podcast: listen on Spotify.

This episode is a study companion for CompTIA Data+ DA0-002 and is not produced by or endorsed by CompTIA.

Objective 1.5 · Data concepts and environments · 20% of the exam

Why this matters

Data analysts increasingly work beside machine learning: preparing the data a model is trained on, reading a model's output, or being asked whether a prediction can be trusted. Data+ does not expect you to build models, but it does expect you to recognise the main kinds, match them to the questions they answer, and understand the limits that decide whether their results are usable.

This lesson covers the learning types, the common model tasks, how models are trained and tested, what large language models are and are not good for, and how bias in data becomes bias in a model.

The lesson

Supervised, unsupervised and reinforcement learning

Artificial intelligence (AI) is the broad field of systems that perform tasks associated with human intelligence. Machine learning (ML) is the part of AI in which a system learns patterns from data rather than following rules a person wrote. Machine learning is usually divided by how it learns.

In supervised learning, the model learns from labelled examples: data where the right answer is already known. Given thousands of past loan applications labelled "repaid" or "defaulted", a model learns which features predict each outcome, then predicts the label for new applications. The known answer is called the target or label, and the inputs are features.

In unsupervised learning, there are no labels. The model looks for structure in the data on its own, such as groups of similar customers, or unusual records that differ from the rest. It is used for exploration when nobody yet knows what categories exist.

In reinforcement learning, an agent learns by trial and error, taking actions and receiving rewards or penalties, and adjusting to maximise reward over time. It is used for sequences of decisions, such as control systems and game playing, and is less common in everyday analysis.

Deep learning is machine learning using neural networks with many layers. It powers image recognition, speech and language models, and generally needs large amounts of data and computing power.

Classification, regression and clustering, and the question each answers

Most practical models do one of a few tasks, and the question being asked decides which.

Classification predicts a category. Will this customer cancel: yes or no? Is this email spam? Which of five product categories does this description belong to? It is supervised learning with a categorical target.

Regression predicts a number. What will next month's sales be? How much will this house sell for? It is supervised learning with a numeric target. (The statistical technique of linear regression, covered in domain 3, is the simplest example.)

Clustering finds groups of similar records without labels. Which segments do our customers fall into? It is unsupervised.

Related tasks include anomaly detection, finding records that do not fit the usual pattern, such as unusual transactions, and forecasting, predicting future values of a time series.

A useful exam habit is to translate a scenario into one of these. "Predict whether a machine will fail this week" is classification. "Estimate how many days until it fails" is regression. "Group machines by their usage patterns" is clustering.

Training, validation and test data, and overfitting

A supervised model is built by training it on historical data. To know whether it will work on data it has not seen, the available data is split.

  • The training set is used to fit the model.
  • The validation set is used to compare versions of the model and tune its settings.
  • The test set is held back until the end, and used once to estimate how the final model will perform on new data.

The split exists because of overfitting: a model that learns the training data too closely, including its noise and quirks, performs very well on that data and poorly on anything new. A model with 99% accuracy on its training data and 70% on the test set has memorised rather than learned. The opposite problem, underfitting, is a model too simple to capture the real pattern, which performs poorly everywhere.

Model quality is measured with metrics suited to the task. For classification, accuracy alone can mislead: if only 2% of transactions are fraudulent, a model that predicts "not fraud" every time is 98% accurate and useless. Measures such as precision (of those flagged, how many were right) and recall (of the real cases, how many were caught) show what accuracy hides.

Large language models and generative AI, and what they cannot be trusted with

Generative AI produces new content such as text, images or code. Large language models (LLMs) are generative models trained on very large amounts of text to predict likely next words, which lets them answer questions, summarise, translate and write code.

For analysts, LLMs can help draft queries and code, explain an unfamiliar function, summarise long text such as survey comments, and suggest approaches. They also have limits that matter in data work.

  • They can hallucinate: produce confident, fluent statements, figures or references that are false.
  • They do not reliably calculate: arithmetic and counting over data should be done by code or a database, not by a model's text.
  • Their knowledge has a cutoff and may be out of date.
  • Data typed into a public tool may be stored or used by its provider, so sensitive or personal data must not be pasted into one without approval.

The working rule is that LLM output is a draft to be checked, never a source. A query an LLM wrote must be read and tested like any other, and a number it states must be verified against the data.

Bias in training data, and why a model inherits it

A model learns whatever patterns its training data contains, including unfair or unrepresentative ones. This is bias, and it enters in several ways.

Sampling bias occurs when the training data does not represent the population the model will be used on, such as a model trained mostly on one region's customers. Historical bias occurs when the data faithfully records past decisions that were themselves unfair, such as past hiring or lending patterns, so the model learns to repeat them. Label bias occurs when the labels reflect human judgement that was inconsistent or prejudiced. And proxy variables can reintroduce a characteristic that was deliberately removed: a postcode can stand in for ethnicity or income.

The consequences can be serious, especially in lending, hiring, insurance and healthcare, where regulations may apply. Guarding against bias starts with the data: check that it represents the population, look at model performance separately for different groups, question features that could act as proxies, and document the model's data, limitations and intended use so others can judge whether to rely on it.

Practise what you just read

1. A model must predict whether each machine will fail within the next week. Which kind of task is this?

Select one

  1. Regression, because failure is measured in days
  2. Reinforcement learning, because the machines improve
  3. Clustering, because machines fall into groups
  4. Classification, because the answer is a category
Show answer

D. Will it fail this week, yes or no, is a category, so the task is classification. Estimating how many days until failure would be regression, and grouping machines by usage without labels would be clustering.

2. A model scores 99% accuracy on its training data and 70% on the held-back test set. What does this indicate?

Select one

  1. Data leakage: the test set was used for training
  2. Nothing: a gap that size shows the model is sound
  3. Overfitting: it memorised the training data's noise
  4. Underfitting: it is far too simple to learn the pattern
Show answer

C. A model that learns its training data too closely, quirks included, performs very well on that data and poorly on new data. The large gap between training and test performance is the signature of overfitting.

3. Only 2% of transactions are fraudulent. A model predicts not fraud for every transaction. What are its accuracy and its recall?

Select one

  1. 98% accuracy and 0% recall: it catches no fraud at all
  2. 2% accuracy and 100% recall: it labels normal sales as fraud
  3. 50% accuracy and 50% recall: it is no better than chance
  4. 98% accuracy and 98% recall: it is right on most rows
Show answer

A. Predicting the majority class every time is right for 98% of transactions, but recall asks how many real fraud cases were caught, and the answer is none. Accuracy alone hides that on imbalanced data.

7 more questions on this objective are part of the full course.

Practise the full question bank in the exam simulator

Hands-on labs

All hands-on labs

This is an independent study companion for CompTIA Data+ DA0-002 and is not produced by or endorsed by CompTIA.