-
Notifications
You must be signed in to change notification settings - Fork 0
/
nba_predict.py
76 lines (62 loc) · 2.1 KB
/
nba_predict.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#NBA_PREDICT
#this file serves as the collective source file that we'll be using finally
#but for now it serves as a playground
# from termcolor import colored
# import matplotlib.pyplot as plt #visualization
# from matplotlib import style # ^
# style.use("ggplot")
from scraper import statRetrieval
from multi import compositePredict, offenseSkillWord, defenseSkillWord, efficiencySkillWord, durabilitySkillWord, sumUp
from sentence import efficiencySent, scoringSent, defenseSent, durableSent, sumUpSent
from flask import Flask, render_template
app = Flask(__name__)
METRIC_SETS = 5
PLAYER_DATA = []
#OLD FORMAT
#TS%/PPG
# scoring_svm = statFit(9,28)
#will implement later
def summary(name, PLAYER_DATA):
summary = ''
try:
summary += efficiencySent(name, efficiencySkillWord(PLAYER_DATA)) + ' '
except(TypeError):
pass
try:
summary += scoringSent(name, offenseSkillWord(PLAYER_DATA)) + ' '
except(TypeError):
pass
try:
summary += defenseSent(name, defenseSkillWord(PLAYER_DATA)) + ' '
except(TypeError):
pass
try:
summary += durableSent(name, durabilitySkillWord(PLAYER_DATA)) + ' '
except(TypeError):
pass
try:
summary += sumUpSent(name, sumUp(compositePredict(PLAYER_DATA)))
except(TypeError):
pass
return summary.lower()
#main sauce
@app.route("/")
@app.route("/<name>")
def predict(name=None):
if(name!=None):
try:
data = statRetrieval(name)
prediction = compositePredict(data)
longform = summary(name, data)
if(prediction == 0):
return render_template("index.html", prediction="0.0", longform=longform)
return render_template("index.html", prediction=prediction, longform=longform)
except(RuntimeError, TypeError, NameError, KeyError, ValueError, IndexError):
#for this you have to render a different HTML file with the display of this text so it doesn't look whack
return render_template("noplayer.html")
else:
#means no player has been searched! make a different html file with presentation for this so
#it doesn't say " ________ has a super potential of SEARCH!"
return render_template("prompt.html", prediction=None)
if __name__ == "__main__":
app.run()