import pandas as pdExercise: Multi-variable Regression 2
Your task: is to build a complete pipeline to process, fit, and score a predictive regression model.
We will work with two datasets:
- The California Housing Prices Dataset has
8numerical features and1categorical, with20,640samples - the Abalone Dataset will require you to do more reading and understanding of the dataset, before you can use it.
1. California Housing Prices Dataset
Find and download the dataset from Kaggle at California Housing Dataset.
According to keras.io:
This dataset was obtained from the StatLib repository.
It’s a continuous regression dataset with 20,640 samples with 8 features each.
The target variable is a scalar: the median house value for California districts, in dollars.
The 8 input features are the following:
- MedInc: median income in block group
- HouseAge: median house age in block group
- AveRooms: average number of rooms per household
- AveBedrms: average number of bedrooms per household
- Population: block group population
- AveOccup: average number of household members
- Latitude: block group latitude
- Longitude: block group longitude
This dataset was derived from the 1990 U.S. census, using one row per census block group. A block group is the smallest geographical unit for which the U.S. Census Bureau publishes sample data (a block group typically has a population of 600 to 3,000 people).
A household is a group of people residing within a home. Since the average number of rooms and bedrooms in this dataset are provided per household, these columns may take surprisingly large values for block groups with few households and many empty houses, such as vacation resorts.
pd.read_csv("../datasets/california_housing.csv").head()| longitude | latitude | housing_median_age | total_rooms | total_bedrooms | population | households | median_income | median_house_value | ocean_proximity | |
|---|---|---|---|---|---|---|---|---|---|---|
| 0 | -122.23 | 37.88 | 41.0 | 880.0 | 129.0 | 322.0 | 126.0 | 8.3252 | 452600.0 | NEAR BAY |
| 1 | -122.22 | 37.86 | 21.0 | 7099.0 | 1106.0 | 2401.0 | 1138.0 | 8.3014 | 358500.0 | NEAR BAY |
| 2 | -122.24 | 37.85 | 52.0 | 1467.0 | 190.0 | 496.0 | 177.0 | 7.2574 | 352100.0 | NEAR BAY |
| 3 | -122.25 | 37.85 | 52.0 | 1274.0 | 235.0 | 558.0 | 219.0 | 5.6431 | 341300.0 | NEAR BAY |
| 4 | -122.25 | 37.85 | 52.0 | 1627.0 | 280.0 | 565.0 | 259.0 | 3.8462 | 342200.0 | NEAR BAY |
# INSERT YOUR CODE2. Abalone Dataset
Predicting the age of abalone from physical measurements.
A real challenge is different formats, hence we present this to you as an opportunity to practice dealling with this problem:
- Visit the dataset page and click the “Download” button.
- You will read the page yourself to understand the purpose of this data, and what you are supposed to do.
- You will notice that it is not simply a
.csvfile. Rather,3different files, compressed.
- Find out how to read it correctly as a DataFrame for exploratory data analysis
- Finally, train a regression model on the features and the target
# INSERT YOUR CODEFind more datasets on UCI Machine Learning Repository.