text_plain_output_1.png
from sklearn.linear_model import LinearRegression

from sklearn.metrics import r2_score

from sklearn.model_selection import train_test_split

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

headbrain = pd.read_csv('../input/headbrain.csv')

headbrain = headbrain.values
X = headbrain[:, 2]
Y = headbrain[:, 3]
(X.shape, Y.shape)

X = X.reshape(len(X), 1)
X_train, X_test, y_train, y_test = train_test_split(X, Y, test_size=0.3)
reg = LinearRegression()
reg.fit(X_train, y_train)
y_predictions = reg.predict(X_test)
print('R-squared :', r2_score(y_test, y_predictions))