[SOLVED] CS1009 Homework 2-Linear and k-NN Regression

40.00 $

Programming resource
Digital learning resource
Category:
Practical programming resource
Suitable for guided study and reference
Tutor guidance available when needed

Description

5/5 - (1 vote)

Main Theme: Predicting Taxi Pickups in NYC
In this homework, we will explore k-nearest neighbor and linear regression methods for predicting a quantitative variable. Specifically, we will build regression models that can predict the number of taxi pickups in New York city at any given time of the day. These prediction models will be useful, for example, in monitoring traffic in the city.
The data set for this problem is given in the file dataset_1.csv. You will need to separate it into training and test sets. The first column contains the time of a day in minutes, and the second column contains the number of pickups observed at that time. The data set covers taxi pickups recorded in NYC during Jan 2015.
We will fit regression models that use the time of the day (in minutes) as a predictor and predict the average number of taxi pickups at that time. The models will be fitted to the training set and evaluated on the test set. The performance of the models will be evaluated using the R2 metric.
Question 1
1.1. Use pandas to load the dataset from the csv file dataset_1.csv into a pandas data frame. Use the train_test_split method from sklearn with a random_state of 42 and a test_size of 0.2 to split the dataset into training and test sets. Store your train set dataframe in the variable train_data. Store your test set dataframe in the variable test_data.
1.2. Generate a scatter plot of the training data points with well-chosen labels on the x and y axes. The time of the day should be on the x-axis and the number of taxi pickups on the y-axis. Make sure to title your plot.
1.3. Does the pattern of taxi pickups make intuitive sense to you?
1

Resource details

Understand the Task Before You Use the Resource

Review the requirements, identify the programming concepts involved, study the implementation and test your understanding with your own examples and modifications.