Skip to content

codeMGL/ai-algorithms

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ai-algorithms

AI from Scratch: Building foundational AI algorithms in Python

How to run files

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> or pytest tests/<folder>/<test_file>.py

What I'm learning with this project

  • 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)

Visualizer

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 window
  • infinite canvas: Nodes are drawn at a bigger size, but not all of them can be shown at the same time

1. Search algorithms

Implementation of BFS, DFS, Dijkstra and A* algorithms from scratch

2. Binary Trees

Implementation of a Binary Search Tree (BST) with recursive in-order traversal from scratch, including visualization, insertion and recursive sorting

Possible future structure

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

About

AI from Scratch: Building foundational AI algorithms in Python

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages