Skip to content

Commit

Permalink
model: scikit: scroer: Fix for daal4py wrapping
Browse files Browse the repository at this point in the history
Signed-off-by: John Andersen <johnandersenpdx@gmail.com>
  • Loading branch information
pdxjohnny committed Jul 28, 2021
1 parent b15b89a commit bbf4910
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
10 changes: 10 additions & 0 deletions model/scikit/dffml_model_scikit/scikit_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,19 @@

# https://intelpython.github.io/daal4py/sklearn.html
try:
# HACK Fix for daal4py not maintaining docstring of roc_auc_score
import sklearn.metrics.ranking

correct_doc = sklearn.metrics.ranking.roc_auc_score.__doc__

import daal4py.sklearn

daal4py.sklearn.patch_sklearn()

# HACK Fix for daal4py not maintaining docstring of roc_auc_score
import daal4py.sklearn.metrics._ranking

daal4py.sklearn.metrics._ranking._daal_roc_auc_score.__doc__ = correct_doc
except ImportError:
# Ignore import errors, package is not installed
pass
Expand Down
7 changes: 6 additions & 1 deletion model/scikit/dffml_model_scikit/scikit_scorers.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,12 @@
# classification.
# References:
# - https://scikit-learn.org/stable/modules/generated/sklearn.metrics.average_precision_score.html#sklearn.metrics.average_precision_score
properties = numpy_docstring_args(method)
# NOTE Fix for daal4py wrapping not preseveing docstring. This can happen
# when a decorator is used to wrap a function
if hasattr(method, "__dict__") and "__wrapped__" in method.__dict__:
properties = numpy_docstring_args(method.__dict__["__wrapped__"])
else:
properties = numpy_docstring_args(method)
if name in (
"RecallScore",
"PrecisionScore",
Expand Down

0 comments on commit bbf4910

Please sign in to comment.