{"id":16210948,"url":"https://github.com/rehan-ankalgi-7t2/ai-ml-lab-programs","last_synced_at":"2025-04-07T21:27:05.636Z","repository":{"id":60042726,"uuid":"422028008","full_name":"rehan-ankalgi-7t2/AI-ML-lab-programs","owner":"rehan-ankalgi-7t2","description":"(VTU) aritficial Intelligence and machine learning practical programs and algorithms","archived":false,"fork":false,"pushed_at":"2022-09-24T07:06:37.000Z","size":389,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-13T22:51:51.510Z","etag":null,"topics":["algorithm","artificial-intelligence","astar-algorithm","backpropagation-learning-algorithm","candidate-elimination","decision-tree","id3-algorithm","kmeans-clustering","knearest-neighbor-algorithm","locally-weighted-regression","machine-learning","naive-bayes-classifier","neural-network","search-algorithm"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rehan-ankalgi-7t2.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-10-28T01:36:54.000Z","updated_at":"2024-12-15T05:46:17.000Z","dependencies_parsed_at":"2022-09-25T23:31:00.100Z","dependency_job_id":null,"html_url":"https://github.com/rehan-ankalgi-7t2/AI-ML-lab-programs","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rehan-ankalgi-7t2%2FAI-ML-lab-programs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rehan-ankalgi-7t2%2FAI-ML-lab-programs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rehan-ankalgi-7t2%2FAI-ML-lab-programs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rehan-ankalgi-7t2%2FAI-ML-lab-programs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rehan-ankalgi-7t2","download_url":"https://codeload.github.com/rehan-ankalgi-7t2/AI-ML-lab-programs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247731673,"owners_count":20986703,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["algorithm","artificial-intelligence","astar-algorithm","backpropagation-learning-algorithm","candidate-elimination","decision-tree","id3-algorithm","kmeans-clustering","knearest-neighbor-algorithm","locally-weighted-regression","machine-learning","naive-bayes-classifier","neural-network","search-algorithm"],"created_at":"2024-10-10T10:45:00.764Z","updated_at":"2025-04-07T21:27:05.614Z","avatar_url":"https://github.com/rehan-ankalgi-7t2.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Artificial Intelligence and Machine Learning laboratory\n\n# Dev Environment instructions\n\n# requirements\n\n- visual studio code / jupyter notebook\n- install jupyter notebook extension on vs code\n- python extension\n- pip\n- python 3\n\n## Experiment 1: A* Search Algorithm\n\nA* Algorithm in Python or in general is basically an artificial intelligence problem used for the pathfinding \\(from point A to point B\\) and the Graph traversals. This algorithm is flexible and can be used in a wide range of contexts.\n\nA* Search algorithm is one of the best and popular technique used in path-finding and graph traversals.\n\nThis Algorithm is the advanced form of the BFS algorithm \\(Breadth-first search\\), which searches for the shorter path first than, the longer paths. It is a complete as well as an **optimal** solution for solving path and grid problems.\n\n**Optimal** – find the least cost from the starting point to the ending point. Complete – It means that it will find all the available paths from start to end.\n\n### Basic concepts of A*\n\n**f\\(n\\) = g\\(n\\) + h\\(n\\)**\n\nWhere\n\n- g\\(n\\) : The actual cost path from the start node to the current node.\n- h\\( n\\) : The actual cost path from the current node to goal node.\n- f\\(n\\) : The actual cost path from the start node to the goal node.\n\nFor the implementation of A* algorithm we have to use two arrays namely OPEN and CLOSE.\n\n**OPEN:**\n\nAn array that contains the nodes that have been generated but have not been yet examined till yet.\n\n**CLOSE:**\n\nAn array which contains the nodes which are examined.\n\n### Algorithm\n\n### Output\n\n![path from node A to node G](images/experiment1a.png)\n![path from node C to node G](images/experiment1b.png)\n\n## Experiment 2: Candidate Elimination Algorithm\n\n#### Problem Statement\n\nFor a given set of training data examples stored in a CSV file, implement and demonstrate that Candidate-Elimination Algorithm to output a description of the set of all hypothesis consistent with the training examples.\n\n#### Task\n\nThe Candidate-Elimination algorithm computes the VERSION SPACE containing all hypothesis from H that are consistent with an observed sequence of training examples.\n\n#### Dataset: finds.csv\n\n| Sky     | AirTemp   | Humidity   | Wind     | Water   | Forecast   | EnjoySport   |\n| :---    | :---      | :---       | :---     | :---    | :---       | :---         |\n| Sunny   | Warm      | Normal     | Strong   | Warm    | same       | Yes          |\n| Sunny   | Warm      | High       | Strong   | Warm    | same       | Yes          |\n| Rainy   | Cold      | High       | Strong   | Warm    | change     | No           |\n| Sunny   | Warm      | High       | Strong   | Warm    | change     | Yes          |\n\n#### Expected Output\n\n`Final S: ['Sunny' 'Warm' '?' 'Strong' '?' '?']\nFinal G: [['Sunny', '?', '?', '?', '?', '?'], ['?', 'Warm', '?', '?', '?', '?']]`\n\n#### Actual Output screenshot\n\n![Final S and Final G](images/experiment2.png)\n\n## Experiment 3: ID3 Algorithm\n\n#### Problem Statement\n\nWrite a program to demonstrate the working of the decision tree based ID3 Algorithm. use an appropriate dataset for building the decision tree and apply this knowledge to classify a new sample.\n\n#### Task\n\nID3 determines the information gain for each candidate attribute the selects the one with highest information gain as the root node of the tree. the information gain values for all the four attributes are calculated using the following formula:\n`IG = -{( P / P+N )log2( P / P+N ) + ( N / P+N )log2( N / P+N )}`\n\nentropy: `Entropy(A) = IG(PiNi) * P(A)`\n\n#### Dataset: Weather.csv\n\n| Day | Outlook  | Temperature | Humidity | Wind   | PlayTennis |\n| :---| :---     | :---        | :---     | :---   | :---       |\n| 1   | Sunny    | Hot         | High     | Weak   | No         |\n| 2   | Sunny    | Hot         | High     | Strong | No         |\n| 3   | Overcast | Hot         | High     | Weak   | Yes        |\n| 4   | Rain     | Mild        | High     | Weak   | Yes        |\n| 5   | Rain     | Cool        | Normal   | Weak   | Yes        |\n| 6   | Rain     | Cool        | Normal   | Strong | No         |\n| 7   | Overcast | Cool        | Normal   | Strong | Yes        |\n| 8   | Sunny    | Mild        | High     | Weak   | No         |\n| 9   | Sunny    | Cool        | Normal   | Weak   | Yes        |\n| 10  | Rain     | Mild        | Normal   | Weak   | Yes        |\n| 11  | Sunny    | Mild        | Normal   | Strong | Yes        |\n| 12  | Overcast | Mild        | High     | Strong | Yes        |\n| 13  | Overcast | Hot         | Normal   | Weak   | Yes        |\n| 14  | Rain     | Mild        | High     | Strong | No         |\n\n## Experiment 5: Back Propagation Algorithm\n\nThe Back Propagation algorithm learns the weights for a multilayer network, **it employes gradient descent to attempt to minimize the sqaured error**\n\n#### Problem statement\n\nCreate an AI Network using **Back Propagation** Algorithm\n\n#### Tasks\n\n- [x] import required libraries\n- [x] Sigmoid function\n- [x] derivative of sigmoid function\n- [x] Variable initialization\n- [x] initialize weights and bias\n- [x] forward propagation\n- [x] back propagation\n\n#### input:\n\n`\n[[0.66666667 1.        ]\n [0.33333333 0.55555556]\n [1.         0.66666667]]\n`\n\n#### Actual Output:\n\n`\n[[0.92]\n [0.86]\n [0.89]]\n`\n\n#### Predicted Output:\n\n`\n[[0.91577318]\n [0.90864649]\n [0.91742677]]\n`\n\n## experiment 6: KMeans and EM Clustering\n\n#### Problem statement\n\nClutering based on EM algorithm and K-means\n\n#### Tasks\n\n- [x] import required libraries\n- [x] import data\n- [x] visualize clustering results\n- [x] plot original classification using petal features\n- [x] plot model classifications\n- [x] General EM for GMM\n- [x] transform data such that its distribution will have **mean value: 0** and **standard deviation: 1**\n\n#### Output\n\n**Real Cluster**\n![Real Cluster](/images/KMeansOgClassification.png)\n\n**KMeans Clustering**\n![KMeans Cluster](/images/KMeansModelClassification.png)\n\n**GMM Cluster**\n![GMM Cluster](/images/GMMClustering.png)\n\n## experiment 7: K nearest neighbor\n\n#### Problem statement\n\nwrite a program to implement K-nearest neighbors algorithm to classify the **iris dataset**, print both... correct and wrong predictions\n\n#### Tasks\n\n- [x] import required packages\n- [x] load dataset\n- [x] split into data **train** and **test** samples\n- [x] print labels\n- [x] create object of KNN Classifier\n- [x] perform training\n- [x] perform testing\n- [x] display results\n\n#### Output:\n\nResult of classification using KNN with k=1\n| Sample: | value             | Actual-label: | Value  | Predicted-label: | Value                           |\n| :------ | :----             | :------------ | :----  | :--------------- | :----                           |\n| Sample: | [6.3 2.5 5.  1.9] | Actual-label: | 2      | Predicted-label: | [2 0 1 2 1 0 2 1 1 2 0 1 0 2 1] |\n| Sample: | [5.4 3.9 1.7 0.4] | Actual-label: | 0      | Predicted-label: | [2 0 1 2 1 0 2 1 1 2 0 1 0 2 1] |\n| Sample: | [6.3 3.3 4.7 1.6] | Actual-label: | 1      | Predicted-label: | [2 0 1 2 1 0 2 1 1 2 0 1 0 2 1] |\n| Sample: | [5.8 2.7 5.1 1.9] | Actual-label: | 2      | Predicted-label: | [2 0 1 2 1 0 2 1 1 2 0 1 0 2 1] |\n| Sample: | [6.4 2.9 4.3 1.3] | Actual-label: | 1      | Predicted-label: | [2 0 1 2 1 0 2 1 1 2 0 1 0 2 1] |\n| Sample: | [5.1 3.5 1.4 0.3] | Actual-label: | 0      | Predicted-label: | [2 0 1 2 1 0 2 1 1 2 0 1 0 2 1] |\n| Sample: | [5.7 2.5 5.  2. ] | Actual-label: | 2      | Predicted-label: | [2 0 1 2 1 0 2 1 1 2 0 1 0 2 1] |\n| Sample: | [6.1 3.  4.6 1.4] | Actual-label: | 1      | Predicted-label: | [2 0 1 2 1 0 2 1 1 2 0 1 0 2 1] |\n| Sample: | [5.  2.  3.5 1. ] | Actual-label: | 1      | Predicted-label: | [2 0 1 2 1 0 2 1 1 2 0 1 0 2 1] |\n| Sample: | [6.9 3.1 5.1 2.3] | Actual-label: | 2      | Predicted-label: | [2 0 1 2 1 0 2 1 1 2 0 1 0 2 1] |\n| Sample: | [5.  3.5 1.3 0.3] | Actual-label: | 0      | Predicted-label: | [2 0 1 2 1 0 2 1 1 2 0 1 0 2 1] |\n| Sample: | [6.  2.2 4.  1. ] | Actual-label: | 1      | Predicted-label: | [2 0 1 2 1 0 2 1 1 2 0 1 0 2 1] |\n| Sample: | [5.  3.4 1.6 0.4] | Actual-label: | 0      | Predicted-label: | [2 0 1 2 1 0 2 1 1 2 0 1 0 2 1] |\n| Sample: | [7.4 2.8 6.1 1.9] | Actual-label: | 2      | Predicted-label: | [2 0 1 2 1 0 2 1 1 2 0 1 0 2 1] |\n| Sample: | [5.4 3.  4.5 1.5] | Actual-label: | 1      | Predicted-label: | [2 0 1 2 1 0 2 1 1 2 0 1 0 2 1] |\n| Classification Accuracy: | 1.0 |\n\n## experiment 8: Locally Weighted Regression\n\nNon parametric locally weighted regression algorithm in order to fir data points\n\n#### Output\n\n![locally weighted regression](/images/locallyweightedregression.png)\n\n## experiment 9: Naive Bayesian classifier\n\n#### Output\n\n`Split 768 rows into train=514 and test=254 rows, Accuracy of the classifier is : 75.59055118110236%`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frehan-ankalgi-7t2%2Fai-ml-lab-programs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frehan-ankalgi-7t2%2Fai-ml-lab-programs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frehan-ankalgi-7t2%2Fai-ml-lab-programs/lists"}