Table of Contents

Hyperparameter optimization for .NET

OptunaSharp

A .NET port of Optuna — the define-by-run hyperparameter optimization framework — built on top of NumSharp. Optuna is the behavioral source of truth; OptunaSharp aligns to it.

Status: core surface ported

The core algorithm surface is in place — samplers, pruners, storages, importance, and visualization — with more landing module-by-module.

dotnet add package OptunaSharp
using OptunaSharp;
using OptunaSharp.Samplers;
var study = Optuna.CreateStudy(sampler: new TPESampler(seed: 42));
study.Optimize(trial =>
{
    double x = trial.SuggestFloat("x", -10, 10);
    return (x - 2) * (x - 2);
}, nTrials: 20);
Console.WriteLine(study.BestValue);   // 0.0004973004749973951
# The same study in Optuna (Python) prints the same value
import optuna
def objective(trial):
    x = trial.suggest_float("x", -10, 10)
    return (x - 2) ** 2
study = optuna.create_study(sampler=optuna.samplers.TPESampler(seed=42))
study.optimize(objective, n_trials=20)
print(study.best_value)   # 0.0004973004749973951

Documentation Map

Pick where you want to start.