Visualizing a learned model

User 2570 | 3/23/2016, 10:22:05 AM

I am trying to visualize DT model using small_model.show(view="Tree") but shows the following error: `


MemoryError Traceback (most recent call last) <ipython-input-26-18864a048e14> in <module>() ----> 1 small_model.show(view="Tree")

C:\Anaconda2\lib\site-packages\graphlab\toolkits\classifier\decisiontreeclassifier.pyc in show(self, view, treeid, vlabelhover) 181 """ 182 if (view=="Tree"): --> 183 return self.showtree(treeid, vlabelhover=vlabelhover) 184 185 return super(Classifier, self).show(view=view)

C:\Anaconda2\lib\site-packages\graphlab\toolkits\classifier\decisiontreeclassifier.pyc in showtree(self, treeid, vlabelhover) 206 >>> model.show(0) 207 """ --> 208 showmodeltree(self, 0, vlabelhover) 209 210 @collectmodel_workflow

C:\Anaconda2\lib\site-packages\graphlab\toolkits_supervisedlearning.pyc in showmodeltree(model, treeid, vlabelhover) 763 else: 764 return str(record['name']) + '<' + str(record['value']) --> 765 g.vertices['repr'] = g.vertices.apply(get_vlabel, str) 766 767 fuchsia = [0.69, 0., 0.48]

C:\Anaconda2\lib\site-packages\graphlab\datastructures\sframe.pyc in apply(self, fn, dtype, seed) 3014 """ 3015 assert callable(fn), "Input must be callable" -> 3016 testsf = self[:10] 3017 dryrun = [fn(row) for row in test_sf] 3018 if dtype is None:

C:\Anaconda2\lib\site-packages\graphlab\datastructures\sframe.pyc in getitem(self, key) 4039 if stop < 0: 4040 stop = len(self) + stop -> 4041 return SFrame(proxy = self.proxy.copy_range(start, step, stop)) 4042 else: 4043 raise TypeError("Invalid index type: must be SArray, list, int, or str")

C:\Anaconda2\lib\site-packages\graphlab\datastructures\gframe.pyc in proxy(self) 297 @property 298 def proxy(self): --> 299 return self.get_cache().proxy

C:\Anaconda2\lib\site-packages\graphlab\datastructures\gframe.pyc in getcache(self) 281 if self.__sframecache is None or self.isdirty__: 282 if self.isvertexframe(): --> 283 self.sframe_cache = self.graph.getvertices() 284 elif self.isedgeframe(): 285 self.sframe_cache = self.graph.get_edges()

C:\Anaconda2\lib\site-packages\graphlab\datastructures\sgraph.pyc in getvertices(self, ids, fields, format) 463 464 with cythoncontext(): --> 465 sf = SFrame(proxy=self.proxy.get_vertices(ids, fields)) 466 467 if (format == 'sframe'):

C:\Anaconda2\lib\site-packages\graphlab\cython\context.pyc in exit(self, exctype, excvalue, traceback) 47 if not self.showcythontrace: 48 # To hide cython trace, we re-raise from here ---> 49 raise exctype(excvalue) 50 else: 51 # To show the full trace, we do nothing and let exception propagate

MemoryError: std::bad_alloc `

Comments

User 1190 | 3/23/2016, 8:01:46 PM

Hi,

Sorry to hear you have trouble with model.show(). We uncovered the bug and it will be fixed in the next release. A simply workaround now is to run the following code once before calling show(). gl.set_runtime_config('SGRAPH_DEFAULT_NUM_PARTITIONS', 1) gl.set_runtime_config('SGRAPH_INGRESS_VID_BUFFER_SIZE', 1000)


User 2570 | 3/24/2016, 4:45:33 AM

@"Jay Gu" Thank you for reply, but it give the following error `


RuntimeError Traceback (most recent call last) <ipython-input-20-0ef03b2e7f94> in <module>() ----> 1 gl.setruntimeconfig('SGRAPHDEFAULTNUMPARTITIONS', 1) 2 gl.setruntimeconfig('SGRAPHINGRESSVIDBUFFER_SIZE', 1000)

C:\Anaconda2\lib\site-packages\graphlab\util_init__.pyc in setruntimeconfig(name, value) 494 ret = unity.setglobal(name, value) 495 if ret != "": --> 496 raise RuntimeError(ret); 497 498 GLOBRE = _re.compile("""[*?]""")

RuntimeError: No such configuration variable `


