A beginner-friendly collection of basic AI and machine learning algorithms for learning. This repository contains hands-on Jupyter notebooks in Python that implement classic search techniques, game-playing AI, probabilistic models, evolutionary algorithms, and introductory ML — ideal for students, self-learners, and anyone building a foundation in artificial intelligence.
Purpose: Basic algorithms for learning — not production libraries. Run each notebook cell-by-cell to understand how each algorithm works under the hood.
- What You Will Learn
- Topics Covered
- Repository Structure
- Prerequisites
- Getting Started
- Notebooks Guide
- Contributing
- Author
This repo helps you learn foundational AI algorithms through practical Python code:
- Graph search — BFS, DFS, UCS, GBFS, and A* pathfinding
- Local search — Hill climbing and simulated annealing
- Constraint satisfaction — N-Queens (backtracking and genetic algorithms)
- Adversarial search — Minimax for Tic-Tac-Toe
- Probabilistic AI — Hidden Markov Models (HMM)
- Machine learning — Supervised and unsupervised learning with scikit-learn
- Neural networks — From-scratch forward pass and sigmoid activation
| Category | Algorithms & Concepts |
|---|---|
| Uninformed Search | Breadth-First Search (BFS), Depth-First Search (DFS), Uniform Cost Search (UCS) |
| Informed Search | Greedy Best-First Search (GBFS), A* Algorithm |
| Local Search | Hill Climbing, Simulated Annealing |
| CSP / Optimization | N-Queens Problem, Genetic Algorithms |
| Game AI | Minimax Algorithm, Tic-Tac-Toe AI |
| Probabilistic Models | Hidden Markov Model (HMM), Viterbi-style inference |
| Machine Learning | Decision Trees, Random Forest, Naive Bayes, K-Means, PCA |
| Neural Networks | Perceptron-style layers, weights, biases, sigmoid activation |
AI-Algorithms/
├── bfs_and_dfs.ipynb # BFS & DFS graph traversal
├── UCS.ipynb # Uniform Cost Search
├── GBFS.ipynb # Greedy Best-First Search
├── A_star_algorithm.ipynb # A* pathfinding
├── Local Searching Algorithms .ipynb # Hill climbing & simulated annealing
├── n-queen_problem.ipynb # N-Queens (backtracking)
├── genetic_algorithm .ipynb # Genetic algorithm basics
├── Genetic Algorithm implementation on N-Queen.ipynb
├── minimax_tic_tac_toe.ipynb # Minimax game AI
├── HMM.ipynb # Hidden Markov Models
├── supervised ML with sklearn.ipynb
├── Unsupervised_Learning.ipynb
├── Neural Networks.ipynb
├── titanic.csv # Sample dataset (Titanic)
└── README.md
- Python 3.8+
- Jupyter Notebook or JupyterLab
- Familiarity with basic Python and NumPy is helpful
pip install jupyter numpy pandas matplotlib scikit-learn-
Clone the repository
git clone https://github.com/danishjavedcodes/AI-Algorithms.git cd AI-Algorithms -
Launch Jupyter
jupyter notebook
-
Open a notebook from the list above and run cells in order.
-
Experiment — change graph weights, heuristics, board sizes, or hyperparameters to see how each algorithm behaves.
| Notebook | Description |
|---|---|
bfs_and_dfs.ipynb |
Implement and compare BFS and DFS on a sample graph |
UCS.ipynb |
Find lowest-cost paths with Uniform Cost Search |
GBFS.ipynb |
Greedy Best-First Search on Romania-style map graphs |
A_star_algorithm.ipynb |
A* search with admissible heuristics |
Local Searching Algorithms .ipynb |
Hill climbing and simulated annealing for optimization |
n-queen_problem.ipynb |
Solve N-Queens using backtracking |
genetic_algorithm .ipynb |
Core GA: selection, crossover, mutation |
Genetic Algorithm implementation on N-Queen.ipynb |
Apply GA to the N-Queens problem |
minimax_tic_tac_toe.ipynb |
Play Tic-Tac-Toe against a minimax AI |
HMM.ipynb |
Hidden Markov Model — states, transitions, observations |
supervised ML with sklearn.ipynb |
Classification on Titanic data (Decision Tree, RF, Naive Bayes) |
Unsupervised_Learning.ipynb |
K-Means clustering and PCA on Titanic data |
Neural Networks.ipynb |
Build a simple neural network forward pass from scratch |
artificial intelligence, AI algorithms, machine learning, search algorithms, A star, BFS, DFS, genetic algorithm, minimax, hidden markov model, neural networks, scikit-learn, python, jupyter notebook, learn AI, basic algorithms, beginner AI
Contributions are welcome. If you find a bug, want to add a notebook, or improve explanations:
- Fork the repository
- Create a feature branch (
git checkout -b improve/readme-or-notebook) - Commit your changes
- Open a Pull Request
This project is open source and intended for educational use. Feel free to use, study, and share these notebooks for learning basic AI algorithms.