Rambatino / CHAID

A python implementation of the common CHAID algorithm
Apache License 2.0
150 stars 50 forks source link

tree.render() throws error while working with data bricks azure #129

Closed tarun1602 closed 1 year ago

tarun1602 commented 1 year ago

I did try to install graphviz and orca both on databricks. but for the following error:

issue 1 : Transform failed with error code 525: Failed to execute 'getPointAtLength' on 'SVGGeometryElement': The element's path is empty.

Complete error here :

ValueError Traceback (most recent call last)

in 14 15 ## print the tree (though not enough power to split) ---> 16 tree.render(path = None, view = True) /local_disk0/.ephemeral_nfs/envs/pythonEnv-7a53298c-35a8-4523-9bec-07dd3847e73a/lib/python3.8/site-packages/CHAID/tree.py in render(self, path, view) 289 290 def render(self, path=None, view=False): --> 291 Graph(self).render(path, view) /local_disk0/.ephemeral_nfs/envs/pythonEnv-7a53298c-35a8-4523-9bec-07dd3847e73a/lib/python3.8/site-packages/CHAID/graph.py in render(self, path, view) 70 ) 71 for node in self.tree: ---> 72 image = self.bar_chart(node) 73 g.node(str(node.node_id), image=image) 74 if node.parent is not None: /local_disk0/.ephemeral_nfs/envs/pythonEnv-7a53298c-35a8-4523-9bec-07dd3847e73a/lib/python3.8/site-packages/CHAID/graph.py in bar_chart(self, node) 94 95 filename = os.path.join(self.tempdir, "node-{}.png".format(node.node_id)) ---> 96 pio.write_image(fig, file=filename, format="png") 97 return filename 98 /databricks/python/lib/python3.8/site-packages/plotly/io/_kaleido.py in write_image(fig, file, format, scale, width, height, validate, engine) 266 # ------------- 267 # Do this first so we don't create a file if image conversion fails --> 268 img_data = to_image( 269 fig, 270 format=format, /databricks/python/lib/python3.8/site-packages/plotly/io/_kaleido.py in to_image(fig, format, width, height, scale, validate, engine) 143 # --------------- 144 fig_dict = validate_coerce_fig_to_dict(fig, validate) --> 145 img_bytes = scope.transform( 146 fig_dict, format=format, width=width, height=height, scale=scale 147 ) /local_disk0/.ephemeral_nfs/envs/pythonEnv-7a53298c-35a8-4523-9bec-07dd3847e73a/lib/python3.8/site-packages/kaleido/scopes/plotly.py in transform(self, figure, format, width, height, scale) 159 if code != 0: 160 message = response.get("message", None) --> 161 raise ValueError( 162 "Transform failed with error code {code}: {message}".format( 163 code=code, message=message ValueError: Transform failed with error code 525: Failed to execute 'getPointAtLength' on 'SVGGeometryElement': The element's path is empty. **issue 2** is there a way to get each edge seq along with filter condition as a array sorted by root to end leave: Ex. node A, {A == 0} node A, {A == 0} & node B, {B == 0} node A, {A == 0} & node B, {B == 0} & node C, {C == 0} i want to use this to calculate how much data flow changing after each node. Thanks in advance!! Tarun
Rambatino commented 1 year ago

Hi Tarun,

Sorry for the delay in responding.

I don't really think I can help on that environment as I have no idea if I'm honest!

Have you looked at the README.md? It definitely seems like it should be possible. Can you have a try, it should be vanilla python. if you're still hitting your head against the wall, I can have a look into it (although it's been a while since I've developed on this library).

Mark

Rambatino commented 1 year ago

Closing as stale

tarun1602 commented 1 year ago

Hi Rambatino Thank you for your reply and apologies I was caught up with other project so didn’t look through it . I will pick it up later in aug and will let you know my findings

Sent from Yahoo Mail for iPhone

On Tuesday, February 7, 2023, 11:56 PM, Mark Ramotowski @.***> wrote:

Hi Tarun,

Sorry for the delay in responding.

I don't really think I can help on that environment as I have no idea if I'm honest!

Have you looked at the README.md? It definitely seems like it should be possible. Can you have a try, it should be vanilla python. if you're still hitting your head against the wall, I can have a look into it (although it's been a while since I've developed on this library).

Mark

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>