{"id":23291718,"url":"https://github.com/andrefcruz/hpt","last_synced_at":"2025-08-21T22:32:22.526Z","repository":{"id":181282571,"uuid":"571252283","full_name":"AndreFCruz/hpt","owner":"AndreFCruz","description":"Hyperparameter tuning with minimal boilerplate","archived":false,"fork":false,"pushed_at":"2023-11-30T15:46:50.000Z","size":3525,"stargazers_count":1,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-09-09T16:04:54.810Z","etag":null,"topics":["easy-to-use","hyperparameter-optimization","hyperparameter-tuning","machine-learning","optuna"],"latest_commit_sha":null,"homepage":"https://andrefcruz.github.io/hpt/","language":"Python","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/AndreFCruz.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}},"created_at":"2022-11-27T16:42:57.000Z","updated_at":"2023-11-30T15:29:47.000Z","dependencies_parsed_at":"2023-11-30T14:27:35.047Z","dependency_job_id":"27cfd377-9844-4846-99a4-7bbd432e18c1","html_url":"https://github.com/AndreFCruz/hpt","commit_stats":null,"previous_names":["andrefcruz/hpt"],"tags_count":31,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AndreFCruz%2Fhpt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AndreFCruz%2Fhpt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AndreFCruz%2Fhpt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AndreFCruz%2Fhpt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AndreFCruz","download_url":"https://codeload.github.com/AndreFCruz/hpt/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230539832,"owners_count":18241962,"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":["easy-to-use","hyperparameter-optimization","hyperparameter-tuning","machine-learning","optuna"],"created_at":"2024-12-20T05:27:45.571Z","updated_at":"2024-12-20T05:27:46.080Z","avatar_url":"https://github.com/AndreFCruz.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# hpt\n\n![Tests status](https://github.com/AndreFCruz/hpt/actions/workflows/python-package.yml/badge.svg)\n![PyPI status](https://github.com/AndreFCruz/hpt/actions/workflows/python-publish.yml/badge.svg)\n![Documentation status](https://github.com/AndreFCruz/hpt/actions/workflows/python-docs.yml/badge.svg)\n![PyPI version](https://badgen.net/pypi/v/hyperparameter-tuning)\n![OSI license](https://badgen.net/pypi/license/hyperparameter-tuning)\n![Python compatibility](https://badgen.net/pypi/python/hyperparameter-tuning)\n\nA minimal hyperparameter tuning framework to help you train hundreds of models.\n\nIt's essentially a set of helpful wrappers over optuna.\n\nConsult the package documentation [here](https://andrefcruz.github.io/hpt/)!\n\n\n## Install\n\nInstall package from [PyPI](https://pypi.org/project/hyperparameter-tuning/):\n\n\n`\npip install hyperparameter-tuning\n`\n\n## Getting started\n\n```py\nfrom hpt.tuner import ObjectiveFunction, OptunaTuner\n\nobj_func = ObjectiveFunction(\n    X_train, y_train, X_test, y_test,\n    hyperparameter_space=HYPERPARAM_SPACE_PATH,    # path to YAML file\n    eval_metric=\"accuracy\",\n    s_train=s_train,\n    s_val=s_test,\n    threshold=0.50,\n)\n\ntuner = OptunaTuner(\n    objective_function=obj_func,\n    direction=\"maximize\",    # NOTE: can pass other useful study kwargs here (e.g. storage)\n)\n\n# Then just run optimize as you would for an optuna.Study object\ntuner.optimize(n_trials=20, n_jobs=4)\n\n# Results are stored in tuner.results\ntuner.results\n\n# You can reconstruct the best predictor with:\nclf = obj_func.reconstruct_model(obj_func.best_trial)\n```\n\n## Defining a hyperparameter space\n\nThe hyperparameter space is provided either path to a YAML file, or as a `dict` \nwith the same structure.\nExample hyperparameter spaces [here](examples/hyperparameter_spaces/).\n\nThe YAML file must follow this structure:\n```yaml\n# One or more top-level algorithms\nDT:  \n    # Full classpath of algorithm's constructor\n    classpath: sklearn.tree.DecisionTreeClassifier\n    \n    # One or more key-word arguments to be passed to the constructor\n    kwargs:\n        \n        # Kwargs may be sampled from a distribution\n        max_depth:\n            type: int           # either 'int' or 'float'\n            range: [ 10, 100 ]  # minimum and maximum values\n            log: True           # (optionally) whether to use logarithmic scale\n        \n        # Kwargs may be sampled from a fixed set of categories\n        criterion:\n            - 'gini'\n            - 'entropy'\n        \n        # Kwargs may be a pre-defined value\n        min_samples_split: 4\n\n\n# You may explore multiple algorithms at once\nLR:\n    classpath: sklearn.linear_model.LogisticRegression\n    kwargs:\n        # An example of a float hyperparameter\n        C:\n            type: float\n            range: [ 0.01, 1.0 ]\n            log: True\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrefcruz%2Fhpt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandrefcruz%2Fhpt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrefcruz%2Fhpt/lists"}