{"id":20522450,"url":"https://github.com/blakeziegler/nfl-ai","last_synced_at":"2026-02-25T18:31:50.412Z","repository":{"id":260161244,"uuid":"880458415","full_name":"blakeziegler/NFL-AI","owner":"blakeziegler","description":"Sports AI featuring Deep Learning Neural Networks from Scratch with Momentum Optimization","archived":false,"fork":false,"pushed_at":"2024-12-20T20:35:24.000Z","size":7822,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-30T15:49:30.316Z","etag":null,"topics":["artificial-intelligence-algorithms","artificial-neural-networks","calculus","deep-neural-networks","linear-algebra","neural-network","numpy","prediction-model","sports","statistics"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/blakeziegler.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-29T19:01:32.000Z","updated_at":"2024-12-17T21:32:59.000Z","dependencies_parsed_at":"2025-01-16T10:36:08.994Z","dependency_job_id":"338c4d03-e01f-4890-9606-2c6f1f74b8ab","html_url":"https://github.com/blakeziegler/NFL-AI","commit_stats":null,"previous_names":["blakeziegler/sportsbetting-ai","blakeziegler/nfl-ai"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/blakeziegler/NFL-AI","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blakeziegler%2FNFL-AI","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blakeziegler%2FNFL-AI/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blakeziegler%2FNFL-AI/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blakeziegler%2FNFL-AI/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/blakeziegler","download_url":"https://codeload.github.com/blakeziegler/NFL-AI/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blakeziegler%2FNFL-AI/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29834617,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-25T17:57:15.019Z","status":"ssl_error","status_checked_at":"2026-02-25T17:56:11.472Z","response_time":61,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["artificial-intelligence-algorithms","artificial-neural-networks","calculus","deep-neural-networks","linear-algebra","neural-network","numpy","prediction-model","sports","statistics"],"created_at":"2024-11-15T22:35:32.379Z","updated_at":"2026-02-25T18:31:50.390Z","avatar_url":"https://github.com/blakeziegler.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NFL-AI\n![Version](https://img.shields.io/badge/version-v1.0.0-blue)\n### Usage\nAfter cloning, install the necessary packages using:\n~~~\npip install -r requirements.txt\n~~~\n\nTo test the neural network and feature engineering individually, run the 'nn_test.py'\nand 'test_feature_engineering.py' files. \n\nTo test the betting system as a whole, run the 'test_betting_system.py' file.\n\n### Introduction\nThe purpose of this project was to determine whether a machine learning approach to sports-betting\nwould outperform popular alternative strategies.  Our project utilizes the predictive capabilities of \nneural networks to assess point spreads and find potential advantageous betting situations for a \nparticular NFL game.\n\n\n### Data\n**Historic NFL Data** *(https://www.kaggle.com/datasets/tobycrabtree/nfl-scores-and-betting-data)*\n\n- Kaggle dataset comprised of the majority of NFL football games dating back to 1966 with 25 unique features for each game.\n- Games taking place prior to the 2010-2011 season were taken out.\n- Irrelevant and/or noisy potential indicators were removed.\n\n**Feature Engineering**\n\n- Game Metrics Calculated:\n  - Total Points and Point Differential\n  - Is Home Favorite? (binary flag)\n  - Spread Performance \u0026 Over/Under Performance\n\n\n- Team Metrics Calculated:\n  - Average Points For/Against\n  - Spread Cover Rate\n  - Win Streak\n\n\n- Relative Power Ranking System Initialized\n\n### Neural Network\n**Input Initialization**\n- layers - Specifies the number of neurons in each layer and the configuration of neurons.\n- activation - Activation function for hidden layers.\n- output_activation - Activation function for output layer.\n- learning - Network learning rate.\n- beta - Momentum coefficient\n\n**Component Initialization**\n- params - Initializes weights and biases using He Initialization.\n- velo - Initializes velocity calculation for momentum optimization.\n\n**Caching and Storage**\n- params - Stores weights and biases.\n- cache - Stores intermediate calculations.\n- gradient - Stores computed gradients.\n\n**Forward Propagation**\n- Inputs 'X' are transposed onto a matrix as:\n~~~\nA = X.T\nself.cache['A0'] = A\n~~~\n- Input and updated weight matrix's are multiplied and bias is added:\n~~~\nZ = np.dot(W, A) + b\n~~~\n- Output is ran through the chosen activation function:\n~~~\nA = self.activation_func(Z)\n~~~\n- Cache the new input matrix 'A' and dot product + bias result 'Z':\n~~~\nself.cache['A' + str(layer)] = A\nself.cache['Z' + str(layer)] = Z\n~~~\n- Cost function is calculated using the Mean Squared Error (MSE) fromula.\n\n**Backpropagation**\n\n- Computes cost gradients with respect to weights and biases\n\n*Output Layer*\n- Cost function is computed with respect to Z (pre-activation):\n~~~\ndZ = self.cache['A' + str(L)] - Y\n~~~\n- Gradient for weights and biases:\n~~~\nself.gradient['dW' + str(L)] = np.dot(dZ, self.cache['A' + str(L - 1)].T) / m\nself.gradient['db' + str(L)] = np.sum(dZ, axis=1, keepdims=True) / m\n~~~\n- dW = derivative of cost function with respect to weights\n- db = derivative of cost function with respect to bias\n- Gradients are averaged over batch size 'm'\n\n*Hidden Layers*\n- Moves gradients back through the hidden layers.\n- Multiplies the gradient from the following layer with weight matrix.\n- Multiplies result with the derivative of the activation function.\n~~~\ndZ = np.dot(self.params['W' + str(layer + 1)].T, dZ) * self.activation_derivative(self.cache['Z' + str(layer)])\n~~~\n- Computation of the gradients is performed as outlined in the output layer.\n- 'dW' and 'db' are cached.\n\n**Training \u0026 Optimization**\n- Batch size and cost value storage are initialized.\n- Data is shuffled at the start of each epoch (training round).\n- For each batch, forward propagation is performed and cost calculated:\n~~~\nY_pred = self.forward_feed(X_batch)\ncost = self.cost(Y_pred, Y_batch.T)\n~~~\n- Back propagation is performed and network is updated:\n~~~\nself.backward_feed(Y_batch.T)\nself.update_network()\n~~~\n- Cost is logged and the network makes predictions on test data:\n~~~\nY_pred = self.forward_feed(X_pred)\n~~~\n- Transpose to original format:\n~~~\nreturn Y_pred.T\n~~~\n\n### Betting System\n**1. Initialize Feature Engineering**\n~~~\nprocessed_data = self.feature_processor.process_initial_features(game_data)\n~~~\n**2. Generate Predictions using neural network**\n~~~\nprediction_features = self._prepare_prediction_features(features)\nraw_predictions = self.neural_network.prediction(prediction_features)\n~~~\n**3. Find Value Bets**\n- Calculate the potential advantage:\n~~~\nedge = predicted_spread - market_spread\n~~~\n- Validate to an advantage between 4.0 and 10.0 spread differential:\n~~~\nif abs(edge) \u003c 4.0 or abs(edge) \u003e 10.0:\n    return False\n~~~\n**4. Wager Determination**\n- Dynamically determines bet amount based on the edge and current bankroll:\n~~~\nbase_stake = self.bankroll * 0.02\nedge_multiplier = min(1 + (edge - 4) * 0.1, 2.5)\n~~~\n**5. Evaluation and Execution**\n- P\u0026L (Profit and Loss) is determined for a particular bet\n~~~\nactual_spread = actual_score_home - actual_score_away\nwon_bet = actual_spread \u003e position['market_spread']  # For home bets\n~~~\n- Note: Payout assumes even odds (-110).\n- Trade is executed if wager amount is within the bounds of the bankroll.\n\n\n\n\n### Results\n\n**Neural Network**\n\nThe neural network we engineered succeeded in accurately predicting NFL scores after\nsufficient training.\n\nCost *(First Training Round)*: 0.51 \\\nCost *(Last Training Round)*: 0.17 \\\nRMSE Score: 2.52\n\nRandomly Selected Test Results: \\\nPredicted: -4.86, Actual: -4.50 \\\nPredicted: -2.04, Actual: -3.00 \\\nPredicted: -4.63, Actual: -2.00 \\\nPredicted: -7.35, Actual: -7.00\n\nCost Graphs Over Epochs:\n\n\u003cimg src=\"Media/cost_10.png\" alt=\"Cost Graph - 10 Epochs\" width=\"40%\"\u003e \u003cimg src=\"Media/cost_100.png\" alt=\"Cost Graph - 100 Epochs\" width=\"40%\"\u003e\n\n*From nn_test.py*\n\n**Betting System**\n\nThe overall betting system shows a substantially superior betting strategy compared to standard industry methods.\n\n\n*Backtesting Results:* \\\nSelected Bets: **181** \\\nWinning Bets: **145** \\\nWin Rate: **80.11%** \\\nTotal P\u0026L: **$25799.73** \\\nTotal Stake: **$47485.33** \\\nROI: **54.33%** \\\nAverage Bet Size: **$262.35**\n\nSample Betting Opportunities:\n\nGame: Philadelphia Eagles vs San Francisco 49ers \\\nMarket Spread: 3.5 \\\nPredicted Spread: -4.1 \\\nEdge: 7.6 points \\\nBet Side: away \\\nRecommended Stake: $271.49 \n\nGame: Los Angeles Rams vs Tampa Bay Buccaneers \\\nMarket Spread: 1.0 \\\nPredicted Spread: -3.6 \\\nEdge: 4.6 points \\\nBet Side: away \\\nRecommended Stake: $212.24 \n\nGame: New England Patriots vs New Orleans Saints \\\nMarket Spread: 3.0 \\\nPredicted Spread: -5.2 \\\nEdge: 8.2 points \\\nBet Side: away \\\nRecommended Stake: $284.28\n\n*From test_betting_system.py*","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblakeziegler%2Fnfl-ai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fblakeziegler%2Fnfl-ai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblakeziegler%2Fnfl-ai/lists"}