import numpy as np
import pandas as pd
from matplotlib import rcParams
import seaborn as sns
from scipy.stats import zscore
import matplotlib.pyplot as plt
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
from sklearn.neighbors import KNeighborsRegressor
from sklearn.linear_model import LinearRegression

# 1 : read the CPU data
df = pd.read_csv("https://raw.githubusercontent.com/grbruns/cst383/master/machine.csv")
df.index = df['vendor']+' '+df['model']
df.drop(['vendor', 'model'], axis=1, inplace=True)
df['cs'] = np.round(1e3/df['myct'], 2)	# clock speed in MHz 

# 2 : create training and test sets using 70/30 split
y = df['prp'].values
predictors = ['cach', 'chmax']
X = df[predictors].values

# create scatterplot so we can see what the data looks like to know how to transform things :D 
sns.scatterplot(x='cs', y='chmax', data=df)

X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.30, random_state=42)
reg = LinearRegression()
reg.fit(X_train, y_train)

reg.score(X_train, y_train)
