Back to homeAP® Computer Science Principles · AP Computer Science Principles · Change subject
Start for free
AP CSP · AP® Computer Science Principles
Computer systems · Emerging technologies

Artificial intelligence and big data

When your email app drops a scam message into the spam folder, it is not checking a written list of suspicious phrases, word for word: it has learned to recognize them from millions of emails that were already classified. That is the fundamental difference between programming a system and training it, and it is the basis of the artificial intelligence you use every day without seeing it. By the end of this page you will see how that spam filter works, and why it can still make mistakes.

From rules to data: machine learning

Comparison of the flows in traditional programming (the rules written by a person produce the output) and machine learning (the example data produce a model that generates predictions). Traditional programming rules (person) output Machine learning example data model prediction

The pipeline of a machine learning system

Every ML system follows the same steps, whether it recommends bus routes or filters spam.

Pipeline of a machine learning system: data collection, data preparation, training, model, and predictions. collect data clean data training model prediction

The training block receives clean, prepared example data (for a bus-route system: past trips, times, and delays) and adjusts the model's parameters. Then the model is used on new data to make predictions.

Neural networks

An artificial neural network is a model made of layers of simple units called "neurons." Each neuron multiplies its inputs by weights, adds them up, and passes the result to the next layer. Think of a mixing board: each slider (weight) controls how much one input matters.

Practice★☆☆Not started
Explain in your own words the difference between traditional programming (rules written by a person) and machine learning (rules learned from examples), and give an…

Explain in your own words the difference between traditional programming (rules written by a person) and machine learning (rules learned from examples), and give an application where each approach is more suitable.

Solve
Practice★☆☆Not started
The figure shows the pipeline of a machine learning system that recommends bus routes, but one of its blocks is covered. Indicate which block is missing, what happens…

The figure shows the pipeline of a machine learning system that recommends bus routes, but one of its blocks is covered. Indicate which block is missing, what happens inside it, and what data it needs to receive from the previous block.

data historical trips, traffic, schedules ? model learned patterns prediction route and time estimated actual results feed into new data
Solve
Practice★☆☆Not started
Explain what a "model" is in machine learning (the patterns and parameters learned from data) and the difference between training it and using it (inference). Why does…

Explain what a "model" is in machine learning (the patterns and parameters learned from data) and the difference between training it and using it (inference). Why does training require much more computing power than using it?

Solve
Practice★☆☆Not started
Explain with a simple analogy what an artificial neural network is: layers of 'neurons' that combine inputs with adjustable weights. What is adjusted during training and…

Explain with a simple analogy what an artificial neural network is: layers of 'neurons' that combine inputs with adjustable weights. What is adjusted during training and what does it mean for the network to 'learn'?

Solve
Practice★☆☆Not started
Order these three terms from most general to most specific: deep learning, artificial intelligence, machine learning. Explain the inclusion relationship between them…

Order these three terms from most general to most specific: deep learning, artificial intelligence, machine learning. Explain the inclusion relationship between them with an example of each level.

Solve

Types of learning: supervised, unsupervised and reinforcement

Diagram of the three types of machine learning: supervised with labeled data (spam and not spam), unsupervised with points that group together without a label, and reinforcement, where an agent acts on an environment and receives a reward. supervised spam not spam with label unsupervised groups without label reinforcement agent environment action reward

Choosing input variables (features)

The features are the input variables the model uses. Feature engineering means choosing and building good features, and it often matters more than the algorithm itself.

Practice★☆☆Not started
In supervised learning, what is the label of a data point? Give three examples of labeled datasets (photo → cat/dog, email → spam/not spam, sensor → healthy/faulty) and…

In supervised learning, what is the label of a data point? Give three examples of labeled datasets (photo → cat/dog, email → spam/not spam, sensor → healthy/faulty) and explain who usually produces the labels and what cost it entails.

Solve
Practice★★☆Not started
Explain the difference between supervised, unsupervised, and reinforcement learning, and classify these applications: a spam filter trained with labeled emails, customer…

Explain the difference between supervised, unsupervised, and reinforcement learning, and classify these applications: a spam filter trained with labeled emails, customer segmentation by buying habits without labels, and a robot learning to walk by trial and error.

Solve
Practice★★☆Not started
To predict a building's electricity consumption, propose at least six input variables (outdoor temperature, time of day, weekday or holiday, occupancy, previous day's…

To predict a building's electricity consumption, propose at least six input variables (outdoor temperature, time of day, weekday or holiday, occupancy, previous day's history, solar radiation) and justify each one. Explain what feature engineering is and why it often has a greater impact than the chosen algorithm.

