<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Variable Importance Plot from the proc hpforest procedure in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Variable-Importance-Plot-from-the-proc-hpforest-procedure/m-p/725206#M35180</link>
    <description>&lt;P&gt;Since your sort order example doesn't include the Gini variable used for the Xaxis it is hard to tell what you actually need. Likely in means that data needs a different sort order. I would be tempted to sort by Gini descending &amp;lt;other variable&amp;gt; , where the other variable would place the variable_name at the top that you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A brief example with a data set you should have available:&lt;/P&gt;
&lt;PRE&gt;proc sgplot data=sashelp.class;
   scatter x=height y=name ;
run;

proc sort data=sashelp.class
       out=work.class;
   by descending height;
run;

proc sgplot data=work.class;
   scatter x=height y=name ;
run;&lt;/PRE&gt;
&lt;P&gt;When you have a character variable on an axis there isn't a "natural" order and the values of something else are controlling the order of appearance in the data set which can affect the order they appear on the axis (depends to some extent on the type of graph, in some you can order by a result calculated by SGPLOT)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 10 Mar 2021 17:00:57 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2021-03-10T17:00:57Z</dc:date>
    <item>
      <title>Variable Importance Plot from the proc hpforest procedure</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Variable-Importance-Plot-from-the-proc-hpforest-procedure/m-p/724962#M35168</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am trying to obtain a variable importance ranking plot from the&amp;nbsp;proc hpforest procedure in SAS.&amp;nbsp; Here is my code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc hpforest data=mydata maxtrees=1000 vars_to_try=10 seed=2021&lt;BR /&gt;trainfraction=0.7 maxdepth=50 leafsize=6 alpha=0.5 ;&lt;BR /&gt;target outcome /level=binary;&lt;BR /&gt;input variable_list&amp;nbsp;&amp;nbsp;/ level = interval;&lt;BR /&gt;ods output VariableImportance = Variable_Importance;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then, I am using PROC SPLOT to plot this output. However, I am not getting the plot I want. Somehow, the values are not in the ascending order. Also, I wanted the variable labels in the plots, instead of the variable names as it's hard to understand the plot.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sgplot data = Variable_Importance;&lt;/P&gt;&lt;P&gt;title "The Variable of Importance Plot";&lt;BR /&gt;series x=Gini y=Variable /lineattrs=(pattern=shortdash color=royalblue thickness=3) legendlabel='Train Gini' GROUPORDER=ASCENDING ;&lt;BR /&gt;xaxis label='Train Gini' display=ALL;&lt;BR /&gt;yaxis label='Variable' display=ALL;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;The plot I want but I also want labels instead of the variable names:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jeff_b_0-1615318672599.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/55743i6D197CDA92A8CAEA/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jeff_b_0-1615318672599.png" alt="jeff_b_0-1615318672599.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The plot I am getting:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jeff_b_1-1615318714238.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/55744iBC037515BF575D73/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jeff_b_1-1615318714238.png" alt="jeff_b_1-1615318714238.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Mar 2021 19:41:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Variable-Importance-Plot-from-the-proc-hpforest-procedure/m-p/724962#M35168</guid>
      <dc:creator>jeff_b</dc:creator>
      <dc:date>2021-03-09T19:41:12Z</dc:date>
    </item>
    <item>
      <title>Re: Variable Importance Plot from the proc hpforest procedure</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Variable-Importance-Plot-from-the-proc-hpforest-procedure/m-p/724991#M35170</link>
      <description>&lt;P&gt;Some example data used for the plot would be nice.&lt;/P&gt;
&lt;P&gt;Then we wouldn't have to ask such things as&lt;/P&gt;
&lt;P&gt;What variable holds the label text you want to display on the axis? (you may need to go back and add this)&lt;/P&gt;
&lt;P&gt;If you have a variable with the text of the label for the variables use that as the axis variable. Otherwise your best approach would be to create a custom character format with the name of the variables as the start and the display value using the variable label to use with the Yaxis statement VALUESFORMAT option.&lt;/P&gt;
&lt;P&gt;What is the SORT order of the data variables used for the x and coordinates? Since Variable is character there isn't a natural order to use in Series (or possibly Scatter) plots and the order of the x y pairs will need to be set by x and a different variable so that the text is the proper order.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The documentation on the GROUPORDER option for the Series statement is pretty clear:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;DIV class="xis-eDocBody"&gt;
&lt;DIV class="xis-refProc"&gt;
&lt;DIV class="xis-procStatement"&gt;
&lt;DIV class="xis-procStatementSyntax"&gt;
&lt;DIV class="xis-syntaxDescription"&gt;
&lt;DIV class="xis-optionalArgGroup"&gt;
&lt;DIV id="n0iz9rcg3x496dn1sfn1g6ernd9oi" class="xis-argDescriptionPair"&gt;
&lt;DIV class="xis-argumentDescription"&gt;
&lt;TABLE class="xis-summary"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD rowspan="2" class="xis-summaryInteraction"&gt;Interactions&lt;/TD&gt;
&lt;TD class="xis-summaryText"&gt;This option is ignored unless GROUP= is specified.&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Your existing code does not supply a GROUP variable:&lt;/P&gt;
&lt;PRE&gt;proc sgplot data = Variable_Importance;

title "The Variable of Importance Plot";
series x=Gini y=Variable /lineattrs=(pattern=shortdash color=royalblue thickness=3) 
     legendlabel='Train Gini' 
    GROUPORDER=ASCENDING
 ;
