AI from Scratch: Building foundational AI algorithms in Python
The project is organised on folders (search_algorithms, binary_trees, etc), ordering the different algorithms and models neatly. Each folder has it's own scripts, to run the code, and tests, to test each algorithms works properly.
- To run the script:
python -m <folder> - To run some tests:
python -m pytest tests/<folder>orpytest tests/<folder>/<test_file>.py
- How to create a medium-sized, well structured modular project
- How to correctly implement AI algorithms seen in class
- How to handle recursion on trees and functions
- How to use lambda functions in lists (i.e, sorting)
- How to run tests using Pytest
- How to add paramenters to use different algorithms using Argparse
- How to use data structures like Deque (Double-Ended Queue)
Drawing the graphs using the Reingold-Tilford algorithm and the Pygame library
How to use it? Move with the arrow keys or WASD. Scroll with your mouse to change the scale/zoom of the canvas. To toggle the drawing view, press the space bar:
scaled to fit: Nodes are drawn to make the entire graph fit on the drawing windowinfinite canvas: Nodes are drawn at a bigger size, but not all of them can be shown at the same time
Implementation of BFS, DFS, Dijkstra and A* algorithms from scratch
Implementation of a Binary Search Tree (BST) with recursive in-order traversal from scratch, including visualization, insertion and recursive sorting
ai-algorithms/
├── README.md
├── search_algorithms/
│ ├── __init__.py
│ ├── bfs.py
│ ├── dfs.py
│ ├── dijkstra.py
│ ├── astar.py
│ └── examples/
│ └── maze_solver.py
├── binary_trees/
│ ├── __init__.py
│ ├── binary_tree.py
│ ├── bst.py
│ └── examples/
│ └── word_search.py
├── decision_trees/
│ ├── __init__.py
│ ├── id3.py
│ ├── one_r.py
│ └── examples/
│ └── classifier.py
├── production_systems/
│ ├── __init__.py
│ ├── inference_engine.py
│ ├── facts/
│ │ └── animals.pl
│ └── examples/
│ └── animal_classifier.py
├── uncertainty/
│ ├── __init__.py
│ ├── bayesian_network.py
│ ├── markov_chain.py
│ ├── hmm.py
│ ├── mdp.py
│ └── examples/
│ ├── weather_prediction.ipynb
│ └── grid_world.ipynb
├── utils/
│ ├── __init__.py
│ └── visualizer.py
└── tests/
├── __init__.py
├── search_algorithms/
│ ├── __init__.py
│ └── test_bfs.py
├── binary_trees/
│ ├── __init__.py
│ └── test_binary_tree.py
├── decision_trees/
│ ├── __init__.py
│ └── test_id3.py
├── production_systems/
│ ├── __init__.py
│ └── test_inference_engine.py
└── uncertainty/
├── __init__.py
└── test_bayesian_network.py