Student Performance Prediction · Project

Student Performance Prediction · Phase 3 · Lesson 2 of 3

Decision Trees and Model Comparison

Train a decision tree or random forest, control overfitting, and compare all models fairly on the same cross-validation folds.

What you need

A computer with a web browser and a free Google account for Google Colab, or Python with Jupyter installed locally. Libraries: pandas, scikit-learn and matplotlib (all free).

In this lesson you will

  • Train tree-based models and control overfitting
  • Compare models fairly and choose one with reasons

Key concepts

decision treerandom forestoverfittingmax depthmodel comparison

The lesson

Decision trees learn if-then rules and can capture interactions, but deep trees memorise the training data (overfitting). Limit max_depth and the minimum samples per leaf, or use a random forest, which averages many trees.

Compare models on the same folds and the same measures. A model that is only slightly better but much harder to explain may not be worth it for a school.

Choose one model and write the reasons: performance against the evaluation plan, stability across folds and explainability.

Step by step

  1. Train a decision tree with limited depth and a random forest.
  2. Run the same cross-validation for both.
  3. Add them to the comparison table.
  4. Choose a model and write three reasons.

Practice activity

Complete the model comparison and a written model choice.

Expected result: A fair comparison of at least three approaches and a justified choice.

Common mistakes

  • Choosing the most complex model by default
  • Comparing models on different data splits

Check your understanding

  1. What is overfitting?

    Show answer

    When a model learns the training data too closely and performs worse on new data.

  2. Name one way to reduce overfitting in a decision tree.

    Show answer

    Limit the maximum depth or the minimum samples per leaf.

Further learning

Projects are instructor-guided: an instructor sets milestones, checks your work and gives feedback, online or in person. Self-study of the public lessons does not lead to a certificate. Enrolment and fees follow the Academy's existing policies — contact the Academy.