Skip to content

Commit

Permalink
Fixed NaN probability scores in BernoulliNB converter when alpha=0 (#238
Browse files Browse the repository at this point in the history
)
  • Loading branch information
Prabhat committed Aug 28, 2019
1 parent 11ac5ef commit 121b1b4
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions skl2onnx/operator_converters/naive_bayes.py
Expand Up @@ -237,8 +237,9 @@ def convert_sklearn_naive_bayes(scope, operator, container):
dot_prod_name = scope.get_unique_variable_name('dot_prod')
partial_sum_result_name = scope.get_unique_variable_name(
'partial_sum_result')

container.add_initializer(constant_name, proto_type, [], [1.0])
# Define constant slightly greater than 1 to avoid log 0
# scenarios when calculating log (1 - x) and x=1 in line 273
container.add_initializer(constant_name, proto_type, [], [1.000000001])

if nb.binarize is not None:
threshold_name = scope.get_unique_variable_name('threshold')
Expand Down

0 comments on commit 121b1b4

Please sign in to comment.