{"id":30548487,"url":"https://github.com/jespb/python-stdgp","last_synced_at":"2025-08-28T03:08:06.022Z","repository":{"id":132774094,"uuid":"220104399","full_name":"jespb/Python-StdGP","owner":"jespb","description":"An easy-to-use scikit-learn inspired implementation of the Standard Genetic Programming (StdGP) algorithm.","archived":false,"fork":false,"pushed_at":"2025-04-24T05:04:55.000Z","size":39,"stargazers_count":8,"open_issues_count":0,"forks_count":9,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-24T06:19:51.568Z","etag":null,"topics":["binary-classification","classification","evolutionary-algorithms","evolutionary-computation","genetic-programming","machine-learning","regression-algorithms","regression-models","regression-trees"],"latest_commit_sha":null,"homepage":"","language":"Python","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/jespb.png","metadata":{"files":{"readme":"README.txt","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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-11-06T22:44:16.000Z","updated_at":"2025-04-24T05:04:58.000Z","dependencies_parsed_at":null,"dependency_job_id":"e85f8149-277c-48d0-8f4d-01922bebca6e","html_url":"https://github.com/jespb/Python-StdGP","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jespb/Python-StdGP","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jespb%2FPython-StdGP","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jespb%2FPython-StdGP/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jespb%2FPython-StdGP/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jespb%2FPython-StdGP/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jespb","download_url":"https://codeload.github.com/jespb/Python-StdGP/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jespb%2FPython-StdGP/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272426363,"owners_count":24933023,"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","status":"online","status_checked_at":"2025-08-28T02:00:10.768Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["binary-classification","classification","evolutionary-algorithms","evolutionary-computation","genetic-programming","machine-learning","regression-algorithms","regression-models","regression-trees"],"created_at":"2025-08-28T03:08:05.387Z","updated_at":"2025-08-28T03:08:06.012Z","avatar_url":"https://github.com/jespb.png","language":"Python","readme":"This is a, easy-to-use, scikit-learn inspired version of the Standard Genetic Programming (StdGP) algorithm.\n\n\nBy using this file, you are agreeing to this product's EULA\nThis product can be obtained in https://github.com/jespb/Python-StdGP\nCopyright ©2019-2025 J. E. Batista\n\n\nThis file contains information about the command and flags used in the stand-alone version of this implementation and an explanation on how to import, use and edit this implementation.\n\n\nThis implementation of StdGP can be used in a stand-alone fashion using the following command and flags:\n\n$ python Main_StdGP_standalone.py\n\t\n\t[-d datasets] \n\t\t- This flag expects a set of csv dataset names separated by \";\" (e.g., a.csv;b.csv)\n\t\t- By default, the heart.csv dataset is used\t\t\n\n\t[-dsdir dir] \n\t\t- States the dataset directory. \n\t\t- By default \"datasets/\" is used \n\t\t- Use \"-dsdir ./\" for the root directory\t\n\n\t[-es elite_size]\n\t\t- This flag expects an integer with the elite size;\n\t\t- By default, the elite has size 1.\n\n\t[-md max_depth]\n\t\t- This flag expects an integer with the maximum initial depth for the trees;\n\t\t- By default, this value is set to 6.\t\t\n\n\t[-mg max_generation]\n\t\t- This flag expects an integer with the maximum number of generations;\n\t\t- By default, this value is set to 100.\n\n\t[-odir dir] \n\t\t- States the output directory. \n\t\t- By default \"results/\" is used \n\t\t- Use \"-odir ./\" for the root directory\n\t\n\t[-op operators]\n\t\t- This flag excepts a set of operators separated by \";\"\n\t\t- Allowed operators: +;-;*;/\n\t\t- By default, the used operators are the sum, subtraction, multiplication and protected division.\t\t\n\n\t[-ps population_size]\n\t\t- This flag expects an integer with the size of the population;\n\t\t- By default, this value is set to 500.\n\n\t[-runs number_of_runs] \n\t\t- This flag expects an integer with the number of runs to be made;\n\t\t- By default, this values is set to 30\n\t\n\t[-tf train_fraction]\n\t\t- This flag expects a float [0;1] with the fraction of the dataset to be used in training;\n\t\t- By default, this value is set to 0.70\n\t\n\t[-ts tournament_size]\n\t\t- This flag expects an integer with the tournament size;\n\t\t- By default, this value is set to 10.\n\n\t[-t number_of_threads]\n\t\t- This flag expects an integer with the number of threads to use while evaluating the population;\n\t\t- If the value is set to 1, the multiprocessing library will not be used \n\t\t- By default, this value is set to 1.\n\n\n\n\n\t\n\n\nHow to import this implementation to your project:\n\t- Download this repository;\n\t- Copy the \"stgp/\" directory to your project directory;\n\t- import the STGP class using \"from stgp.STGP import STGP\".\n\nHow to use this implementation:\n\t$ from stdgp.StdGP import StdGP\n\t$ model = StdGP()\n\t$ model.fit( training_x, training_y)\n\nArguments for StdGP():\n\toperators\t\t\t-\u003e Operators used by the individual (default: [\"+\",\"-\",\"*\",\"/\"] )\n\tmax_depth\t\t\t-\u003e Max initial depths of the individuals (default: 6)\n\tpopulation_size\t\t-\u003e Population size (default: 500)\n\tmax_generation\t\t-\u003e Maximum number of generations (default: 100)\n\ttournament_size\t\t-\u003e Tournament size (default: 5)\n\telitism_size\t\t-\u003e Elitism selection size (default: 1)\n\tlimit_depth\t\t\t-\u003e Maximum individual depth (default: 17)\n\tthreads \t\t\t-\u003e Number of CPU threads to be used (default: 1)\n\nArguments for model.fit():\n\tTr_X \t\t\t\t-\u003e Training samples\n\tTr_Y \t\t\t\t-\u003e Training labels\n\tTe_X \t\t\t\t-\u003e Test samples, used in the standalone version (default: None)\n\tTe_Y \t\t\t\t-\u003e Test labels, used in the standalone version (default: None)\n\n\nUseful methods:\n\t$ model = StdGP()\t\t\t-\u003e starts the model;\n\t$ model.fit(X, Y)\t\t\t-\u003e fits the model to the dataset;\n\t$ model.predict(dataset)    -\u003e Returns a list with the prediction of the given dataset.\n\n\n\n\nHow to edit this implementation:\n\tFitness Function ( stdgp.Individual ):\n\t\t- Change the getFitness() method to use your own fitness function;\n\t\t- This implementation assumes that a higher fitness is always better. To change this, edit the __gt__ method in this class;\n\t\t- You may use the getTrainingPredictions() and getTrainingSet() to obtain the models prediction and the training set;\n\t\t- You can also explore the behind the standard fitness function;\n\t\t- Warning: StdGP evaluates every model in every run, as such, I do not recomend complex fitness functions. You should invest in fast evaluation methods to train a population.\n\n\tClassification method ( stdgp.Individual ):\n\t\t- Change the trainModel() method to use your own classifier;\n\t\t- Assuming it is a scykit-learn implementation, you may only need to change the first few lines of this method;\n\t\t- Warning: StdGP evaluates every model in every run, as such, I do not recomend complex classification model. You should invest in fast classification methods to train a population and the use a more complex method (if you wish) on the final model.\n\n\n\nIf you use this implementation, please cite one of the following works where it is used:\n\n@article{BATISTA2025101761,\n\ttitle = {Complexity, interpretability and robustness of GP-based feature engineering in remote sensing},\n\tjournal = {Swarm and Evolutionary Computation},\n\tvolume = {92},\n\tpages = {101761},\n\tyear = {2025},\n\tissn = {2210-6502},\n\tdoi = {https://doi.org/10.1016/j.swevo.2024.101761},\n\turl = {https://www.sciencedirect.com/science/article/pii/S2210650224002992},\n\tauthor = {João E. Batista and Adam K. Pindur and Ana I.R. Cabral and Hitoshi Iba and Sara Silva},\n}\n\n@article{Rodrigues2023,\n  title = {Exploring SLUG: Feature Selection Using Genetic Algorithms and Genetic Programming},\n  volume = {5},\n  ISSN = {2661-8907},\n  url = {http://dx.doi.org/10.1007/s42979-023-02106-3},\n  DOI = {10.1007/s42979-023-02106-3},\n  number = {1},\n  journal = {SN Computer Science},\n  publisher = {Springer Science and Business Media LLC},\n  author = {Rodrigues,  Nuno M. and Batista,  João E. and Cava,  William La and Vanneschi,  Leonardo and Silva,  Sara},\n  year = {2023},\n  month = dec \n}\n\n@inproceedings{10.1145/3520304.3533946,\n\tauthor = {Batista, Jo\\~{a}o E. and Silva, Sara},\n\ttitle = {Evolving a cloud-robust water index with genetic programming},\n\tyear = {2022},\n\tisbn = {9781450392686},\n\tpublisher = {Association for Computing Machinery},\n\taddress = {New York, NY, USA},\n\turl = {https://doi.org/10.1145/3520304.3533946},\n\tdoi = {10.1145/3520304.3533946},\n\tbooktitle = {Proceedings of the Genetic and Evolutionary Computation Conference Companion},\n\tpages = {55–56},\n\tnumpages = {2},\n\tlocation = {Boston, Massachusetts},\n\tseries = {GECCO '22}\n}\n\n\n\n\n\nReference:\n    Poli, R., Langdon, W.B., McPhee, N.F.: A Field Guide to Genetic Programming. Lulu Enterprises, UK Ltd (2008)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjespb%2Fpython-stdgp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjespb%2Fpython-stdgp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjespb%2Fpython-stdgp/lists"}