Question: Now that we have have our data, we need to split this into a training set, and a testing set. But before we split our

Now that we have have our data, we need to split this into a training set, and a testing set. But before we split our data into training and testing, we also need to split our data into the predictive features (denoted x) and the response (denoted y).
Write a function that will take as input a 2-d numpy array and retum four variables in the form of (X_train, y_train),(X_test, y-test), where (X_train, y_train) are the features + response of the training set, and (x-test, y-test) are the features + response of the testing set.
Function Specifications:
Should take a 2-d numpy as input.
Should split the array such that x is the year, and y is the corresponding population.
Should return two tuples of the form (X_train, y-t rain),(X_test, y-test).
Should use sklearn's train_test_split function with a test_size =0.2 and random_state =42.
### START FUNCTION
def feature_response_split(arr):
# your code here
return
 Now that we have have our data, we need to split

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!