Teyro
CoursesFor creatorsBlog
Log inGet started
Tey Mascot
LOADING.

Every expert you admire was once a beginner who refused to quit.

Teyro

The fun way to finish learning coding and AI: short daily lessons with streaks, leagues and friends.

Get the app

Learn

  • All courses
  • Learn coding
  • Learn AI
  • Learn online
  • How it works
  • Leagues
  • Get the app

Creators

  • Teach on Teyro
  • How teaching works
  • Teach coding online
  • Teach AI online
  • Join as a Founding Creator
  • Creator log in

Resources

  • Blog
  • Features
  • Use cases
  • Compare
  • FAQ

Legal

  • Terms of Use
  • Privacy Policy

© 2026 Teyro · support@teyro.app

HomeBlogSkill Building & Careers
Skill Building & Careers

Training and Test Data: Why You Must Split Your Dataset

Learn why models are tested on unseen data, how to split into training, validation and test sets and mistakes like data leakage.

The Teyro TeamOct 26, 20261 min read
On this page7 sections
  1. Direct answer
  2. Example in Python
  3. Typical splits
  4. Common mistakes
  5. Where Teyro fits
  6. The bottom line
  7. More guides

If you grade a student on the questions they practised, you learn nothing about what they know.

Direct answer

Split your data into a training set to teach the model and a test set to evaluate it on unseen data. Often you also use a validation set for tuning. Keep the test set untouched until the end, and avoid data leakage.

Example in Python

from sklearn.model_selection import train_test_split

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

Typical splits

SetPurposeShare
Traininglearn patternsaround 60 to 80 percent
Validationtune settingsaround 10 to 20 percent
Testfinal checkaround 10 to 20 percent

Common mistakes

  • Scaling or cleaning using the whole dataset before splitting.
  • Repeatedly adjusting the model based on test results.
  • Splitting time series data randomly.

Where Teyro fits

Teyro's Machine Learning for Beginners course turns this into short lessons you can play in a few minutes a day. It has 200 lessons, and you can start free.

The bottom line

The test set is a final exam. Do not peek.

More guides

  • Linear Regression Explained
  • Decision Trees Explained
  • Neural Networks Explained in Simple Terms
  • Overfitting explained
  • Cross validation explained
  • Machine Learning for Beginners course

Frequently asked questions

Why split data into training and test sets?

To measure how well a model performs on new data, not data it has already seen.

What is a validation set?

A separate portion used to tune settings while keeping the test set untouched until the end.

What is data leakage?

When information from the test set influences training, making results look better than they really are.

Learn it by playing

Machine Learning for Beginners turns this into short, playable lessons. Free to start.

See the Machine Learning for Beginners course

Free to start · No credit card needed

Share

Written by

The Teyro Team

Learning Team at Teyro

We build Teyro — an AI-powered learning platform that turns skill-building into a daily habit through bite-sized, gamified lessons. We write about the learning science and study strategies that shape our product.

More from The Teyro Team

On this page

  • Direct answer
  • Example in Python
  • Typical splits
  • Common mistakes
  • Where Teyro fits
  • The bottom line
  • More guides

Keep reading

Skill Building & Careers

Best Careers for 2027: High-Demand Jobs and the Skills to Get Them

The best careers for 2027 and the jobs most in demand, based on BLS and World Economic Forum data, plus the skills each path needs.

Oct 30, 20263 min read
Skill Building & Careers

Best Certifications for 2027: Tech, Data, Cloud and Business

The best certifications for 2027 in cloud, security, data, project management and AI, who each one suits, and when a portfolio matters more.

Oct 30, 20263 min read
Skill Building & Careers

Best Programming Language to Learn in 2027 (for Your Goal)

The best programming language to learn in 2027 depends on what you want to build. Compare Python, JavaScript, TypeScript, SQL and C.

Oct 30, 20263 min read