{"id":26537446,"url":"https://github.com/mbeps/machine-learning-pacman-classifier-coursework","last_synced_at":"2025-03-21T22:30:14.440Z","repository":{"id":282527132,"uuid":"927948575","full_name":"mbeps/machine-learning-pacman-classifier-coursework","owner":"mbeps","description":"The project implements a neural network classifier with advanced techniques like batch normalisation, dropout, and gradient clipping to control Pacman's movements based on the game state.","archived":false,"fork":false,"pushed_at":"2025-02-18T20:44:23.000Z","size":307,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-15T07:54:50.432Z","etag":null,"topics":["artificial-intelligence","backpropagation","batch-normalization","deep-learning","gradient-descent","machine-learning","neural-networks"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mbeps.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2025-02-05T20:03:51.000Z","updated_at":"2025-03-14T19:32:38.000Z","dependencies_parsed_at":"2025-03-15T07:54:58.576Z","dependency_job_id":"9bc8f396-94ab-413d-8113-e67a23044ba1","html_url":"https://github.com/mbeps/machine-learning-pacman-classifier-coursework","commit_stats":null,"previous_names":["mbeps/machine-learning-pacman-classifier-coursework"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mbeps%2Fmachine-learning-pacman-classifier-coursework","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mbeps%2Fmachine-learning-pacman-classifier-coursework/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mbeps%2Fmachine-learning-pacman-classifier-coursework/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mbeps%2Fmachine-learning-pacman-classifier-coursework/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mbeps","download_url":"https://codeload.github.com/mbeps/machine-learning-pacman-classifier-coursework/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244879577,"owners_count":20525445,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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","backpropagation","batch-normalization","deep-learning","gradient-descent","machine-learning","neural-networks"],"created_at":"2025-03-21T22:30:13.609Z","updated_at":"2025-03-21T22:30:14.320Z","avatar_url":"https://github.com/mbeps.png","language":"Python","readme":"# Pacman Movement Classifier\n\nThis project implements a custom neural network classifier to control Pacman's movements. The classifier decides Pacman's next move based on the game state, which includes information about nearby walls, food, and ghosts. The implementation focuses on machine learning principles rather than optimal game performance.\n\nThe solution features a sophisticated neural network with batch normalisation, dropout regularisation, and momentum-based optimisation. While simpler approaches like k-NN or Naive Bayes could work, this implementation demonstrates advanced classification techniques with proper software engineering practices.\n\n# Technical Features\n\n## Core Classification Architecture\n- Feed-forward neural network with configurable hidden layers\n- ReLU activation functions for hidden layers\n- Softmax output layer for 4-class movement prediction\n- He initialisation for weights\n\n## Optimisation Techniques\n- Mini-batch gradient descent\n- Momentum-based updates with velocity tracking\n- Inverse scaling learning rate decay\n- L2 regularisation\n- Gradient clipping with norm thresholding\n\n## Regularisation Methods\n- Batch Normalisation\n  - Running mean/variance tracking\n  - Learnable scale (gamma) and shift (beta) parameters\n  - Training/inference mode handling\n- Dropout\n  - Inverted dropout scaling\n  - Configurable dropout rate\n\n## Training Management\n- Early stopping with validation monitoring\n- Automatic hyperparameter optimisation via grid search\n- Train/validation/test split (80/10/10)\n- Best model checkpointing\n\n## Implementation Features\n- Type hints throughout codebase\n- Numerical stability safeguards\n- Comprehensive error handling\n- Memory efficient operations\n- Legal move validation and filtering\n- Fallback strategies for edge cases\n\n# Requirements\n- Conda \n- Poetry with Python 3.10 or above\n\n# Usage\n\n## Using Conda\nSince this project uses standard Python packages available in Anaconda, no additional installation is needed.\n\n1. Run Pacman with the classifier:\n```bash\npython pacman.py --pacman ClassifierAgent\n```\n\n## Using Poetry\n1. Install dependencies:\n```bash\npoetry install\n```\n\n2. Run Pacman with the classifier:\n```bash\npoetry run python pacman.py --pacman ClassifierAgent\n```\n\nAdditional Commands:\n```bash\n# Play manually using keyboard\npython pacman.py\n\n# Run with a random agent\npython pacman.py --pacman RandomAgent\n\n# Generate training data while playing\npython pacman.py --p TraceAgent\n```\n\n# Sources\n- https://machinelearningmastery.com/gradient-descent-with-momentum-from-scratch/\n- https://optimization.cbe.cornell.edu/index.php?title=Momentum\n- https://machinelearningmastery.com/understand-the-dynamics-of-learning-rate-on-deep-learning-neural-networks/\n- https://arxiv.org/abs/1908.01878\n- https://towardsdatascience.com/early-stopping-a-cool-strategy-to-regularize-neural-networks-bfdeca6d722e/\n- https://www.datacamp.com/tutorial/loss-function-in-machine-learning\n- https://www.datacamp.com/tutorial/batch-normalization-tensorflow\n- https://towardsdatascience.com/dropout-in-neural-networks-47a162d621d9/\n- https://builtin.com/machine-learning/relu-activation-function\n- https://www.analyticsvidhya.com/blog/2021/04/introduction-to-softmax-for-neural-network/\n- https://arxiv.org/abs/1502.01852\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmbeps%2Fmachine-learning-pacman-classifier-coursework","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmbeps%2Fmachine-learning-pacman-classifier-coursework","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmbeps%2Fmachine-learning-pacman-classifier-coursework/lists"}