{"id":13769849,"url":"https://github.com/bergel/NEAT","last_synced_at":"2025-05-11T02:33:38.711Z","repository":{"id":140631820,"uuid":"217438410","full_name":"bergel/NEAT","owner":"bergel","description":"NEAT implementation in Pharo","archived":false,"fork":false,"pushed_at":"2020-05-08T20:14:44.000Z","size":1525,"stargazers_count":16,"open_issues_count":1,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-12T11:45:33.609Z","etag":null,"topics":["artificial-intelligence","artificial-intelligence-algorithms","neat","pharo","pharo-smalltalk"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bergel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2019-10-25T02:53:08.000Z","updated_at":"2021-03-21T03:02:31.000Z","dependencies_parsed_at":"2024-01-07T21:55:29.567Z","dependency_job_id":null,"html_url":"https://github.com/bergel/NEAT","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/bergel%2FNEAT","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bergel%2FNEAT/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bergel%2FNEAT/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bergel%2FNEAT/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bergel","download_url":"https://codeload.github.com/bergel/NEAT/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225004689,"owners_count":17405659,"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":["artificial-intelligence","artificial-intelligence-algorithms","neat","pharo","pharo-smalltalk"],"created_at":"2024-08-03T17:00:32.190Z","updated_at":"2024-11-17T05:31:42.965Z","avatar_url":"https://github.com/bergel.png","language":"Java","funding_links":[],"categories":["Artificial Intelligence and Machine Learning","Neuroevolution"],"sub_categories":[],"readme":"# Neuroevolution and NEAT\n\n[Neuroevolution](https://en.wikipedia.org/wiki/Neuroevolution) is a fantastic area that belongs to artificial intelligence. Neuroevolution is about _evolving_ neural networks to solve a particular problem. Neuroevolution differs from classical deep learning in the way a satisfactory model is obtained. Classical learning techniques for Deep Learning (e.g., backpropagation) are about _learning_, while Neuroevolution is about _evolving_ a model. \n\nNEAT is maybe the most popular neuroevolution algorithm. A description of NEAT may be found in the paper [Evolving Neural Networks through Augmenting Topologies](http://nn.cs.utexas.edu/downloads/papers/stanley.ec02.pdf).\n\nThe content of this GitHub repository is heavily inspired from the book [Agile Artificial Intelligence in Pharo: Implementing Neural Networks, Genetic Algorithms, and Neuroevolution](https://www.apress.com/gp/book/9781484253830).\n\n# NEAT4Pharo\n\nThis repository provides an implementation of NEAT for the [Pharo programming language](http://pharo.org). Many implementations of NEAT exist in a wide range of programming languages. The advantages of NEAT4Pharo is to have a relativaly small amount of source code (\u003c 1000 LOC), and it offers interactive visualization to give a better understanding of how the evolution was carried out. \n\n# Loading NEAT4Pharo\n\nExecute the following script to load the [Roassal2 visualization engine](https://github.com/ObjectProfile/Roassal2) and NEAT4Pharo:\n\n```Smalltalk\nMetacello new\n    baseline: 'Roassal2';\n    repository: 'github://ObjectProfile/Roassal2/src';\n    load.\nGofer new\n    url: 'github://bergel/NEAT/src';\n    package: 'NEAT';\n    load.\n```\n\n# Example\n\nOne of the introductory example in neural network, is to build a neural network that expresses the XOR logical gate. We can do so using NEAT. Consider the following script:\n\n```Smalltalk\nneat := NEAT new.\nneat numberOfInputs: 2.\nneat numberOfOutputs: 1.\nneat fitness: [ :ind | \n\t| score |\n\tscore := 0.\n\t#(#(0 0 0) #(0 1 1) #(1 0 1) #(1 1 0)) do: [ :tuple |\n\t\tdiff := (ind evaluate: (tuple first: 2)) first - tuple last.\n\t\tscore := score + (diff * diff) ]. \n\t(score / -4) asFloat ].\nneat numberOfGenerations: 200.\nneat run\n```\n\nThe script configure the NEAT algorithm to handles individual (i.e., neural networks) having two inputs and one output. The XOR logical gates takes two arguments and return one value. So, a neural network with 2 inputs and 1 output is sufficent to express the XOR.\n\nEvaluating the script gives the following output:\n![alt text](images/XOR-example3.png)\n\nWe see the curve of the maximum fitness reaches 0. This means that the NEAT algorithm was able to produce through evolution a neural network that express the XOR logical gate. We can veriy this:\n\n```Smalltalk\nneat result evaluate: #(0 0).\n\"Return #(0.0024744051266554854)\"\n\nneat result evaluate: #(0 1).\n\"#(0.9992445715215523)\"\n\nneat result evaluate: #(1 0).\n\"#(0.9901246518281834)\"\n\nneat result evaluate: #(1 1).\n\"#(0.006270828175993032)\"\n```\n\nIn addition to the fitness curve, inspecting the object `neat` gives additional relevant visualizations. For example, the tab `#Species` gives the evolution of the number of species during the generations:\n\n![alt text](images/XOR-Species.png)\n\nWe see that the number of species increases significantly at the begining of the algorithm execution to reach a relatively sable value around 25 species. Clicking on a dot opens the species visualization:\n\n![alt text](images/XOR-SpeciesVisualization.png)\n\nThe species visualization represents species. The size of a box is the size of the species, i.e., the number of individual that belongs to the species. The color fading indicate the fitness value of the best individual. Clicking on a species list the individuals that belongs to the species. Clicking on an individual open a visualization of the neural network\n\n![alt text](images/XOR-NeuralNetwork.png)\n\n# Let's chat\n\nJoin the [Pharo discord server](http://pharo.org/community) and join the `#ia` channel. You are also very welcome to post issues to this GitHub repository.\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbergel%2FNEAT","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbergel%2FNEAT","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbergel%2FNEAT/lists"}