Home›Learn›AI›Training and Testing Data
AI Master CourseBeginner Friendly

Training and Testing Data

Learn why datasets are divided into training and testing sets.

📘 Chapter 10 / 29⏱️ 8–10 Min Read🎯 Beginner Friendly
Course Progress34%

Course Progress

34%

10 / 29 chapters

📖

Theory

Understand the concept step by step

Machine Learning datasets are commonly divided into training and testing data. Training data is used to learn the model parameters. Testing data is used to evaluate how well the trained model performs on unseen data. Keeping test data separate helps provide a better estimate of generalization performance.
💻

Example

See how the concept works

AI / Python
from sklearn.model_selection import train_test_split

X = [[1], [2], [3], [4], [5], [6]]
y = [2, 4, 6, 8, 10, 12]

X_train, X_test, y_train, y_test = train_test_split(
    X,
    y,
    test_size=0.2,
    random_state=42
)

print(X_train)
print(X_test)
📤

Output

Understand what the code produces

The dataset is divided into training and testing subsets.

📝

Practice

Test your understanding

Split a dataset into training and testing sets using scikit-learn.

❓

MCQs

Check your knowledge

What is the main topic covered in Training and Testing Data?

A.Evaluating the model on unseen data
B.Writing the model's source code
C.Deleting training examples
D.Creating database tables
💼

Interview Questions

Prepare for AI interviews

1

Interview Question

Why do we split data into training and testing sets?

2

Interview Question

What is training data?

3

Interview Question

What is testing data?

4

Interview Question

What is overfitting?