quara.loss_function.weighted_probability_based_squared_error module

class WeightedProbabilityBasedSquaredError(num_var=None, func_prob_dists=None, func_gradient_prob_dists=None, func_hessian_prob_dists=None, prob_dists_q=None, weight_matrices=None)[source]

Bases: quara.loss_function.probability_based_loss_function.ProbabilityBasedLossFunction

Constructor

Parameters
  • num_var (int, optional) – number of variables, by default None

  • func_prob_dists (List[Callable[[np.ndarray], np.ndarray]], optional) – functions map variables to a probability distribution.

  • func_gradient_prob_dists (List[Callable[[int, np.ndarray], np.ndarray]], optional) – functions map variables and an index of variables to gradient of probability distributions.

  • func_hessian_prob_dists (List[Callable[[int, int, np.ndarray], np.ndarray]], optional) – functions map variables and indices of variables to Hessian of probability distributions.

  • prob_dists_q (List[np.ndarray], optional) – vectors of q, by default None.

  • weight_matrices (List[np.ndarray], optional) – weight matrices, by default None

gradient(var, validate=False)[source]

returns the gradient of Weighted Probability Based Squared Error.

see gradient()

Parameters
  • var (numpy.ndarray) –

  • validate (bool) –

Return type

numpy.ndarray

hessian(var, validate=False)[source]

returns the Hessian of Weighted Probability Based Squared Error.

see hessian()

Parameters
  • var (numpy.ndarray) –

  • validate (bool) –

Return type

numpy.ndarray

set_weight_matrices(weight_matrices)[source]

sets weight matrices.

Parameters

weight_matrices (List[np.ndarray]) – weight matrices.

Return type

None

value(var, validate=False)[source]

returns the value of Weighted Probability Based Squared Error.

see value()

Parameters
  • var (numpy.ndarray) –

  • validate (bool) –

Return type

numpy.float64

property weight_matrices: List[numpy.ndarray]

returns weight matrices.

Returns

weight matrices.

Return type

List[np.ndarray]

class WeightedProbabilityBasedSquaredErrorOption(mode_weight=None, weights=None, weight_name=None)[source]

Bases: quara.loss_function.probability_based_loss_function.ProbabilityBasedLossFunctionOption

Constructor

mode_weight should be the following value:

  • “identity” then uses identity matrices for weights.

  • “custom” then uses user custom matrices for weights.

  • “inverse_sample_covariance” then uses inverse matrices of Sample Covariance Matrices.

  • “inverse_unbiased_covariance” then uses inverse matrices of Unbiased Covariance Matrices.

Parameters
  • mode_weight (str, optional) – mode_weight string, by default None

  • weights (List, optional) – values of weight, by default None

  • weight_name (str, optional) – weight_name string, by default None

Raises

ValueError – unsupported mode_weight