BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
andreas_zaras
Pyrite | Level 9

Hello!

 

I have creeated a pipeline in Model Studio (DM and ML) with a Python Open Surce node where i have built a decision tree model. The node works fine and in the Reuslts window i can extract various things e.g. the variable improtance of the tree. What i am also trying to do is to output a plot of the tree. I use the following python script:

tree.plot_tree(dm_model,filled=True,rounded=True,class_names=["Reject","Grant"],feature_names=X_enc.columns, fontsize=6)
plt.show()

The node works fine (green sign after the pipeline is ran) but there is not plot in the results. Do i need to add something more in the python script to have the desired result (decsiion tree viusual-plot).

 

Thanks in advance,

 

Andreas

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
RadhikhaMyneni
SAS Employee

Hi Andreas,

 

For the plot to show up in the node results, you need to: (1) save it in jpg, png or gif format, (2) name it with rpt_ prefix, for example rpt_treeplot.png or rpt_treeplot.jpg and (3) save it in dm_nodedir folder (dm_nodedir is a variable available in the node editor pointing to a temporary working folder)

 

Here is some sample Python code that does this:

# Plot model residuals
plt.scatter(pred, pred - dm_inputdf[dm_dec_target])
plt.axhline(y=0, color='r')
plt.title('Residual plot')
plt.ylabel('Residual')
plt.savefig(dm_nodedir + '/rpt_residuals.png')
plt.close()

 

Hope this helps,

Radhikha

View solution in original post

2 REPLIES 2
RadhikhaMyneni
SAS Employee

Hi Andreas,

 

For the plot to show up in the node results, you need to: (1) save it in jpg, png or gif format, (2) name it with rpt_ prefix, for example rpt_treeplot.png or rpt_treeplot.jpg and (3) save it in dm_nodedir folder (dm_nodedir is a variable available in the node editor pointing to a temporary working folder)

 

Here is some sample Python code that does this:

# Plot model residuals
plt.scatter(pred, pred - dm_inputdf[dm_dec_target])
plt.axhline(y=0, color='r')
plt.title('Residual plot')
plt.ylabel('Residual')
plt.savefig(dm_nodedir + '/rpt_residuals.png')
plt.close()

 

Hope this helps,

Radhikha

andreas_zaras
Pyrite | Level 9
Thanks Radhikha!

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

How to choose a machine learning algorithm

Use this tutorial as a handy guide to weigh the pros and cons of these commonly used machine learning algorithms.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 1194 views
  • 1 like
  • 2 in conversation