Skip to content

Commit 49f6bee

Browse files
committed
Nomogram: Support sparse data
1 parent d3194d0 commit 49f6bee

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, mean, unique
1516
from Orange.classification import Model
1617
from Orange.classification.naive_bayes import NaiveBayesModel
1718
from Orange.classification.logistic_regression import \
@@ -870,8 +871,8 @@ def calculate_log_reg_coefficients(self):
870871
for i in range(len(self.log_reg_coeffs)):
871872
if self.log_reg_coeffs[i].shape[1] == 1:
872873
coef = self.log_reg_coeffs[i]
873-
min_t = np.nanmin(self.data.X, axis=0)[i]
874-
max_t = np.nanmax(self.data.X, axis=0)[i]
874+
min_t = nanmin(self.data.X, axis=0)[i]
875+
max_t = nanmax(self.data.X, axis=0)[i]
875876
self.log_reg_coeffs[i] = np.hstack((coef * min_t, coef * max_t))
876877
self.log_reg_cont_data_extremes.append(
877878
[sorted([min_t, max_t], reverse=(c < 0)) for c in coef])
@@ -1080,10 +1081,10 @@ def _init_feature_marker_values(self):
10801081
value, feature_val = 0, None
10811082
if len(self.log_reg_coeffs):
10821083
if attr.is_discrete:
1083-
ind, n = np.unique(self.data.X[:, i], return_counts=True)
1084+
ind, n = unique(self.data.X[:, i], return_counts=True)
10841085
feature_val = np.nan_to_num(ind[np.argmax(n)])
10851086
else:
1086-
feature_val = np.average(self.data.X[:, i])
1087+
feature_val = mean(self.data.X[:, i])
10871088
inst_in_dom = instances and attr in instances.domain
10881089
if inst_in_dom and not np.isnan(instances[0][attr]):
10891090
feature_val = instances[0][attr]

0 commit comments

Comments
 (0)