From dcebac3799233435d1b86e8f73cb218f0a9d11bf Mon Sep 17 00:00:00 2001 From: Marko Toplak Date: Thu, 17 Nov 2022 13:02:18 +0100 Subject: [PATCH] stats: convert sparse array to csc before mean compute --- Orange/statistics/util.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Orange/statistics/util.py b/Orange/statistics/util.py index 800958677cd..f5ac575d883 100644 --- a/Orange/statistics/util.py +++ b/Orange/statistics/util.py @@ -343,6 +343,8 @@ def stats(X, weights=None, compute_variance=False): is_sparse = sp.issparse(X) if X.size and is_numeric: + if is_sparse: + X = X.tocsc() if compute_variance: means, vars = nan_mean_variance_axis(X, axis=0, weights=weights) else: @@ -360,7 +362,6 @@ def stats(X, weights=None, compute_variance=False): X.shape[0] - nans)) elif is_sparse and X.size: non_zero = np.bincount(X.nonzero()[1], minlength=X.shape[1]) - X = X.tocsc() return np.column_stack(( nanmin(X, axis=0), nanmax(X, axis=0),