From 508609c4605daa7bb90d09665b95175311325489 Mon Sep 17 00:00:00 2001 From: Sam Date: Sat, 30 Jan 2021 17:28:40 -0500 Subject: [PATCH 1/2] Fixed Numpy boolean array indexing issue for 2dim arrays. Numpy requires the use of masking for all boolean array indexing on non 1 or 0-d arrays. Therefore the following line breaks all estimators when using the conventional Nx1 sklearn data format for regression, which this library also requires. pred[ind] = p This commit uses a mask to fix this. --- mlinsights/mlmodel/piecewise_estimator.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mlinsights/mlmodel/piecewise_estimator.py b/mlinsights/mlmodel/piecewise_estimator.py index a843137d..ab7a72c2 100644 --- a/mlinsights/mlmodel/piecewise_estimator.py +++ b/mlinsights/mlmodel/piecewise_estimator.py @@ -293,7 +293,10 @@ def _apply_predict_method(self, X, method, parallelized, dimout): for ind, p in indpred: if ind is None: continue - pred[ind] = p + # pred[ind] = p + mask = (ind==True) + numpy.putmask(pred,mask,p) + indall = numpy.logical_or(indall, ind) # pylint: disable=E1111 # no in a bucket From 0c029c2bd60f547f8e327f4ec65ca146971dbd8d Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 1 Feb 2021 11:09:46 -0500 Subject: [PATCH 2/2] My change was incorrect --- mlinsights/mlmodel/piecewise_estimator.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/mlinsights/mlmodel/piecewise_estimator.py b/mlinsights/mlmodel/piecewise_estimator.py index ab7a72c2..a843137d 100644 --- a/mlinsights/mlmodel/piecewise_estimator.py +++ b/mlinsights/mlmodel/piecewise_estimator.py @@ -293,10 +293,7 @@ def _apply_predict_method(self, X, method, parallelized, dimout): for ind, p in indpred: if ind is None: continue - # pred[ind] = p - mask = (ind==True) - numpy.putmask(pred,mask,p) - + pred[ind] = p indall = numpy.logical_or(indall, ind) # pylint: disable=E1111 # no in a bucket