Solve
Practice★★☆Not started
Distinguish between a classification problem (predicting a category) and a regression problem (predicting a number). Classify these tasks: estimating the price of a…

Distinguish between a classification problem (predicting a category) and a regression problem (predicting a number). Classify these tasks: estimating the price of a house, deciding whether an X-ray shows a fracture, predicting tomorrow's temperature, and grouping news articles by topic.

Solve

Evaluating a model: overfitting and the confusion matrix

Two-by-two confusion matrix comparing reality with the model's prediction: true negatives and true positives (correct predictions, in green) and false positives and false negatives (errors, in pink). confusion matrix model's prediction negative positive reality negative positive true negative false positive false negative true positive green: correct · pink: error

Precision, recall, and cross-validation

A single train/test split can be "lucky" or "unlucky" depending on which examples land in the test set. Cross-validation splits the data into several parts and rotates which part is used for testing, then averages the results. It gives a more reliable estimate of the true error, especially when data is scarce.

When the cost of a miss is high, lowering the decision threshold catches more positives (fewer false negatives) at the price of more false alarms.

Practice★★☆Not started
A system learns with $80\,\%$ of the data and is evaluated with the remaining $20\,\%$. Explain what the training set and test set are, what overfitting is, and how it…

A system learns with $80\,\%$ of the data and is evaluated with the remaining $20\,\%$. Explain what the training set and test set are, what overfitting is, and how it is detected by comparing errors in both sets.

Solve
Practice★★☆Not started
A fault classifier evaluated on $200$ machines yields the confusion matrix shown in the figure. a) Calculate the precision ($\frac{VP}{VP + FP}$) and recall or…

A fault classifier evaluated on $200$ machines yields the confusion matrix shown in the figure. a) Calculate the precision ($\frac{VP}{VP + FP}$) and recall or sensitivity ($\frac{VP}{VP + FN}$). b) Explain which error is more serious in maintenance (a false negative: an undetected fault) and how you would change the model threshold to reduce it at the expense of more false alarms.

predicts healthy predicts faulty actually healthy actually faulty 140 true negatives 18 false positives 6 false negatives 36 true positives
Solve
Practice★★☆Not started
Explain what cross-validation is (dividing the data into several parts and rotating which one is used for testing) and what problem it solves when data is scarce: why…

Explain what cross-validation is (dividing the data into several parts and rotating which one is used for testing) and what problem it solves when data is scarce: why can a single train/test split yield a "lucky" or "unlucky" estimate of the true error?

Solve
Practice★★☆Not started
In bank fraud detection, only one in a thousand transactions is fraudulent. Explain what an imbalanced dataset is, why a model that classifies everything as 'legitimate'…

In bank fraud detection, only one in a thousand transactions is fraudulent. Explain what an imbalanced dataset is, why a model that classifies everything as 'legitimate' achieves $99.9\,\%$ accuracy and is completely useless, and what metrics and techniques are used instead (recall, oversampling the minority class, class weighting).

Solve

Big data: volume, velocity, variety and their cost

The three Vs of big data: a huge database with billions of rows (volume), a clock and a stream of data packets that arrive non-stop (velocity), and a text document, an image and a sensor as different formats (variety). volume billions of rows velocity data every second variety text, image, sensor
Practice★☆☆Not started
Define "big data" and explain the three classic "Vs" (volume, velocity, and variety) with an example of each in the context of an urban transportation app.

Define "big data" and explain the three classic "Vs" (volume, velocity, and variety) with an example of each in the context of an urban transportation app.

Solve
Practice★☆☆Not started
Name five everyday services that use machine learning today (maps and traffic, translators, video recommenders, voice assistants, spam filters) and state for each one…

Name five everyday services that use machine learning today (maps and traffic, translators, video recommenders, voice assistants, spam filters) and state for each one what input data the model uses.

Solve
Practice★★☆Not started
A city council installs traffic sensors at $200$ intersections that send a reading every $5$ seconds. a) Estimate the number of readings generated per day and per year.…

A city council installs traffic sensors at $200$ intersections that send a reading every $5$ seconds. a) Estimate the number of readings generated per day and per year. b) Explain what storage and processing problems they pose and why conventional single-server databases might fall short.

Solve
Practice★★★Not started
A tech company decides to train its own 70-billion-parameter language model from scratch in a data center connected to a grid with an emission factor of 0.26 kg CO₂/kWh.…

