In [ ]:
%matplotlib inline

import pandas as pd
import seaborn as sns

sns.set_context("talk")

In [ ]:
import matplotlib
matplotlib.rcParams['figure.figsize'] = (20, 10)

In [ ]:
N_SAMPLES = 1000
THETA = np.array([2., 4.])

df_x_train = np.random.uniform(low=-100, high=100, size=(N_SAMPLES, 2))
df_x_test = np.random.uniform(low=-100, high=100, size=(N_SAMPLES, 2))

df_y_train = np.dot(df_x_train, THETA) + np.random.normal(scale=10., size=N_SAMPLES)
df_y_test = np.dot(df_x_test, THETA)   + np.random.normal(scale=10., size=N_SAMPLES)

In [ ]:
theta = np.dot(np.linalg.inv(np.dot(df_x_train.T, df_x_train)),
               np.dot(df_x_train.T, df_y_train))
theta

In [ ]:
df_y_pred = np.dot(df_x_test, theta)
#df_y_pred

In [ ]:
plt.scatter(df_y_test, df_y_pred);