{"id":18762635,"url":"https://github.com/deephyper/metalgpy","last_synced_at":"2025-04-13T03:32:22.470Z","repository":{"id":37825723,"uuid":"442876460","full_name":"deephyper/metalgpy","owner":"deephyper","description":"A library to write algorithms manipulating other algorithms. MetalgPy stands for Meta-Algorithm with Python.","archived":false,"fork":false,"pushed_at":"2022-07-14T21:19:11.000Z","size":186,"stargazers_count":2,"open_issues_count":2,"forks_count":1,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-26T21:38:20.233Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/deephyper.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":"2021-12-29T19:55:34.000Z","updated_at":"2022-06-19T23:30:39.000Z","dependencies_parsed_at":"2022-06-23T08:59:29.350Z","dependency_job_id":null,"html_url":"https://github.com/deephyper/metalgpy","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deephyper%2Fmetalgpy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deephyper%2Fmetalgpy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deephyper%2Fmetalgpy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deephyper%2Fmetalgpy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/deephyper","download_url":"https://codeload.github.com/deephyper/metalgpy/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248643008,"owners_count":21138354,"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":[],"created_at":"2024-11-07T18:22:31.909Z","updated_at":"2025-04-13T03:32:22.189Z","avatar_url":"https://github.com/deephyper.png","language":"Python","readme":"# Meta Algorithm in Python (MetalgPy)\n\nWhat if we could write a program that generates programs? Inspired by Automated Machine Learning research.\n\n\u003e :warning: **Experimental**: Contributions are welcome!\n\n## Installation\n\n```console\npip install metalgpy\n```\n\n## Quickstart\n\nA simple but detailed example:\n\n```python\nimport warnings\nwarnings.filterwarnings(\"ignore\")\n\nimport metalgpy as mpy\n\n# the @mpy.meta decorator transform an original python code \n# into a meta-program. f is now symbolizing the original python code\n@mpy.meta\ndef f(x):\n    return x**2\n\n# program is a symbol representing the call to f (original python code)\n# where the input is a symbol representing a variable List (categorical decision variable)\nprogram = f(mpy.Float(0, 10))\nprint(\"Program: \", program, end=\"\\n\\n\")\n\n# the choice method returns the variable symbols of the symbolized program\nchoices = program.choices()\nprint(\"Variable Space: \", choices)\n\n# optimize the program\nfor i, eval in mpy.sample(program, size=100):\n\n    sample_program = program.clone().freeze(eval.x)\n    y = sample_program.evaluate()\n    print(f\"{i:02d} -\u003e {sample_program} = {y}\")\n\n    eval.report(y)\n```\n\ngives the following output:\n\n```console\nProgram:  f(Float(id=0, low=0, high=10))\n\nVariable Space:  {'0': Float(id=0, low=0, high=10)}\n\n01 -\u003e f(1.4883186068135734) = 2.215092275387496\n02 -\u003e f(9.731099196329486) = 94.69429156880437\n03 -\u003e f(2.8835900819936366) = 8.315091760972068\n04 -\u003e f(6.684879549955022) = 44.68761459740686\n05 -\u003e f(6.369117254195896) = 40.56565459769586\n06 -\u003e f(8.311599275340795) = 69.08268251384563\n07 -\u003e f(3.9495544683795036) = 15.598980498696504\n08 -\u003e f(2.719439725535402) = 7.395352420820062\n09 -\u003e f(5.076587322264285) = 25.771738840574468\n10 -\u003e f(6.509647409342488) = 42.37550939395937\n11 -\u003e f(0.0) = 0.0\n12 -\u003e f(0.07807885269930037) = 0.006096307238839045\n13 -\u003e f(0.004326455132792617) = 1.8718214016067583e-05\n14 -\u003e f(0.03447243207111301) = 0.0011883485728975008\n15 -\u003e f(0.018114237444373238) = 0.0003281255981911335\n16 -\u003e f(0.0020049360585783216) = 4.019768598987575e-06\n17 -\u003e f(0.6959012004878518) = 0.48427848084043323\n18 -\u003e f(0.006902913600794758) = 4.765021618003725e-05\n19 -\u003e f(0.04812048929037971) = 0.0023155814895455483\n20 -\u003e f(0.015496977861506611) = 0.00024015632284002603\n21 -\u003e f(0.03973738943234384) = 0.0015790601188977519\n22 -\u003e f(0.14944732113771342) = 0.022334501795238843\n23 -\u003e f(0.1538705525239814) = 0.02367614693403532\n24 -\u003e f(0.02714364492250043) = 0.0007367774596787835\n25 -\u003e f(0.013367771420287281) = 0.00017869731274504944\n26 -\u003e f(0.07504851702564763) = 0.0056322799077489225\n27 -\u003e f(0.061488350499158975) = 0.0037808172471074236\n28 -\u003e f(0.010089082470558145) = 0.00010178958509772366\n29 -\u003e f(0.1785305521706959) = 0.031873158058373575\n30 -\u003e f(0.07218850699949093) = 0.005211180542815551\n31 -\u003e f(0.08273460533704255) = 0.006845014920276189\n32 -\u003e f(0.004884441886340666) = 2.3857772541039158e-05\n```\n\n## Overview\n\nDemonstrate features with short examples. In these examples we assume that the package is imported such as:\n\n```python\nimport metalgpy as mpy\n```\n\n### Symbols\n\nTransform a python object into a symbol with:\n\n```\n@mpy.meta\ndef foo(...):\n    ...\n\n@mpy.meta\nclass Foo:\n    ...\n```\n\n### Variables\n\n```python\nmpy.Float(0, 10) # float in [0, 10] interval with implicit name\nmpy.Float(0, 10, name=\"x\") # explicit name\nmpy.Int(0, 10) # integer in [0, 10]\nmpy.List([True, False]) # categorical nominal\nmpy.List([\"bad\", \"medium\", \"good\"], ordered=True) # categorical ordinal\n```\n\n### Expressions\n\nBuild expressions of symbols with:\n\n* arithmetic\n```python\na = mpy.Float(0, 10, name=\"a\")\nb = mpy.Float(0, 10, name=\"b\")\n\ntotal = a + b\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeephyper%2Fmetalgpy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeephyper%2Fmetalgpy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeephyper%2Fmetalgpy/lists"}