Skip to contents

Computes point estimates of conditional probabilities from a prototype computation, either P(X|C) (feature probabilities given categories) or P(C|X) (category probabilities given feature values). This function provides the expected values of the conditional probability distributions.

Usage

conditionalProbs(x, type = c("features", "categories"), s = 500)

Arguments

x

A prototypeComputation object created by compute.

type

Character string specifying the type of conditional probabilities:

"features"

Returns P(X|C) - probability of features given categories

"categories"

Returns P(C|X) - probability of categories given feature values

s

Integer. Number of posterior draws used for sampling-based estimation. Default is 500. Results are averaged across all draws to provide point estimates.

Value

The return structure depends on the type parameter:

For type = "features": A data frame with categories as rows and features as columns, where each cell contains P(X_k = 1 | C_j). To get P(X_k = 0 | C_j) you can calculate 1 - "data frame".

For type = "categories": A list with two elements:

Xk=0

Matrix of P(C_j | X_k = 0) for each feature k and category j

Xk=1

Matrix of P(C_j | X_k = 1) for each feature k and category j

Details

This function provides point estimates by taking the mean of the sampling distributions generated by conditionalProbsSample. The conditional probabilities represent:

  • P(X|C): Given that an observation belongs to category C, what is the probability that feature X has value 1?

  • P(C|X): Given that feature X has a specific value (0 or 1), what is the probability that the observation belongs to category C?

See also

conditionalProbsSample for full sampling distributions, summary.prototypeComputation for comprehensive summaries, compute for creating prototypeComputation objects