# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# %matplotlib inline
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import statsmodels.api as sm

from sklearn.linear_model import LinearRegression
from sklearn.model_selection import train_test_split

df = pd.read_csv("NBA_19_records.csv")
df.head()

df.columns

df = df[['salary_2019to2020','age', 'gp','min','pts','fg_prc','three_pnt_prc','ft_prc','reb','ast', 'tov','plusminus']]
df.head()

df = df.rename(columns={"salary_2019to2020":"y","age":"X1", "gp":"X2","min":"X3","pts":"X4","fg_prc":"X5","three_pnt_prc":"X6","ft_prc":"X7","reb":"X8","ast":"X9", "tov":"X10","plusminus":"X11"})
df.head()

# +
# test train split
# linear regression (sklearn)
# coefficients/weights
# -

X = df.drop(columns=['y'])
y = df['y']

X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=42)

model = LinearRegression(normalize=True)

model.fit(X_train, y_train)

model.coef_

stat_model = sm.OLS(y,X)
stat_result = stat_model.fit()
print(stat_result.summary())

# +
# scalar

StarcoderdataJupyterScriptsDedupFiltered