Skip to content

Commit

Permalink
today predictions
Browse files Browse the repository at this point in the history
  • Loading branch information
logroa committed Apr 27, 2021
1 parent b6327b5 commit 47c230f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
1 change: 1 addition & 0 deletions dataprep.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,5 @@ def fullJob():

if __name__ == "__main__":
fullJob()
conn.commit()

26 changes: 21 additions & 5 deletions regressionmodeling.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@
import numpy as np
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LogisticRegression

import sqlite3
import os
from sklearn.metrics import classification_report, accuracy_score, confusion_matrix, plot_confusion_matrix, precision_recall_curve, plot_precision_recall_curve, plot_roc_curve

df = pd.read_csv("modelData.csv")
todayGames = pd.read_csv("todayData.csv")

df = df.drop('date', 1)
todayGames = todayGames.drop('date', 1)

y = df[['win']]
X = df.drop('win', 1)
Expand Down Expand Up @@ -38,7 +41,20 @@
plot_confusion_matrix(logreg, X_test, y_test, normalize='true')
plot_roc_curve(logreg, X_test, y_test)

print("pred: ")
print(predictions)
print("actual: ")
print(y_test)
path = os.path.dirname(os.path.abspath(__file__))
conn = sqlite3.connect(path + '/' + 'stats.db')
cur = conn.cursor()

print("Today's Predictions: ")
todayPred = logreg.predict(todayGames)
todayGames['winPred'] = todayPred
for key, i in todayGames.iterrows():
cur.execute("SELECT Team FROM Teams WHERE id = ?", (i['team_id'],))
tname = cur.fetchone()[0]
cur.execute("SELECT Team FROM Teams WHERE id = ?", (i['opponent_id'],))
oname = cur.fetchone()[0]
word = ""
if i['winPred'] == 0:
word = "not "
print(tname + " are " + word + "projected to beat " + oname + " today.")

0 comments on commit 47c230f

Please sign in to comment.