from numpy import genfromtxt
import pandas as pd
import numpy as np
from pandas.core import base

"""
df = pd.read_csv('baseball_small.csv', sep=',')
X1 = df[['RS','RA','W','OBP','SLG','BA']]
y = df['OOBP']
X=np.asmatrix(X1)
"""

baseball_data = genfromtxt('baseball_small.csv',delimiter=',')
print(baseball_data[1:48,3:9])
X = baseball_data[1:48,3:9]
y = baseball_data[1:48,-2]
X_test=baseball_data[49,3:9]
print(X)
print(y)

XT = np.matrix.transpose(X)
XT_X = np.matmul(XT, X)
XT_y = np.matmul(XT, y)
betas = np.matmul(np.linalg.inv(XT_X), XT_y)
print(betas)
print(X_test)
print(betas.dot(np.transpose(X_test)))
print(f'Value in csv file={baseball_data[49,-2]}')
