{"id":23450781,"url":"https://github.com/red-data-tools/red-optuna","last_synced_at":"2025-07-11T10:43:21.850Z","repository":{"id":56891539,"uuid":"183155869","full_name":"red-data-tools/red-optuna","owner":"red-data-tools","description":"Ruby bindings for Optuna, a hyperparameter optimization framework","archived":false,"fork":false,"pushed_at":"2019-09-16T12:25:04.000Z","size":6,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-06-21T06:04:25.572Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","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/red-data-tools.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-04-24T05:41:29.000Z","updated_at":"2024-10-05T20:44:57.000Z","dependencies_parsed_at":"2022-08-20T16:01:02.729Z","dependency_job_id":null,"html_url":"https://github.com/red-data-tools/red-optuna","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/red-data-tools/red-optuna","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/red-data-tools%2Fred-optuna","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/red-data-tools%2Fred-optuna/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/red-data-tools%2Fred-optuna/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/red-data-tools%2Fred-optuna/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/red-data-tools","download_url":"https://codeload.github.com/red-data-tools/red-optuna/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/red-data-tools%2Fred-optuna/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264787315,"owners_count":23663935,"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-12-24T00:15:06.690Z","updated_at":"2025-07-11T10:43:21.823Z","avatar_url":"https://github.com/red-data-tools.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Red Optuna\n\nRed Optuna is Ruby bindings for [Optuna](https://optuna.org/), a\nhyperparameter optimization framework.\n\n## Description\n\nRed Optuna is a hyperparameter optimization framework. You can\noptimize hyperparameter automatically.\n\n## Install\n\n```console\n% gem install red-optuna\n```\n\n## Usage\n\nHere is an example to optimize hyperparameter for Iris dataset\nclassifier by Rumale.\n\n```ruby\nrequire \"datasets-numo-narray\"\nrequire \"optuna\"\nrequire \"rumale\"\n\niris = Datasets::Iris.new.to_table\nx = iris.to_narray(:sepal_length,\n                   :sepal_width,\n                   :petal_length,\n                   :petal_width)\ny = Numo::NArray[*iris.label_encode(:label)]\n\nstudy = Optuna::Study.new\nstudy.optimize(n_trials: 100) do |trial|\n  classifier_name = trial.suggest_categorical(\"classifier\",\n                                              [\"SVC\", \"RandomForest\"])\n  if classifier_name == \"SVC\"\n    svc_regulation = trial.suggest_uniform(\"svc_regulation\", 0.0, 1.0)\n    classifier = Rumale::LinearModel::SVC.new(reg_param: svc_regulation.to_f)\n  else\n    rf_max_depth = trial.suggest_loguniform(\"rf_max_depth\", 2, 32).to_i\n    classifier = Rumale::Ensemble::RandomForestClassifier.new(max_depth: rf_max_depth)\n  end\n\n  splitter = Rumale::ModelSelection::StratifiedKFold.new\n  cv = Rumale::ModelSelection::CrossValidation.new(estimator: classifier,\n                                                   splitter: splitter)\n  report = cv.perform(x, y)\n  accuracy = report[:test_score].sum / splitter.n_splits\n  1.0 - accuracy\nend\np study.best_trial\n```\n\n## License\n\nThe MIT license. See `LICENSE.txt` for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fred-data-tools%2Fred-optuna","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fred-data-tools%2Fred-optuna","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fred-data-tools%2Fred-optuna/lists"}