Learn practical skills, build real-world projects, and advance your career

Assignment - Decision Trees and Random Forests


In this assignment, you'll continue building on the previous assignment to predict the price of a house using information like its location, area, no. of rooms etc. You'll use the dataset from the House Prices - Advanced Regression Techniques competition on Kaggle.

We'll follow a step-by-step process:

  1. Download and prepare the dataset for training
  2. Train, evaluate and interpret a decision tree
  3. Train, evaluate and interpret a random forest
  4. Tune hyperparameters to improve the model
  5. Make predictions and save the model

As you go through this notebook, you will find a ??? in certain places. Your job is to replace the ??? with appropriate code or values, to ensure that the notebook runs properly end-to-end and your machine learning model is trained properly without errors.


  1. Make sure to run all the code cells in order. Otherwise, you may get errors like NameError for undefined variables.
  2. Do not change variable names, delete cells, or disturb other existing code. It may cause problems during evaluation.
  3. In some cases, you may need to add some code cells or new statements before or after the line of code containing the ???.
  4. Since you'll be using a temporary online service for code execution, save your work by running jovian.commit at regular intervals.
  5. Review the "Evaluation Criteria" for the assignment carefully and make sure your submission meets all the criteria.
  6. Questions marked (Optional) will not be considered for evaluation and can be skipped. They are for your learning.
  7. It's okay to ask for help & discuss ideas on the community forum, but please don't post full working code, to give everyone an opportunity to solve the assignment on their own.

Important Links:

How to Run the Code and Save Your Work

Option 1: Running using free online resources (1-click, recommended): The easiest way to start executing the code is to click the Run button at the top of this page and select Run on Binder. This will set up a cloud-based Jupyter notebook server and allow you to modify/execute the code.

Option 2: Running on your computer locally: To run the code on your computer locally, you'll need to set up Python, download the notebook and install the required libraries. Click the Run button at the top of this page, select the Run Locally option, and follow the instructions.

Saving your work: You can save a snapshot of the assignment to your Jovian profile, so that you can access it later and continue your work. Keep saving your work by running jovian.commit from time to time.

!pip install jovian --upgrade --quiet
import jovian