This notebook is an exercise in the Introduction to Machine Learning course. You can reference the tutorial at this link.


Introduction

In this exercise, you will create and submit predictions for a Kaggle competition. You can then improve your model (e.g. by adding features) to apply what you've learned and move up the leaderboard.

Begin by running the code cell below to set up code checking and the filepaths for the dataset.

Here's some of the code you've written so far. Start by running it again.

Train a model for the competition

The code cell above trains a Random Forest model on train_X and train_y.

Use the code cell below to build a Random Forest model and train it on all of X and y.

Now, read the file of "test" data, and apply your model to make predictions.

Let's rock

Before submitting, run a check to make sure your test_preds have the right format.

Generate a submission

Run the code cell below to generate a CSV file with your predictions that you can use to submit to the competition.

Submit to the competition

To test your results, you'll need to join the competition (if you haven't already). So open a new window by clicking on this link. Then click on the Join Competition button.

join competition image

Next, follow the instructions below:

  1. Begin by clicking on the Save Version button in the top right corner of the window. This will generate a pop-up window.
  2. Ensure that the Save and Run All option is selected, and then click on the Save button.
  3. This generates a window in the bottom left corner of the notebook. After it has finished running, click on the number to the right of the Save Version button. This pulls up a list of versions on the right of the screen. Click on the ellipsis (...) to the right of the most recent version, and select Open in Viewer. This brings you into view mode of the same page. You will need to scroll down to get back to these instructions.
  4. Click on the Output tab on the right of the screen. Then, click on the file you would like to submit, and click on the blue Submit button to submit your results to the leaderboard.

You have now successfully submitted to the competition!

If you want to keep working to improve your performance, select the Edit button in the top right of the screen. Then you can change your code and repeat the process. There's a lot of room to improve, and you will climb up the leaderboard as you work.

Continue Your Progress

There are many ways to improve your model, and experimenting is a great way to learn at this point.

The best way to improve your model is to add features. To add more features to the data, revisit the first code cell, and change this line of code to include more column names:

features = ['LotArea', 'YearBuilt', '1stFlrSF', '2ndFlrSF', 'FullBath', 'BedroomAbvGr', 'TotRmsAbvGrd']

Some features will cause errors because of issues like missing values or non-numeric data types. Here is a complete list of potential columns that you might like to use, and that won't throw errors:

Look at the list of columns and think about what might affect home prices. To learn more about each of these features, take a look at the data description on the competition page.

After updating the code cell above that defines the features, re-run all of the code cells to evaluate the model and generate a new submission file.

What's next?

As mentioned above, some of the features will throw an error if you try to use them to train your model. The Intermediate Machine Learning course will teach you how to handle these types of features. You will also learn to use xgboost, a technique giving even better accuracy than Random Forest.

The Pandas course will give you the data manipulation skills to quickly go from conceptual idea to implementation in your data science projects.

You are also ready for the Deep Learning course, where you will build models with better-than-human level performance at computer vision tasks.


Have questions or comments? Visit the Learn Discussion forum to chat with other Learners.