invert4geom.Inversion.optimize_inversion_damping

invert4geom.Inversion.optimize_inversion_damping#

Inversion.optimize_inversion_damping(n_trials, damping_limits, n_startup_trials=None, score_as_median=False, sampler=None, grid_search=False, fname=None, plot_scores=True, plot_cv=None, plot_grids=False, logx=True, logy=True, progressbar=True, parallel=False, seed=0)[source]#

Use Optuna to find the optimal damping regularization parameter for a gravity inversion. The optimization aims to minimize the cross-validation score, represented by the root mean (or median) squared error (RMSE), between the testing gravity data, and the predict gravity data after and inversion. Follows methods of Uieda and Barbosa[1].

Provide upper and low damping values, number of trials to run, and specify to let Optuna choose the best damping value for each trial or to use a grid search. The results are saved to a pickle file with the best inversion results and the study.

Parameters:
  • n_trials (int) – number of damping values to try

  • n_startup_trials (int | None) – number of startup trials, by default is automatically determined

  • damping_limits (tuple[float, float]) – upper and lower limits

  • score_as_median (bool) – if True, changes the scoring from the root mean square to the root median square, by default False

  • sampler (BaseSampler | None) – customize the optuna sampler, by default either GPsampler or GridSampler depending on if grid_search is True or False

  • grid_search (bool) – search the entire parameter space between damping_limits in n_trial steps, by default False

  • fname (str | None) – file name to save both study and inversion results to as pickle files, by default fname is tmp_x_damping_cv where x is a random integer between 0 and 999 and will save study to <fname>_study.pickle and tuple of inversion results to <fname>.pickle.

  • plot_scores (bool) – plot the cross-validation results, by default True

  • plot_grids (bool) – for each damping value, plot comparison of predicted and testing gravity data, by default False

  • logx (bool) – make x axis of CV result plot on log scale, by default True

  • logy (bool) – make y axis of CV result plot on log scale, by default True

  • progressbar (bool) – add a progressbar, by default True

  • parallel (bool) – run the optimization in parallel, by default False

  • seed (int) – random seed for the samplers, by default 0

  • plot_cv (bool | None)

Returns:

inv_copy – a copy of the Inversion object after running the inversion with the best damping value

Return type:

Inversion