Skip to content

Commit e81f2d9

Browse files
committed
Nomogram: Support sparse data
1 parent 71b7167 commit e81f2d9

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

Orange/widgets/visualize/ownomogram.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from AnyQt.QtCore import Qt, QEvent, QRectF, QSize
1313

1414
from Orange.data import Table, Domain
15+
from Orange.statistics.util import nanmin, nanmax, average, unique
1516
from Orange.classification import Model
1617
from Orange.classification.naive_bayes import NaiveBayesModel
1718
from Orange.classification.logistic_regression import \
@@ -868,8 +869,8 @@ def calculate_log_reg_coefficients(self):
868869
for i in range(len(self.log_reg_coeffs)):
869870
if self.log_reg_coeffs[i].shape[1] == 1:
870871
coef = self.log_reg_coeffs[i]
871-
min_t = np.nanmin(self.data.X, axis=0)[i]
872-
max_t = np.nanmax(self.data.X, axis=0)[i]
872+
min_t = nanmin(self.data.X, axis=0)[i]
873+
max_t = nanmax(self.data.X, axis=0)[i]
873874
self.log_reg_coeffs[i] = np.hstack((coef * min_t, coef * max_t))
874875
self.log_reg_cont_data_extremes.append(
875876
[sorted([min_t, max_t], reverse=(c < 0)) for c in coef])
@@ -1076,10 +1077,10 @@ def _init_feature_marker_values(self):
10761077
value, feature_val = 0, None
10771078
if len(self.log_reg_coeffs):
10781079
if attr.is_discrete:
1079-
ind, n = np.unique(self.data.X[:, i], return_counts=True)
1080+
ind, n = unique(self.data.X[:, i], return_counts=True)
10801081
feature_val = np.nan_to_num(ind[np.argmax(n)])
10811082
else:
1082-
feature_val = np.average(self.data.X[:, i])
1083+
feature_val = average(self.data.X[:, i])
10831084
inst_in_dom = instances and attr in instances.domain
10841085
if inst_in_dom and not np.isnan(instances[0][attr]):
10851086
feature_val = instances[0][attr]

0 commit comments

Comments
 (0)