Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed NaN probability scores in BernoulliNB converter when alpha=0 #238

Merged
merged 3 commits into from
Aug 28, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions skl2onnx/operator_converters/naive_bayes.py
Original file line number Diff line number Diff line change
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])
xadupre marked this conversation as resolved.
Show resolved Hide resolved

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