Skip to content

Commit

Permalink
Rename new var if necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrejaKovacic committed May 12, 2020
1 parent fbf6f33 commit f306a28
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions Orange/widgets/visualize/owsilhouetteplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import pyqtgraph as pg

import Orange.data
from Orange.data.util import get_unique_names
import Orange.distance
import Orange.misc
from Orange.data import Table, Domain
Expand Down Expand Up @@ -494,12 +495,18 @@ def commit(self):
scores = self._silhouette

var = self.cluster_var_model[self.cluster_var_idx]
silhouette_var = Orange.data.ContinuousVariable(
"Silhouette ({})".format(escape(var.name)))

domain = self.data.domain
proposed = "Silhouette ({})".format(escape(var.name))
names = [var.name for var in itertools.chain(domain.attributes,
domain.class_vars,
domain.metas)]
unique = get_unique_names(names, proposed)
silhouette_var = Orange.data.ContinuousVariable(unique)
domain = Orange.data.Domain(
self.data.domain.attributes,
self.data.domain.class_vars,
self.data.domain.metas + (silhouette_var, ))
domain.attributes,
domain.class_vars,
domain.metas + (silhouette_var, ))
data = self.data.transform(domain)

if np.count_nonzero(selectedmask):
Expand Down

0 comments on commit f306a28

Please sign in to comment.