Solutions to practical assignments of Artificial Intelligence course (CE-417) at Sharif University of Technology
This repository contains solutions for the practical assignments given in the AI course, covering various essential topics in artificial intelligence. Each assignment implements a specific AI technique or algorithm to solve real-world problems, showcasing the theoretical concepts in action.
-
Implements the A* search algorithm to solve an elevator scheduling problem where students and professors must be transported between two floors, following specific constraints.
Problem Description: The elevator needs to move students and professors between two floors with the following constraints:
- No floor should have more students than professors (if professors are present).
- The solution must ensure that all students and professors are transferred safely across floors.
Approach: The problem is represented as a graph, where each state is described by the number of students and professors on each floor, and the position of the elevator. A* uses a heuristic to search for the optimal path from the initial to the final state, ensuring efficiency and optimality.
Comparison with DFS:
The A* algorithm outperforms DFS in terms of finding shorter paths, thanks to its heuristic function, though it explores more states.See this file for more details.
-
Demonstrates optimization using the Simulated Annealing algorithm for solving the Knapsack problem.
Problem Description: The Knapsack problem involves selecting a subset of items with specific weights and values to maximize the total value without exceeding a given weight limit.
Approach: Simulated Annealing is a probabilistic algorithm that explores the solution space by accepting worse solutions with decreasing probability over time (as the temperature cools). This helps escape local optima and leads to a near-optimal solution.
Results:
The algorithm finds an average best solution with a value of approximately 2595.05 over multiple runs, demonstrating its effectiveness in solving the Knapsack problem.See this file for more details.
-
The Cryptarithmetic Puzzle is a puzzle where the digits of some numbers are replaced with letters to make a mathematical equation. Each letter represents a unique digit from 0 to 9 (in case of base 10). The puzzle has the following constraints:
- Each letter can be replaced by a digit from 0 to 9 (in case of base 10), but no digit can be used twice.
- Each letter must be replaced by the same digit throughout the puzzle.
- The leftmost digit of each number cannot be zero.
-
Minimax algorithm for game-playing agents with alpha-beta pruning.
-
Implementation of Q-learning with tabular updates for reinforcement learning.
-
A simple chat system utilizing reinforcement learning for decision-making.
-
Building and inference on Bayesian networks for probabilistic reasoning.
-
Implementing decision tree algorithms for classification tasks.
-
In this notebook I implemented Logistic Regression from scratch. First I implemented all the needed function in order to use Logistic Regression. After that I tested my implementation on a dummy dataset and visualize the model boundary. Then I did the same on a tweet sentiment classification dataset.
Steps: - Creating Dummy Dataset - Implementing model - Implementing training - Training on a Tweet Sentiment Analysis Dataset (Ungraded)
First dataset:
Second dataset:
Tweet Sentiment Analysis Dataset:
In this part I used the logistic regression model I implemented to classify whether a tweet contains a postivie or negative sentiment.
The accuracy:
The result:
Professor Mohammad Hossein Rohban
Feel free to fork this repository, submit pull requests, or raise issues if you find any bugs or have suggestions for improvements.