leaspy.algo.personalize.scipy_minimize ====================================== .. py:module:: leaspy.algo.personalize.scipy_minimize .. autoapi-nested-parse:: This module defines the `ScipyMinimize` class. .. !! processed by numpydoc !! Classes ------- .. autoapisummary:: leaspy.algo.personalize.scipy_minimize.ScipyMinimizeAlgorithm Module Contents --------------- .. py:class:: ScipyMinimizeAlgorithm(settings) Bases: :py:obj:`leaspy.algo.personalize.base.PersonalizeAlgorithm`\ [\ :py:obj:`leaspy.models.McmcSaemCompatibleModel`\ , :py:obj:`leaspy.io.outputs.individual_parameters.IndividualParameters`\ ] Gradient descent based algorithm to compute individual parameters, `i.e.` personalizing a model for a given set of subjects. :Parameters: **settings** : :class:`.AlgorithmSettings` Settings for the algorithm, including the `custom_scipy_minimize_params` parameter, which contains keyword arguments passed to :func:`scipy.optimize.minimize`. :Attributes: **scipy_minimize_params** : :obj:`dict` Keyword arguments for :func:`scipy.optimize.minimize`, with default values depending on the usage of a jacobian (cf. `ScipyMinimize.DEFAULT_SCIPY_MINIMIZE_PARAMS_WITH_JACOBIAN` and `ScipyMinimize.DEFAULT_SCIPY_MINIMIZE_PARAMS_WITHOUT_JACOBIAN`). Customization is possible via the `custom_scipy_minimize_params` in :class:`.AlgorithmSettings`. **format_convergence_issues** : :obj:`str` A format string for displaying convergence issues, which can use the following variables: - `patient_id`: :obj:`str` - `optimization_result_pformat`: :obj:`str` - `optimization_result_obj`: dict-like The default format is defined in `ScipyMinimize.DEFAULT_FORMAT_CONVERGENCE_ISSUES`, but it can be customized via the `custom_format_convergence_issues` parameter. **logger** : None or callable :obj:`str` -> None The function used to display convergence issues returned by :func:`scipy.optimize.minimize`. By default, convergence issues are printed only if the BFGS optimization method is not used. This can be customized by setting the `logger` attribute in :class:`.AlgorithmSettings`. .. !! processed by numpydoc !! .. py:attribute:: name :type: leaspy.algo.base.AlgorithmName .. py:attribute:: DEFAULT_SCIPY_MINIMIZE_PARAMS_WITH_JACOBIAN .. py:attribute:: DEFAULT_SCIPY_MINIMIZE_PARAMS_WITHOUT_JACOBIAN .. py:attribute:: DEFAULT_FORMAT_CONVERGENCE_ISSUES :value: Multiline-String .. raw:: html
Show Value .. code-block:: python """ {patient_id}: {optimization_result_pformat}""" .. raw:: html
.. py:attribute:: regularity_factor :type: float :value: 1.0 .. py:attribute:: scipy_minimize_params .. py:attribute:: format_convergence_issues .. py:attribute:: logger .. py:method:: obj_no_jac(x, state, scaling) Objective loss function to minimize in order to get patient's individual parameters. :Parameters: **x** : numpy.ndarray Individual standardized parameters At initialization x is full of zeros (mode of priors, scaled by std-dev) **state** : :class:`.State` The cloned model state that is dedicated to the current individual. In particular, individual data variables for the current individual are already loaded into it. **scaling** : _AffineScalings1D The scaling to be used for individual latent variables. :Returns: **objective** : :obj:`float` Value of the loss function (negative log-likelihood). .. !! processed by numpydoc !! .. py:method:: obj_with_jac(x, state, scaling) :abstractmethod: Objective loss function to minimize in order to get patient's individual parameters, together with its jacobian w.r.t to each of `x` dimension. :Parameters: **x** : numpy.ndarray Individual standardized parameters At initialization x is full of zeros (mode of priors, scaled by std-dev) **state** : :class:`.State` The cloned model state that is dedicated to the current individual. In particular, individual data variables for the current individual are already loaded into it. **scaling** : _AffineScalings1D The scaling to be used for individual latent variables. :Returns: 2-tuple (as expected by :func:`scipy.optimize.minimize` when ``jac=True``) * objective : :obj:`float` * gradient : array-like[float] with same length as `x` (= all dimensions of individual latent variables, concatenated) .. !! processed by numpydoc !! .. py:method:: is_jacobian_implemented(model) Check that the jacobian of model is implemented. .. !! processed by numpydoc !!