Beginner-Friendly Topic
Take your time - it's perfectly normal to re-read this topic 2-3 times. Try the interactive code editor below to run code yourself. Use the Q&A section to check your understanding before moving on. You've got this! 🚀
Training Data
Training data is the set of examples an AI model learns from. The model studies this data to find patterns. The quality and quantity of training data directly affects how well the model performs.
What is Training Data?
Training data is the collection of labeled examples that the AI model is trained on. During training, the model repeatedly looks at these examples, measures its errors, and adjusts itself to reduce those errors.
Think of it like a student studying a textbook. The textbook is the training data. The student (AI) reads through all the examples, makes mistakes on practice questions, corrects those mistakes, and gradually improves.
Deep Learning ⊂ Machine Learning ⊂ Artificial Intelligence
Characteristics of Good Training Data
- Representative: The training examples should reflect the real situations the model will face
- Balanced: If predicting spam, include enough spam and non-spam examples. Do not have 99% non-spam
- Accurate: Incorrectly labeled examples teach the model wrong patterns
- Diverse: Include a wide variety of cases, not just common ones
- Large enough: More examples usually means better learning, especially for complex tasks
Training Data Example
# Simple example: training data for a number classifier
# The model learns which numbers are positive or negative
training_data = [
# (number, correct_label)
(5, "positive"),
(10, "positive"),
(3, "positive"),
(-4, "negative"),
(-7, "negative"),
(-2, "negative"),
(0, "zero"),
]
# A simple model learns this pattern:
# number > 0 -> positive
# number < 0 -> negative
# number == 0 -> zero
def train_simple_model(data):
"""Learn from training data"""
print("Training the model...")
print(f"Examining {len(data)} training examples...")
# In real ML, this step involves complex math
# Here we illustrate the concept
print("Model learned: positive if > 0, negative if < 0, zero if == 0")
print()
def predict(number):
"""Apply what was learned"""
if number > 0:
return "positive"
elif number < 0:
return "negative"
else:
return "zero"
train_simple_model(training_data)
# Test on new numbers (not in training data)
test_numbers = [8, -15, 0, 42, -1]
print("Predictions on new data:")
for num in test_numbers:
print(f" {num} -> {predict(num)}")Tip
Tip
In real AI projects, collecting and cleaning training data often takes 60 to 80 percent of the total project time. This is normal. Good training data is worth more than a complex algorithm. A simple algorithm with great data usually beats a complex algorithm with poor data.
Key Takeaways
- Training data is the set of examples an AI model learns from.
- Representative: The training examples should reflect the real situations the model will face
- Balanced: If predicting spam, include enough spam and non-spam examples. Do not have 99% non-spam
- Accurate: Incorrectly labeled examples teach the model wrong patterns