Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENH] Scatter Plot Graph and Scaling can handle metas #2699

Merged
merged 5 commits into from
Nov 10, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
MDS: no more metas handling
  • Loading branch information
jerneju committed Nov 10, 2017

Verified

This commit was signed with the committer’s verified signature.
jerneju Jernej Urankar
commit 81247dd68607b5ca1aed36beab47d1475326b2bc
36 changes: 8 additions & 28 deletions Orange/widgets/unsupervised/owmds.py
Original file line number Diff line number Diff line change
@@ -55,11 +55,6 @@ def update_data(self, attr_x, attr_y, reset_view=True):
self.plot_widget.hideAxis(axis)
self.plot_widget.setAspectLocked(True, 1)

def get_size_index(self):
if self.attr_size == "Stress":
return -2
return super().get_size_index()

def compute_sizes(self):
def scale(a):
dmin, dmax = np.nanmin(a), np.nanmax(a)
@@ -69,17 +64,16 @@ def scale(a):
return np.zeros_like(a)

self.master.Information.missing_size.clear()
size_index = self.get_size_index()
if size_index == -1:
if self.attr_size is None:
size_data = np.full((self.n_points,), self.point_width,
dtype=float)
elif size_index == -2:
elif self.attr_size == "Stress":
size_data = scale(stress(self.master.embedding, self.master.effective_matrix))
size_data = self.MinShapeSize + size_data * self.point_width
else:
size_data = \
self.MinShapeSize + \
self.scaled_data[size_index, self.valid_data] * \
self.scaled_data.get_column_view(self.attr_size)[0][self.valid_data] * \
self.point_width
nans = np.isnan(size_data)
if np.any(nans):
@@ -270,11 +264,6 @@ def update_regression_line(self):

def init_attr_values(self):
domain = self.data and len(self.data) and self.data.domain or None
if domain is not None:
domain = Domain(
attributes=domain.attributes,
class_vars=domain.class_vars,
metas=tuple(a for a in domain.metas if a.is_primitive()))
for model in self.models:
model.set_domain(domain)
self.graph.attr_color = self.data.domain.class_var if domain else None
@@ -653,21 +642,12 @@ def _setup_plot(self, new=False):
coords = np.vstack((emb_x, emb_y)).T

data = self.data

primitive_metas = tuple(a for a in data.domain.metas if a.is_primitive())
keys = [k for k, a in enumerate(data.domain.metas) if a.is_primitive()]
data_metas = data.metas[:, keys].astype(float)

attributes = self.data.domain.attributes + (self.variable_x, self.variable_y) + \
primitive_metas
attributes = data.domain.attributes + (self.variable_x, self.variable_y)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BlazZupan, do we want the columns that contain x and y coordinates from the MDS to appear as ordinary attributes or as metas?

They used to be in metas, but now that visualization widgets can show metas as well, I would tend to store x and y as metas to not pollute that feature set.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually this line here is not related to that (it's for constructing data for plotting).
Output data has new coordinates in metas as we want, see commit function below (L671)

domain = Domain(attributes=attributes,
class_vars=self.data.domain.class_vars)
if data_metas is not None:
data_x = (self.data.X, coords, data_metas)
else:
data_x = (self.data.X, coords)
data = Table.from_numpy(domain, X=hstack(data_x),
Y=self.data.Y)
class_vars=data.domain.class_vars,
metas=data.domain.metas)
data = Table.from_numpy(domain, X=hstack((data.X, coords)),
Y=data.Y, metas=data.metas)
subset_data = data[self._subset_mask] if self._subset_mask is not None else None
self.graph.new_data(data, subset_data=subset_data, new=new)
self.graph.update_data(self.variable_x, self.variable_y, True)