yobx.sklearn.naive_bayes.categorical_nb#
- yobx.sklearn.naive_bayes.categorical_nb.sklearn_categorical_nb(g: GraphBuilderExtendedProtocol, sts: Dict, outputs: List[str], estimator: CategoricalNB, X: str, name: str = 'categorical_nb') Tuple[str, str][source]#
Converts a
sklearn.naive_bayes.CategoricalNBinto ONNX.The joint log-likelihood for class c is:
jll[n, c] = class_log_prior_[c] + Σ_f feature_log_prob_[f][c, X[n, f]]For each feature f,
feature_log_prob_[f]has shape(C, n_categories[f]). The contribution is looked up via a Gather on the transposed tablefeature_log_prob_[f].T(shapen_categories[f] × C) using the integer feature columnX[:, f]as indices.probabilities ← Softmax(jll, axis=1) label ← classes_[ArgMax(jll, axis=1)]
- Parameters:
g – the graph builder to add nodes to
sts – shapes defined by scikit-learn
outputs – desired names (label, probabilities)
estimator – a fitted
CategoricalNBX – input tensor name (integer category indices)
name – prefix for added node names
- Returns:
tuple
(label_result_name, proba_result_name)