pycmtensor.functions#

PyCMTensor functions module

Module Contents#

pycmtensor.functions.logit(utility: list, avail: list = None)[source]#

Computes the Logit function, with availability conditions.

Parameters
  • utility (list) – List of M utility equations.

  • avail (list) – List of M availability conditions. If no availabilities are

  • provided

  • availabilities. (defaults to 1 for all) –

Returns

A NxM matrix of probabilities.

Return type

TensorVariable

pycmtensor.functions.log_likelihood(prob, y)[source]#

Symbolic representation of the log likelihood cost function.

Parameters
  • prob (TensorVariable) – Matrix describing the choice probabilites.

  • y (TensorVariable) – The TensorVariable referencing the choice column.

Returns

a symbolic representation of the log likelihood with ndim=0.

Return type

TensorVariable

pycmtensor.functions.errors(prob, y)[source]#

Symbolic representation of the prediction as a percentage error.

Parameters
  • prob (TensorVariable) – Matrix describing the choice probabilites.

  • y (TensorVariable) – The TensorVariable referencing the choice column.

Raises
  • TypeErrory should have the same shape as pred.

  • NotImplementedErrory should be an int Type.

Returns

a symbolic representation of the prediction error with ndim=0.

Return type

TensorVariable

pycmtensor.functions.hessians(ll, params)[source]#

Symbolic representation of the Hessian matrix given the log likelihood.

Parameters
  • ll (TensorVariable) – the loglikelihood to compute the gradients over

  • params (list) – list of params to compute the gradients over

Returns

the Hessian matrix with ndim=2

Return type

TensorVariable

Note

Parameters with status=1 are ignored.

pycmtensor.functions.bhhh(ll, params)[source]#

Symbolic representation of the Berndt-Hall-Hall-Hausman (BHHH) algorithm given the log likelihood.

Parameters
  • ll (TensorVariable) – the loglikelihood to compute the gradients over

  • params (list) – list of params to compute the gradients over

Returns

the outer product of the gradient with ndim=2

Return type

TensorVariable

Note

Parameters with status=1 are ignored.

pycmtensor.functions.gnorm(cost, params)[source]#

Symbolic representation of the gradient norm given the cost.

Parameters
  • cost (TensorVariable) – the cost to compute the gradients over

  • params (list) – list of params to compute the gradients over

Returns

the gradient norm value

Return type

TensorVariable

Note

Parameters with status=1 are ignored.