Computer Science
How AI Works
Machine learning, training data, and how AI makes predictions
Related Tools
Related Labs
Related Worksheets
Artificial intelligence is software that learns patterns from data and uses those patterns to make predictions, classify information, generate content, or choose actions. It matters because AI systems now help filter spam, recommend videos, translate languages, detect disease, and control robots. At the center of many modern AI systems is a model, which is a mathematical function with adjustable parameters. Training changes those parameters so the model becomes better at a task.
Key Facts
- A basic AI model can be written as y = f(x; theta), where x is the input, y is the output, and theta represents learned parameters.
- Training data contains examples that teach the model, such as image pixels paired with labels like cat or dog.
- A loss function measures error, such as mean squared error: L = (1/n) sum(yi - yhat_i)^2.
- Gradient descent updates parameters using theta_new = theta_old - alpha grad L, where alpha is the learning rate.
- Neural networks pass information through layers using weighted sums, activations, and connections between nodes.
- AI performance must be tested on new data because memorizing training examples is not the same as learning a useful pattern.
Vocabulary
- Artificial intelligence
- Artificial intelligence is the field of building computer systems that perform tasks that normally require human-like reasoning, perception, language, or decision making.
- Model
- A model is a mathematical or computational system that maps inputs to outputs using learned parameters.
- Training data
- Training data is the collection of examples used to adjust an AI model so it performs a task more accurately.
- Neural network
- A neural network is a model made of connected layers of artificial neurons that transform input data into useful outputs.
- Loss function
- A loss function is a formula that measures how far a model's prediction is from the correct answer.
Common Mistakes to Avoid
- Thinking AI understands like a human. Most AI systems detect statistical patterns in data, not meaning in the human sense.
- Training and testing on the same data. This can hide overfitting because the model may memorize examples instead of learning patterns that work on new cases.
- Using a learning rate that is too large. Large updates can overshoot the best parameters and make the loss unstable or worse.
- Assuming more data always fixes bias. If the data is incomplete, unfair, or incorrectly labeled, a larger dataset can still teach the model the wrong patterns.
Practice Questions
- 1 A model predicts 8, 10, and 13 for correct values 9, 12, and 12. Calculate the mean squared error using L = (1/n) sum(yi - yhat_i)^2.
- 2 A parameter starts at theta = 4.0. The gradient of the loss is 1.5 and the learning rate is alpha = 0.2. Use theta_new = theta_old - alpha grad L to find the updated parameter.
- 3 A face recognition system works very well on its training photos but poorly on photos from new cameras and lighting conditions. Explain what likely happened and name one way to reduce the problem.