-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmvp_model.py
48 lines (40 loc) · 1.48 KB
/
mvp_model.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import numpy as np
import pandas as pd
from scipy import stats
import math
np.random.seed(1)
pd.options.display.max_rows = 10
pd.options.display.float_format = '{:.1f}'.format
# field_df = pd.read_csv('data/mvpfield.csv')
years = ['2010', '2014', '2016', '2017', '2018']
mvp_index = 0
stats_of_interest = ['VORP','PER','WS','FTr','DWS','OWS','WinsAdded']
zscore_list = []
def zscore_model():
for stat in stats_of_interest:
# print('Z-scores for {}'.format(stat))
stat_zscores = np.array([0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0])
for year in years:
field_df = pd.read_csv('data/mvp'+year+'.csv')
stat_for_t20 = field_df[stat].tolist()
math_ready = np.array(stat_for_t20)
yearly_zscores = np.array(stats.zscore(math_ready))
# print(yearly_zscores)
stat_zscores += yearly_zscores
# print('mvp z-score for {} is {}'.format(stat, yearly_zscores[mvp_index]))
# print()
zscore_list.append((stat_zscores/(len(years)))[mvp_index])
# print()
# print()
# print("MVP Z-Scores compared to top 20")
# for ind in range(len(zscore_list)):
# print(interest[ind])
# print(zscore_list[ind])
# print()
return zscore_list
# a = [1.0,2.0,3.0,4.0]
# b = [1.0,0.6,4.1,4.0]
# print(eucliddist(a,b))