User 4939 | 4/17/2016, 6:11:03 AM

I am having a similar error with same command ` small_model.show(view ='Tree')


MemoryError Traceback (most recent call last) <ipython-input-27-18864a048e14> in <module>() ----> 1 small_model.show(view="Tree")

c:\anaconda2\envs\dato-env\lib\site-packages\graphlab\toolkits\classifier\decisiontreeclassifier.pyc in show(self, view, treeid, vlabelhover) 181 """ 182 if (view=="Tree"): --> 183 return self.showtree(treeid, vlabelhover=vlabelhover) 184 185 return super(Classifier, self).show(view=view)

c:\anaconda2\envs\dato-env\lib\site-packages\graphlab\toolkits\classifier\decisiontreeclassifier.pyc in showtree(self, treeid, vlabelhover) 206 >>> model.show(0) 207 """ --> 208 showmodeltree(self, 0, vlabelhover) 209 210 @collectmodel_workflow

c:\anaconda2\envs\dato-env\lib\site-packages\graphlab\toolkits_supervisedlearning.pyc in showmodeltree(model, treeid, vlabelhover) 763 else: 764 return str(record['name']) + '<' + str(record['value']) --> 765 g.vertices['repr'] = g.vertices.apply(get_vlabel, str) 766 767 fuchsia = [0.69, 0., 0.48]

c:\anaconda2\envs\dato-env\lib\site-packages\graphlab\datastructures\sframe.pyc in apply(self, fn, dtype, seed) 3014 """ 3015 assert callable(fn), "Input must be callable" -> 3016 testsf = self[:10] 3017 dryrun = [fn(row) for row in test_sf] 3018 if dtype is None:

c:\anaconda2\envs\dato-env\lib\site-packages\graphlab\datastructures\sframe.pyc in getitem(self, key) 4039 if stop < 0: 4040 stop = len(self) + stop -> 4041 return SFrame(proxy = self.proxy.copy_range(start, step, stop)) 4042 else: 4043 raise TypeError("Invalid index type: must be SArray, list, int, or str")

c:\anaconda2\envs\dato-env\lib\site-packages\graphlab\datastructures\gframe.pyc in proxy(self) 297 @property 298 def proxy(self): --> 299 return self.get_cache().proxy

c:\anaconda2\envs\dato-env\lib\site-packages\graphlab\datastructures\gframe.pyc in getcache(self) 281 if self.__sframecache is None or self.isdirty__: 282 if self.isvertexframe(): --> 283 self.sframe_cache = self.graph.getvertices() 284 elif self.isedgeframe(): 285 self.sframe_cache = self.graph.get_edges()

c:\anaconda2\envs\dato-env\lib\site-packages\graphlab\datastructures\sgraph.pyc in getvertices(self, ids, fields, format) 463 464 with cythoncontext(): --> 465 sf = SFrame(proxy=self.proxy.get_vertices(ids, fields)) 466 467 if (format == 'sframe'):

c:\anaconda2\envs\dato-env\lib\site-packages\graphlab\cython\context.pyc in exit(self, exctype, excvalue, traceback) 47 if not self.showcythontrace: 48 # To hide cython trace, we re-raise from here ---> 49 raise exctype(excvalue) 50 else: 51 # To show the full trace, we do nothing and let exception propagate

MemoryError: std::bad_alloc `


User 4 | 4/18/2016, 6:01:40 PM

Hi @erigits and @npatel, there is a small change to @"Jay Gu"'s workaround above that should make it work. Please try this: gl.set_runtime_config('GRAPHLAB_SGRAPH_DEFAULT_NUM_PARTITIONS', 1) gl.set_runtime_config('GRAPHLAB_SGRAPH_INGRESS_VID_BUFFER_SIZE', 1000)


User 4939 | 4/22/2016, 7:12:18 AM

It worked, thanks Zach and Jay


User 1174 | 4/22/2016, 5:58:22 PM

@erigits the correct config name is gl.set_runtime_config('GRAPHLAB_SGRAPH_DEFAULT_NUM_PARTITIONS', 1) gl.set_runtime_config('GRAPHLAB_SGRAPH_INGRESS_VID_BUFFER_SIZE', 1000)

sorry about the typo. let us know if it solves your issue