Python Learning Week 5 (Solution)

      Task 1 Write a program in python to implement given Graph, BFS and DFS.  Output must be as given below     CODE:   graph = {     ‘E’ : [‘A’,’B’],     ‘A’ : [‘D’],     ‘B’ : [‘D’],     ‘D’ : [‘C’],     ‘C’:   [] }  #EDGE-LIST def edges(graph):     edge_list = []     for node in graph:         for neighbour in graph[node]:             edge_list.append((node, neighbour))     return edge_list #VERTEX-LIST class Vertices_list:     def __init__(self,graph_dict=None):         if graph_dict is None:             graph_dict = []         self.graph_dict = graph_dict     def get_Vertices(self):         return list(self.graph_dict.keys()) G = Vertices_list(graph) #BFS […]
Read More

Python Learning Week 6 (Solution)

Task 1 Implement Greedy Best First Search Algorithm for the given example, if starting node is Arad and goal node is Bucharest.     CODE: GRAPH = {‘Arad’:[[‘Zerind’,374],[‘Timisoara’,329],[‘Sibiu’,253]],         ‘Zerind’:[[‘Oradea’,380],[‘Arad’,366]],         ‘Oradea’:[[‘Sibiu’,253]],         ‘Sibiu’:[[‘Rimniciu Vilcea’,193],[‘Fagaras’,178],[‘Arad’,366]],         ‘Fagaras’:[[‘Sibiu’,253],[‘Bucharest’,0]],         ‘Rimniciu Vilcea’:[[‘Pitesti’,98],[‘Craiova’,160],[‘Sibiu’,253]],         ‘Timisoara’:[[‘Lugoj’,244],[‘Arad’,366]],         ‘Lugoj’:[[‘Mehadia’,241]],         ‘Mehadia’:[[‘Lugoj’,244],[‘Dorbeta’,242]],         ‘Dobreta’:[[‘Mehadia’,241],[‘Craiova’,160]],         ‘Pitesti’:[[‘Craiova’,160],[‘Bucharest’,0]],         ‘Craiova’:[[‘Pitesti’,98],[‘Dobreta’,242],[‘Rimniciu Vilcea’,193]],         ‘Bucharest’:[[‘Giurgiu’,77],[‘Urziceni’,80],[‘Fagaras’,178],[‘Pitesti’,98]],         ‘Giurgiu’: [[‘Bucharest’,0]],         ‘Urziceni’:[[‘Vaslui’,199],[‘Hirsova’,151],[‘Bucharest’,0]],         ‘Vaslui’:[[‘Lasi’,226],[‘Urziceni’,80]],         ‘Lasi’:[[‘Neamt’,234],[‘Vaslui’,199]],         ‘Neamt’:[[‘Lasi’,226]],         ‘Hirsova’:[[‘Eforie’,161],[‘Urziceni’,80]],         ‘Eforie’:[[‘Hirsova’,151]]} def gbfs(GRAPH, start, end):    […]
Read More

Python Learning Week 7

Implementation of Greedy Best First Search & A* Search Algorithm Background Heuristics can be said to be estimates of how far the goal state is. Heuristics basically predict how far the goal state maybe or how much it will cost to get to the goal state from a particular node. Greedy Breath First Search Example Pseudocode […]
Read More

Python Learning Week 8

Implementation of K-nearest Neighbor Classification Model Background Installing Panda, numpy, scipy, sklearn libraries Go to terminal in Pycharm Type pip install pandas Or you can install all by going to Settings -> Project Interpreter -> +-> sklearn -> Install Package KNN- Classifier In pattern recognition and machine learning, k-nearest neighbors (KNN) is a simple algorithm that stores […]
Read More

Python Learning Week 8 (Solution)

Task 1 Write a program to implement KNN classifier and classify given vector. (for k = 3) Age Loan Class (Defaulter) 25 40000 N 35 60000 N 45 80000 N 20 20000 N 35 120000 N 52 18000 N 23 95000 Y 40 62000 Y 60 100000 Y 48 220000 Y 33 150000 Y 48 […]
Read More

Python Learning Week 9

KNN Classifier In Artificial Learning Import data set: Creating Dependent and independent variables: Initialize the algorithm: Training and testing: Fitdoes training on Training Data (X_train, Y_Train) Predictdoes testing on Test data (X_test) and predicts outputs  Combining with predicted values with y values:
Read More

Python Learning Week 9 (Solution)

KNN Classifier In Artificial Learning Tasks Implement KNN algorithm yourself in python for Iris Dataset without using built-in KNN classifier library. Load dataset Split dataset into test and train sets Perform KNN algorithm to make predictions for k=5 Compute accuracy and confusion matrix CODE:     What we studied in Week 9:In this week we studied the […]
Read More

Python Learning Week 10

Naïve Bayes Classification Model   Background: Bayesian is one of the simplest probabilistic classifier that classifies a candidate test vector based on Bayes Rule: Lab Tasks Task 1 Develop a python program to implement Bayesian classification model for the following dataset and classify the given test vector:   Age Loan Class (Defaulter) 25 40000 0 […]
Read More

Python Learning Week 10 (Solution)

Naïve Bayes Classification Model   Tasks Task 1 Develop a python program to implement Bayesian classification model for the following dataset and classify the given test vector:   Age Loan Class(Defaulter) 25 40000 0 35 60000 0 45 80000 0 20 20000 0 35 120000 0 52 18000 0 23 95000 1 40 62000 1 […]
Read More

Python Learning Week 11

Mini Project: Adversarial Search or Playing Games with Python   Game name: Tic Tac Toe (Using: The Minimax Algorithm) Adversarial Search Examine the problems that arise when we try to plan ahead in a world where other agents are planning against us.  A good example is in board games. Adversarial games, while much studied in AI, […]
Read More