Created
May 27, 2018 13:30
-
-
Save grohith327/34d8e17c27965ba899baa6dc0355a099 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import numpy as np | |
df_train = pd.read_csv('/Users/rohith/Documents/Datasets/Linear_Regression/train.csv') | |
df_test = pd.read_csv('/Users/rohith/Documents/Datasets/Linear_Regression/test.csv') | |
x_train = df_train['x'] | |
y_train = df_train['y'] | |
x_test = df_test['x'] | |
y_test = df_test['y'] | |
x_train = np.array(x_train) | |
y_train = np.array(y_train) | |
x_test = np.array(x_test) | |
y_test = np.array(y_test) | |
x_train = x_train.reshape(-1,1) | |
x_test = x_test.reshape(-1,1) |
Hello Raj, Thank you for your kind words. Later in the example we manually calculate the gradients and update the weights which requires some matmul, therefore, to ensure it works smoothly we reshape the matrix. If you are going to be using the sklearn package to perform linear regression I guess the reshaping is only an addition. Thank you.
Thank you Rohith,
How can I get the CSV to test the code?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello Rohith,
Thank you for such a wonderful content. I have a question here, is there any reason why you have reshaped the array to 1 column? Because i think it will work without reshaping the array too.