Recap: Bike Rentals
Part of the Supervised Learning section of Coddy's Machine Learning journey. Lesson 15 of 58.
Challenge
MediumA city's bike scheme plans its fleet from the weather forecast. bike_days.csv holds 120 days: temp_c, humidity, wind_kmh, weekend (1 or 0) and rentals.
- Hold out a test quarter (
random_state=0) and fit aLinearRegressionof rentals on the fourfeatures. - Print the test MAE (whole rentals), R squared (3 decimals) and the temperature's weight (1 decimal).
- Scatter the test residuals against
temp_cover a dashed line at 0. Title itMisses by Temperature; label the axesTemperature (C)andResidual (rentals).
Another city's report:
Typical miss: 187 rentals a day
R squared: 0.512
Each extra degree adds 21.4 rentalsThen Coddy describes your chart. What does it tell the scheme about hot days?
Try it yourself
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
from sklearn.metrics import mean_absolute_error, r2_score
days = pd.read_csv("bike_days.csv")
features = ["temp_c", "humidity", "wind_kmh", "weekend"]
# Write your code below
All lessons in Supervised Learning
1Your First Model
Learning from ExamplesTrain and Test SetsFit and PredictScoring a ModelRecap: Seed Sorter2Nearest Neighbors
How k-NN DecidesChoosing kDecision BoundariesScaling for NeighborsRecap: Wine Neighbors5Measuring Classifiers
The Confusion MatrixPrecision and RecallThe F1 ScoreImbalanced ClassesROC CurvesRecap: Screening Test11Project: Penguin Species
Meet the PenguinsPrepare the DataChoose a ModelTune the WinnerShip the Model3Linear Regression
Predicting NumbersSeveral FeaturesMeasuring ErrorsResidual PlotsRecap: Bike RentalsPractice on your own: Online Python compiler