Skip to content
Snippets Groups Projects

Resolve "(LearnerND) add iso-surface plot feature"

Merged Jorn Hoofwijk requested to merge 112-learnernd-add-iso-surface-plot-feature into master
All threads resolved!
Compare and Show latest version
2 files
+ 4
13
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -659,7 +659,7 @@ class LearnerND(BaseLearner):
self.tell_many(*zip(*data.items()))
def _get_iso(self, level=0.0, which='surface'):
if which == 'surface'
if which == 'surface':
if self.ndim != 3 or self.vdim != 1:
raise Exception('Isosurface plotting is only supported'
' for a 3D input and 1D output')
@@ -671,8 +671,6 @@ class LearnerND(BaseLearner):
' for a 2D input and 1D output')
get_surface = False
get_line = True
else:
raise Exception
vertices = [] # index -> (x,y,z)
faces_or_lines = [] # tuple of indices of the corner points
@@ -734,12 +732,6 @@ class LearnerND(BaseLearner):
return vertices, faces_or_lines
def _get_isoline(self, level=0.0):
return self._get_iso(level=0.0, which='line')
def _get_isosurface(self, level=0.0):
return self._get_iso(level=0.0, which='surface')
def plot_isoline(self, level=0.0, n=None, tri_alpha=0):
"""Plot the isoline at a specific level of the function we want to
learn, only works in 2D.
@@ -762,8 +754,7 @@ class LearnerND(BaseLearner):
plot = plot * self.plot_isoline(level=l, n=-1)
return plot
vertices, lines = self._get_isoline(level)
vertices, lines = self.self._get_iso(level, which='line')
paths = [[vertices[i], vertices[j]] for i, j in lines]
contour = hv.Path(paths)
@@ -790,7 +781,7 @@ class LearnerND(BaseLearner):
"""
plotly = ensure_plotly()
vertices, faces = self._get_isosurface(level)
vertices, faces = self._get_iso(level, which='surface')
x, y, z = zip(*vertices)
fig = plotly.figure_factory.create_trisurf(
Loading