A tech company decides to train its own 70-billion-parameter language model from scratch in a data center connected to a grid with an emission factor of 0.26 kg CO₂/kWh. The training process requires 1.5 GWh of electrical energy. Once deployed, the service is estimated to handle 20 million queries per day, consuming an additional 0.5 GWh per month during the inference phase.

  1. a) Analyze the three lifecycle phases of this AI system that contribute to its environmental footprint and justify why, over one year of operation, the impact of daily inference can significantly exceed that of the initial training.
  2. b) Calculate the mass of CO₂ (in metric tons) emitted solely during the training phase and compare it with the emissions generated by the first full year of inference.
  3. c) Design three technical engineering measures (at the level of model architecture, weight reuse, and infrastructure selection) that drastically reduce energy consumption without unacceptably degrading the quality of the responses.
Solve

Bias, black boxes, and designing responsibly

Model bias comes from the training data (who is represented, how labels were created) and from design choices. Always evaluate the source, quality, and representativeness of the data.

For example, a face-recognition model trained mostly on photos of light-skinned adults from one region will make more mistakes on everyone else. The data was not representative, so the model's errors are not spread fairly. Before training, ask: Who is in this data? Who is missing? Who made the labels, and how?

A black box model (like a deep neural network) can be very accurate but impossible to explain. An interpretable model (like a decision tree) is less accurate but auditable. In medicine, you weigh accuracy against the need to explain and justify decisions to patients.

Practice★★★Not started
A technology company trains a machine learning model to screen resumes of applicants for engineering positions. To avoid discriminatory bias based on socioeconomic…

A technology company trains a machine learning model to screen resumes of applicants for engineering positions. To avoid discriminatory bias based on socioeconomic background, the team excludes the ZIP code, neighborhood of residence, and nationality from the data. However, during the testing phase, it is detected that candidates from low-income districts are rejected at a rate 73.5 % higher than those from high-income districts with equivalent academic profiles.

  1. a) Technically justify how the model could have inferred socioeconomic background despite having removed direct geographic variables, proposing at least two common variables on a resume that act as proxy variables (proxies).
  2. b) Analyze the ethical and legal implications of this outcome in accordance with U.S. artificial intelligence and anti-discrimination regulations (risk classification and principle of non-discrimination).
  3. c) Design a pre-deployment algorithmic audit that includes a quantitative fairness metric (fairness) and a mitigation technique to correct the bias.
Solve
Practice★★★Not started
Design at a conceptual level a predictive maintenance system for a city's fleet of boilers: what sensors and data you would collect, what labels supervised learning…

Design at a conceptual level a predictive maintenance system for a city's fleet of boilers: what sensors and data you would collect, what labels supervised learning would require, how you would validate the model, and what decision the system would take upon predicting an imminent breakdown.

Solve
Practice★★★Not started
In a hospital, two artificial intelligence systems are being evaluated to support emergency triage and stroke detection from neuroimaging: System Alpha: Deep neural…

In a hospital, two artificial intelligence systems are being evaluated to support emergency triage and stroke detection from neuroimaging:

  • System Alpha: Deep neural network with an overall accuracy rate of 97.4 %, but whose internal decision-making process is an uninterpretable mathematical black box.

  • System Beta: Decision tree based on structured clinical rules with an accuracy rate of 89.6 %, fully transparent and auditable step-by-step by specialists.

  1. a) Justify the ethical and deontological dilemma faced by medical staff when choosing one of the systems: is it acceptable to use a model with a lower accuracy rate if it allows understanding the clinical causes of each diagnosis?
  2. b) Analyze the demands posed by patient and health legislation (such as HIPAA and informed consent requirements) regarding the right to an understandable explanation and the assignment of liability in the event of a misdiagnosis.
  3. c) Design a technological compromise proposal that combines the high performance of System Alpha with the interpretability guarantees of System Beta, justifying the inclusion of post hoc explainability methods (such as attribution heatmaps) and a mandatory human oversight protocol (human-in-the-loop).
Solve
Practice★★★Not started
A city council's public safety department commissions a technical team to develop a machine learning system to "predict which neighborhoods will suffer more criminal…

A city council's public safety department commissions a technical team to develop a machine learning system to "predict which neighborhoods will suffer more criminal incidents next year" and thus distribute patrols. The model will be trained using the geolocated record of police reports and arrests from the last four years.

  1. a) Critically argue why using records of reports and police interventions as the target variable introduces a systematic measurement bias with respect to the actual criminality in the city.
  2. b) Model the closed-loop dynamic (self-fulfilling prophecy) that the deployment of this algorithm will cause: predict how the collected data will evolve after sending more patrols to the neighborhoods flagged in the first iteration, and what effect this will have on retraining the model.
  3. c) Design an alternative proposal for the city council that leverages data science not for anticipatory punitive patrolling, but to identify needs for preventive social intervention, investment in street lighting, or reinforcement of public services in vulnerable areas.
Solve

Summary

See all the exercises in this section