xaxis label='Train Gini' display=ALL;
yaxis label='Variable' display=ALL;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Mar 2021 21:53:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Variable-Importance-Plot-from-the-proc-hpforest-procedure/m-p/724991#M35170</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-03-09T21:53:07Z</dc:date>
    </item>
    <item>
      <title>Re: Variable Importance Plot from the proc hpforest procedure</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Variable-Importance-Plot-from-the-proc-hpforest-procedure/m-p/725202#M35179</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Thank you for the reply to my question!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The variables of importance output from the proc hpforest procedure sorted by AAEOOB:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jeff_b_2-1615394363479.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/55783iF0E61392DD2DC6DA/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jeff_b_2-1615394363479.png" alt="jeff_b_2-1615394363479.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Yes, I tried to create a label variable from the PROC CONTENTS output and merging it BY VARIABLE with the variable of importance output. However, since the label variable is a character/string variable, I cannot input it on Y-axis in the PROC SGPLOT procedure. I will try using the VALUESFORMAT option. Thanks for the suggestion.&lt;/P&gt;&lt;P&gt;For the data sorting, I used the AAEOOB variable, which is absolute error out of bag. I think using this variable or any variable from the variable of importance output for sorting&amp;nbsp; is incorrect, because the&amp;nbsp;proc hpforest procedure uses own method to rank the variables (I guess by dividing mean error rate by SD or something like that), which looks like in the below figure. When I try to sort the output by any variable (MSE, OOB MSE, AE or AAEOOB), the ranking or order of the variables changes and the plot doesn't look like as it's supposed to be. I am not sure why&amp;nbsp;the&amp;nbsp;proc hpforest procedure doesn't include the variable of importance plots in it. I guess I have to use R to get the plot. I was trying to see if I can get one using SAS, too. Thank you for any suggestions with this!&lt;/P&gt;&lt;P&gt;The variables of importance output from the proc hpforest procedure:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jeff_b_1-1615393694173.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/55781i6B496951D85B34BB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jeff_b_1-1615393694173.png" alt="jeff_b_1-1615393694173.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class="branch"&gt;&lt;DIV&gt;&lt;DIV align="center"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class="branch"&gt;&lt;DIV&gt;&lt;DIV align="center"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 10 Mar 2021 16:41:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Variable-Importance-Plot-from-the-proc-hpforest-procedure/m-p/725202#M35179</guid>
      <dc:creator>jeff_b</dc:creator>
      <dc:date>2021-03-10T16:41:20Z</dc:date>
    </item>
    <item>
      <title>Re: Variable Importance Plot from the proc hpforest procedure</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Variable-Importance-Plot-from-the-proc-hpforest-procedure/m-p/725206#M35180</link>
      <description>&lt;P&gt;Since your sort order example doesn't include the Gini variable used for the Xaxis it is hard to tell what you actually need. Likely in means that data needs a different sort order. I would be tempted to sort by Gini descending &amp;lt;other variable&amp;gt; , where the other variable would place the variable_name at the top that you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A brief example with a data set you should have available:&lt;/P&gt;
&lt;PRE&gt;proc sgplot data=sashelp.class;
   scatter x=height y=name ;
run;

proc sort data=sashelp.class
       out=work.class;
   by descending height;
run;

proc sgplot data=work.class;
   scatter x=height y=name ;
run;&lt;/PRE&gt;
&lt;P&gt;When you have a character variable on an axis there isn't a "natural" order and the values of something else are controlling the order of appearance in the data set which can affect the order they appear on the axis (depends to some extent on the type of graph, in some you can order by a result calculated by SGPLOT)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Mar 2021 17:00:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Variable-Importance-Plot-from-the-proc-hpforest-procedure/m-p/725206#M35180</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-03-10T17:00:57Z</dc:date>
    </item>
    <item>
      <title>Re: Variable Importance Plot from the proc hpforest procedure</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Variable-Importance-Plot-from-the-proc-hpforest-procedure/m-p/725240#M35182</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;!&lt;/P&gt;&lt;P&gt;Thank you for the help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With some modification, the code you provided worked, although I had to create another variable called "rank" from the variable of importance output and merge it back to that dataset. I used that "rank" variable to sort, since I didn't have the Gini variable in the dataset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data ranking;&lt;BR /&gt;length Variable $100;&lt;BR /&gt;INPUT rank Variable $;&lt;BR /&gt;CARDS;&lt;BR /&gt;1 high_PA_baseline&lt;BR /&gt;2 early_weight_loss&lt;/P&gt;&lt;P&gt;....&lt;/P&gt;&lt;P&gt;;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sort data=Variable_Importance; by Variable; run;&lt;BR /&gt;proc sort data=ranking; by Variable; run;&lt;BR /&gt;*Merge;&lt;BR /&gt;data plot;&lt;BR /&gt;length Variable $100;&lt;BR /&gt;merge Variable_Importance(in=x) ranking(in=y);&lt;BR /&gt;by Variable;&lt;BR /&gt;if x=y;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sgplot data=plot;&lt;BR /&gt;scatter x=AAEOOB y=Variable ;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sort data=plot out=plot2;&lt;BR /&gt;by AAEOOB descending rank;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sgplot data=plot2;&lt;BR /&gt;scatter x=AAEOOB y=Variable ;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Mar 2021 18:57:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Variable-Importance-Plot-from-the-proc-hpforest-procedure/m-p/725240#M35182</guid>
      <dc:creator>jeff_b</dc:creator>
      <dc:date>2021-03-10T18:57:13Z</dc:date>
    </item>
  </channel>
</rss>

