An open API service indexing awesome lists of open source software.

https://github.com/amirreza81/artificial-intelligence

Solutions to practical assignments of Artificial Intelligence course (CE-417) at Sharif University of Technology
https://github.com/amirreza81/artificial-intelligence

a-star a-star-algorithm adversarial-search ai alpha-beta-pruning artificial-intelligence bayesian-networks cryptarithmetic decision-trees deep-learning logistic-regression machine-learning minimax-algorithm pytorch q-learning q-learning-vs-sarsa rainforcement-learning rl simulated-annealing simulated-annealing-algorithm

Last synced: 6 days ago
JSON representation

Solutions to practical assignments of Artificial Intelligence course (CE-417) at Sharif University of Technology

Awesome Lists containing this project

README

        

# Artificial Intelligence 🤖🧠

**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.

## Table of Contents
> - [A Star](#A\*)
> - [Simulated Annealing](#Simulated_Annealing)
> - [Cryptarithmetic Puzzle](#Cryptarithmetic_Puzzle)
> - [Adversarial Search](#Adversarial_Search)
> - [Q_Tabular](#Q_Tabular)
> - [RL_Chat](#RL_Chat)
> - [Bayesian Networks](#Bayesian_Networks)
> - [Decision Tree](#Decision_Tree)
> - [Logistic Regression](#Logistic_Regression)

* ### **A\***:
Implements the A* search algorithm to solve an elevator scheduling problem where students and professors must be transported between two floors, following specific constraints.

![A* Algorithm GIF](a_star_algorithm.gif)

**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](https://github.com/Amirreza81/Artificial-Intelligence/blob/main/A-star/A_star.ipynb) for more details.

* ### **Simulated_Annealing**:
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](https://github.com/Amirreza81/Artificial-Intelligence/blob/main/Simulated%20Annealing/Simulated_Annealing.ipynb) for more details.

* ### **Cryptarithmetic_Puzzle**:
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.

puzzle

* ### **Adversarial_Search**:
Minimax algorithm for game-playing agents with alpha-beta pruning.

* ### **Q_Tabular**:
Implementation of Q-learning with tabular updates for reinforcement learning.

* ### **RL_Chat**:
A simple chat system utilizing reinforcement learning for decision-making.

* ### **Bayesian_Networks**:
Building and inference on Bayesian networks for probabilistic reasoning.

* ### **Decision_Tree**:
Implementing decision tree algorithms for classification tasks.

* ### **Logistic_Regression**:

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**:

![Dataset](./Logistic%20Regression/images/dataset.png)
![Result](./Logistic%20Regression/images/resultLR.png)

**Second dataset**:

![Dataset](./Logistic%20Regression/images/ds2.png)
![Result](./Logistic%20Regression/images/resultLR2.png)

**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:

![Acc](./Logistic%20Regression/images/acc.png)

The result:

![res](./Logistic%20Regression/images/res.png)

## Instructor ✍
[Professor Mohammad Hossein Rohban](https://scholar.google.com/citations?user=pRyJ6FkAAAAJ&hl=en)

## Contribution 👥
Feel free to fork this repository, submit pull requests, or raise issues if you find any bugs or have suggestions for improvements.