Skip to content

Python API reference

The public API is exported from the quoptuna package (__all__): Optimizer, DataPreparation, XAI, XAIConfig, create_model.

Loads and prepares a CSV for training.

ParameterDescription
file_pathPath to the CSV dataset
x_colsList of feature column names
y_colTarget column name

Method .get_data(output_type="2") returns a data dict consumed by Optimizer.

Optuna-based hyperparameter search over quantum and classical models.

ParameterDescription
db_nameSQLite storage database name
study_nameOptuna study name
dataData dict from DataPreparation.get_data()
model_typesList of model names (default set)
search_spaceOptional custom categorical search space
samplertpe | random | grid
sampler_seedSampler seed
prunernone | asha | hyperband

The full constructor parameter set lives in source.

Method .optimize(n_trials=...) -> (study, best_trials).

  • best_trials[0].value — best (validation) F1
  • best_trials[0].params["model_type"] — winning model

SHAP-based explainability. XAIConfig configures the analysis; XAI produces SHAP plots (bar, beeswarm, violin, heatmap, waterfall) and other diagnostics for a trained model. Detailed plotting options are configured via XAIConfig fields — refer to source or /api/docs for the exact field names.

Construct a single model instance by name (quantum or classical) without running a search. See the Model catalog for valid model_type values.

from quoptuna import DataPreparation, Optimizer
data_prep = DataPreparation(file_path="your_data.csv", x_cols=["f1","f2","f3"], y_col="target")
data_dict = data_prep.get_data(output_type="2")
optimizer = Optimizer(db_name="experiment", study_name="trial_1", data=data_dict)
study, best_trials = optimizer.optimize(n_trials=100)
print(best_trials[0].value, best_trials[0].params["model_type"])