Fitting a simple model: regression
In this exercise, you'll practice fitting a regression model using data from the California housing market. A DataFrame called housing is available in your workspace. It contains many variables of data (stored as columns). Can you find a relationship between the following two variables?
- "MedHouseVal": the median house value for California districts (in $100,000s of dollars)
- "AveRooms": average number of rooms per dwelling
Cet exercice fait partie du cours
Machine Learning for Time Series Data in Python
Instructions
- Prepare XandyDataFrames using the data inhousing.- Xshould be the Median House Value,- yaverage number of rooms per dwelling.
 
- Fit a regression model that uses these variables (remember to shape the variables correctly!).
- Don't forget that each variable must be the correct shape for scikit-learn to use it!
Exercice interactif pratique
Essayez cet exercice en complétant cet exemple de code.
from sklearn import linear_model
# Prepare input and output DataFrames
X = ____
y = ____
# Fit the model
model = linear_model.LinearRegression()
model.fit(____)