Course: Introduction to Machine Learning
Student: Năng Lê Khánh Hà
Step 1: Loading the Data
First, I used Pandas to load the Iowa housing dataset called train.csv. The file contains details
about houses, like their size, year built, and sale prices.
Here’s how I did it:
import pandas as pd
iowa_file_path = '../input/home-data-for-ml-course/train.csv'
home_data = pd.read_csv(iowa_file_path)
After loading the data, I checked that everything worked properly. The dataset has many
columns describing each house — for example, LotArea (the size of the land), YearBuilt (when
the house was built), and SalePrice (how much it sold for).
Step 2: Reviewing the Data
To understand the data better, I looked at some summary statistics using the .describe()
function. That showed me the average, minimum, and maximum values for each column.
Then, I calculated two things that the exercise asked for:
1. The average lot size
2. The age of the newest home (as of this year)
Here’s the code I used:
avg_lot_size = round(home_data['LotArea'].mean())
from datetime import datetime
current_year = datetime.now().year
newest_home_age = current_year - home_data['YearBuilt'].max()
When I ran this, I got:
Average lot size: around 10,514 square feet
Newest home age: about 15 years old (the newest house was built in 2010)
Step 3: Thinking About the Data
The newest house in this dataset isn’t that new. There could be two reasons:
1. They haven’t built many new houses in this area.
2. The data was collected a while ago, so it doesn’t include newer homes.
If it’s the first reason, then the model we build will still work fine for predicting prices of
existing houses — it just won’t be useful for newly built ones.
But if it’s the second reason, that’s a bigger problem. Housing prices and construction trends
change over time, so using old data could make the model less accurate for today’s market.
To figure out which reason is true, I could:
Look at the distribution of YearBuilt values to see when most houses were built.
Check the Kaggle dataset description to see when the data was collected.
Compare it with more recent housing data from Iowa.