{"id":20977088,"url":"https://github.com/marcnuth/genetics","last_synced_at":"2025-05-14T14:31:54.449Z","repository":{"id":57433558,"uuid":"92915495","full_name":"Marcnuth/genetics","owner":"Marcnuth","description":"Genetic Algorithm in Python, which could be used for Sampling, Feature Select, Model Select, etc in Machine Learning","archived":false,"fork":false,"pushed_at":"2019-08-19T16:03:22.000Z","size":12,"stargazers_count":15,"open_issues_count":0,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-19T01:06:38.470Z","etag":null,"topics":["feature-engineering","genetic-algorithm","machine-learning","model-selection","sampling"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Marcnuth.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}},"created_at":"2017-05-31T07:03:22.000Z","updated_at":"2024-05-29T04:26:50.000Z","dependencies_parsed_at":"2022-08-28T04:41:21.496Z","dependency_job_id":null,"html_url":"https://github.com/Marcnuth/genetics","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/Marcnuth%2Fgenetics","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Marcnuth%2Fgenetics/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Marcnuth%2Fgenetics/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Marcnuth%2Fgenetics/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Marcnuth","download_url":"https://codeload.github.com/Marcnuth/genetics/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254160648,"owners_count":22024574,"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":["feature-engineering","genetic-algorithm","machine-learning","model-selection","sampling"],"created_at":"2024-11-19T04:57:14.798Z","updated_at":"2025-05-14T14:31:54.146Z","avatar_url":"https://github.com/Marcnuth.png","language":"Python","readme":"# Introduction\n\n![PyPI - Downloads](https://img.shields.io/pypi/dm/genetics?color=lightgreen\u0026label=PyPI)\n\nGenetic Algorithm in Python, which could be used for Sampling, Feature Select, Model Select, etc in Machine Learning\n\n\n# Install\n\n```shell\n\nsudo pip3 install genetics\n\n```\n\n# Usage\n\n## API\n\n### Initialize the Object\n\n```python\nGA(train, valid, estimator, groups=100, iter=200, r_sample=0.8, r_crossover=0.5, r_vary=0.01, r_keep_best=0.1, n_jobs=4, verbose=False)\n```\n\n- train: a 2D numpy matrix, the last column will be used as the labels\n- valid: a 2D numpy matrix, which's columns should be the same as the train\n- estimator: a SKLearn estimator, such as RandomForestClassifier or SVR etc.\n- groups: the groups in every generation, default 200\n- iter: the number of iterations, the procedure will stop when reach the number. default 200\n- r_sample: useful when doing sampling, the ratio for sampling, deault 0.8\n- r_crossover: the ratio of crossover when generating a children from his parents, default 0.5\n- r_vary: the ratio for varying when generating a child from his parents, default 0.01, suggest 0 - 0.1\n- r_keep_best: the ratio for keeping the best groups in every generation, default 0.1\n- n_jobs: the number for running procedure in parallel, default 4\n- verbose: the flag for showing the verbose messages, default False\n\n\n### Sampling\n\n```python\n# Example\n\nfrom genetics import GA\n\n# the sample_result is a 2D numpy matrix, which is the result after sampling\n# the sample_genes is the gene used for selecting instances, just ignore it if you don't need it\n# the sample_scores is the final score when doing validation in valid set\n(sample_result, sample_genes, sample_scores) = GA(train, valid, RandomForestClassfier).select_instance()\n\n# Or you can do sampling by calling this\n(sample_result, sample_genes, sample_scores) = GA(train, valid, RandomForestClassfier).select(axis=0)\n\n```\n\n### Feature Selection\n\n```python\n# Example\n\nfrom genetics import GA\n\n# the sample_result is a 2D numpy matrix, which is the result after selecting feature\n# the sample_genes is the gene used for selecting features, just ignore it if you don't need it\n# the sample_scores is the final score when doing validation in valid set\n(sample_result, sample_genes, sample_scores) = GA(train, valid, RandomForestClassfier).select_feature()\n\n# Or you can select features by calling this\n(sample_result, sample_genes, sample_scores) = GA(train, valid, RandomForestClassfier).select(axis=1)\n\n```\n\n# Citation\n\n```\nZeng X, Yuan S, Huang X, et al. \nIdentification of cytokine via an improved genetic algorithm[J]. \nFrontiers of Computer Science, 2015, 9(4): 643-651.\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcnuth%2Fgenetics","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarcnuth%2Fgenetics","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcnuth%2Fgenetics/lists"}