<?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: Decision Trees in R Script Showcase</title>
    <link>https://community.fabric.microsoft.com/t5/R-Script-Showcase/Decision-Trees/m-p/686579#M331</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to know if this decision tree uses Chaid algorithym or CRT&lt;/P&gt;</description>
    <pubDate>Wed, 08 May 2019 14:30:43 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2019-05-08T14:30:43Z</dc:date>
    <item>
      <title>Decision Trees</title>
      <link>https://community.fabric.microsoft.com/t5/R-Script-Showcase/Decision-Trees/m-p/58465#M14</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="report_DTs.JPG" style="width: 550px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/11180iE75C0F0524E365DC/image-size/large?v=v2&amp;amp;px=999" role="button" title="report_DTs.JPG" alt="report_DTs.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Description&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;With decision trees, you can visualize the probability of something you want to estimate, based on decision criteria from the historic data.&lt;/P&gt;
&lt;P&gt;The decision tree classifier automatically finds the important decision criteria to consider.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Prerequisites (The sample .pbix files will not work without these prerequites completed)&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;1. Install R Engine&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Power BI Desktop does not include, deploy or install the R engine. To run R scripts in Power BI Desktop, you must separately install&lt;/SPAN&gt;R&lt;SPAN&gt; on your local computer. You can download and install &lt;/SPAN&gt;R&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;SPAN&gt;for free from many locations, including the &lt;/SPAN&gt;&lt;A title="" href="https://mran.revolutionanalytics.com/download/" target="_blank" rel="nofollow noopener noreferrer"&gt;Revolution Open download page&lt;/A&gt;&lt;SPAN&gt;, and the &lt;/SPAN&gt;&lt;A title="" href="https://cran.r-project.org/bin/windows/base/" target="_blank" rel="nofollow noopener noreferrer"&gt;CRAN Repository&lt;/A&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. Install the required R packages.&lt;/P&gt;
&lt;P&gt;Download the R script attached to this message and run it to install all required packages on your local machine.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Required&amp;nbsp;R packages:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;rpart,&amp;nbsp;rpart.plot, RColorBrewer&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Tested on:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;CRAN 3.3.1 R, MRO 3.3.0,&amp;nbsp;&lt;SPAN&gt;, powerbi.com&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Legal Disclaimers&lt;/STRONG&gt;&lt;EM&gt;:&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;A title="" href="http://aka.ms/galleryTOS" target="_self" rel="nofollow noopener noreferrer"&gt;&lt;EM&gt;Terms of Service &lt;/EM&gt;&lt;/A&gt;&lt;EM&gt;and &lt;/EM&gt;&lt;A title="" href="https://aka.ms/gallerythirdparty" target="_self" rel="nofollow noopener noreferrer"&gt;&lt;EM&gt;Third Party Programs&lt;/EM&gt;&lt;/A&gt;&lt;EM&gt;.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Nov 2016 09:31:09 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/R-Script-Showcase/Decision-Trees/m-p/58465#M14</guid>
      <dc:creator>Sharon</dc:creator>
      <dc:date>2016-11-16T09:31:09Z</dc:date>
    </item>
    <item>
      <title>Re: Decision Trees</title>
      <link>https://community.fabric.microsoft.com/t5/R-Script-Showcase/Decision-Trees/m-p/144920#M136</link>
      <description>&lt;P&gt;Dear Sharon&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is really excellent - my only question is whether there is a way to format (i) the colors, to make the output better fit in with the existing report and (ii) the formating of numbers in nodes? I am working on a loan portfolio to estimate the likelihood of default - but the loan amounts are presented in ln (XeY) format - it would be really helpful to amend these.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regardless, this is an excellent contribution!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Gratefully,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Tim&lt;/P&gt;</description>
      <pubDate>Sun, 19 Mar 2017 12:45:11 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/R-Script-Showcase/Decision-Trees/m-p/144920#M136</guid>
      <dc:creator>TimKroemer</dc:creator>
      <dc:date>2017-03-19T12:45:11Z</dc:date>
    </item>
    <item>
      <title>Re: Decision Trees</title>
      <link>https://community.fabric.microsoft.com/t5/R-Script-Showcase/Decision-Trees/m-p/157379#M150</link>
      <description>&lt;P&gt;This visual is excellent.&amp;nbsp;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;How&amp;nbsp;can I&amp;nbsp;convert the row counts from scientific notation to numeric?&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;How can I convert my dataset to method="Class"?&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;Is it possible to add Tooltips to these nodes using R-script?&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Most of my code is from your sample PBIX file.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my screenshot.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="decision tree2.jpg" style="width: 471px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/36901i6C119F7F8903B0DD/image-size/large?v=v2&amp;amp;px=999" role="button" title="decision tree2.jpg" alt="decision tree2.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Apr 2017 18:19:45 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/R-Script-Showcase/Decision-Trees/m-p/157379#M150</guid>
      <dc:creator>ironryan77</dc:creator>
      <dc:date>2017-04-11T18:19:45Z</dc:date>
    </item>
    <item>
      <title>Re: Decision Trees</title>
      <link>https://community.fabric.microsoft.com/t5/R-Script-Showcase/Decision-Trees/m-p/163093#M155</link>
      <description>&lt;P&gt;Hi &lt;A id="link_19" class="lia-link-navigation lia-page-link lia-user-name-link" title="" href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/23255" target="_self"&gt;&lt;SPAN class=""&gt;TimKroemer&lt;/SPAN&gt;&lt;/A&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Sorry for the delay in reply:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(i)&lt;SPAN&gt;the colors. &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Answer: look for "default.palettes" &amp;nbsp;in R script and change it as you like&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;(ii) the formating of numbers in nodes?&lt;BR /&gt;Answer: &amp;nbsp;prp {rpart.plot} &amp;nbsp;function has plenty of parameters.&amp;nbsp;&lt;BR /&gt;&lt;A href="https://www.rdocumentation.org/packages/rpart.plot/versions/2.1.0/topics/prp" target="_self"&gt;https://www.rdocumentation.org/packages/rpart.plot/versions/2.1.0/topics/prp&lt;/A&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 23 Apr 2017 07:33:39 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/R-Script-Showcase/Decision-Trees/m-p/163093#M155</guid>
      <dc:creator>boefraty</dc:creator>
      <dc:date>2017-04-23T07:33:39Z</dc:date>
    </item>
    <item>
      <title>Re: Decision Trees</title>
      <link>https://community.fabric.microsoft.com/t5/R-Script-Showcase/Decision-Trees/m-p/163094#M156</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;SPAN class=""&gt;&lt;A id="link_23" class="lia-link-navigation lia-page-link lia-user-name-link" title="" href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/15145" target="_self"&gt;ironryan77&lt;/A&gt;,&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class=""&gt;1) Format it via parameters of prp function, may be you will need to reload "format" function&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class=""&gt;2) Option 1: use characters instead of "numbers" for 1st column , Option 2: specify it explicitely as rpart(..., method ="class",...)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class=""&gt;3) This&amp;nbsp;visual is image, so tooltips are not possible. (We suport such functionality in &amp;nbsp;HTML-based R-powered Custom Visuals)&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 23 Apr 2017 07:32:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/R-Script-Showcase/Decision-Trees/m-p/163094#M156</guid>
      <dc:creator>boefraty</dc:creator>
      <dc:date>2017-04-23T07:32:43Z</dc:date>
    </item>
    <item>
      <title>Re: Decision Trees</title>
      <link>https://community.fabric.microsoft.com/t5/R-Script-Showcase/Decision-Trees/m-p/213298#M205</link>
      <description>&lt;P&gt;Hello Sharon,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am just starting in the power bi world and I am trying to build a decision tree, my problem is the one in the file attached. The tree doesnt appear, it says "The tree depth is zero".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Am I doing something wrong?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Eli&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jul 2017 17:20:18 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/R-Script-Showcase/Decision-Trees/m-p/213298#M205</guid>
      <dc:creator>Elizabeth24</dc:creator>
      <dc:date>2017-07-17T17:20:18Z</dc:date>
    </item>
    <item>
      <title>Re: Decision Trees</title>
      <link>https://community.fabric.microsoft.com/t5/R-Script-Showcase/Decision-Trees/m-p/213302#M206</link>
      <description>&lt;P&gt;Hello Sharon,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am having some troubles on trying to build a decision tree on power bi, I am quite new here so I think it should be something easy...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The error says : "The tree depth is zero"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance for your help,&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jul 2017 17:29:18 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/R-Script-Showcase/Decision-Trees/m-p/213302#M206</guid>
      <dc:creator>Elizabeth24</dc:creator>
      <dc:date>2017-07-17T17:29:18Z</dc:date>
    </item>
    <item>
      <title>Re: Decision Trees</title>
      <link>https://community.fabric.microsoft.com/t5/R-Script-Showcase/Decision-Trees/m-p/213371#M207</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/36318"&gt;@Elizabeth24&lt;/a&gt;,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sometimes algorithm "decides" that adding branches to root of the tree is not useful.&lt;/P&gt;
&lt;P&gt;For example, if you have 90% negatives 10% positives in your data. The accuracy of root node is 0.9 and adding branches may not improve it much. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You may try to disable cross validation.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You may try to make changes in data.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You may try to change some&amp;nbsp;parameters, for example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;complexity &amp;nbsp; = &amp;nbsp;1e-05 #change &amp;nbsp;to 1e-10&lt;/P&gt;
&lt;P&gt;minBucket = 2# change to 1&lt;/P&gt;
&lt;P&gt;minRows &amp;nbsp;= &amp;nbsp;10 # change to 5&lt;/P&gt;
&lt;P&gt;maxNumAttempts &amp;nbsp;= &amp;nbsp;10 &amp;nbsp; #change to 50&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jul 2017 19:36:11 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/R-Script-Showcase/Decision-Trees/m-p/213371#M207</guid>
      <dc:creator>boefraty</dc:creator>
      <dc:date>2017-07-17T19:36:11Z</dc:date>
    </item>
    <item>
      <title>Re: Decision Trees</title>
      <link>https://community.fabric.microsoft.com/t5/R-Script-Showcase/Decision-Trees/m-p/360150#M275</link>
      <description>&lt;P&gt;Hello Sharon,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for sharing this example. I have a question, I just tried the following short code for plotting a decision tree in Power BI:&amp;nbsp;&lt;/P&gt;&lt;P&gt;-----------------------------&lt;/P&gt;&lt;P&gt;library(rpart.plot)&lt;BR /&gt;library(rpart)&lt;/P&gt;&lt;P&gt;set.seed(1)&lt;BR /&gt;fit &amp;lt;- rpart(Kyphosis~Age+Number+Start,method="class",data=kyphosis)&lt;/P&gt;&lt;P&gt;rpart.plot(fit)&lt;/P&gt;&lt;P&gt;-----------------------------&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That worked very well and the plot appeared to be OK in PBI Desktop, but once I published the file on Power BI service the plot changed a lot (attached file).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then I tried with your template and the plot is perfect on desktop and on PBI service. I noted some differences in the code like the function&amp;nbsp;replaceFancyRpartPlot(). But I don't know exactly why the visual changed so much between desktop and the version published on the web.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you give me a hand with this?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&amp;nbsp;&lt;/P&gt;&lt;P&gt;J.&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;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 18 Feb 2018 20:05:05 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/R-Script-Showcase/Decision-Trees/m-p/360150#M275</guid>
      <dc:creator>realexander</dc:creator>
      <dc:date>2018-02-18T20:05:05Z</dc:date>
    </item>
    <item>
      <title>Re: Decision Trees</title>
      <link>https://community.fabric.microsoft.com/t5/R-Script-Showcase/Decision-Trees/m-p/360153#M276</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/55389"&gt;@realexander&lt;/a&gt;,&amp;nbsp;&lt;/P&gt;&lt;P&gt;The differences in performance for&amp;nbsp; PBI desktop and service are due to different R engine (and packages) vesrions.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Unfortunatly, we still have R3.2.2 in service, it is about to be upgraded next month.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 18 Feb 2018 20:12:34 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/R-Script-Showcase/Decision-Trees/m-p/360153#M276</guid>
      <dc:creator>boefraty</dc:creator>
      <dc:date>2018-02-18T20:12:34Z</dc:date>
    </item>
    <item>
      <title>Re: Decision Trees</title>
      <link>https://community.fabric.microsoft.com/t5/R-Script-Showcase/Decision-Trees/m-p/686579#M331</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to know if this decision tree uses Chaid algorithym or CRT&lt;/P&gt;</description>
      <pubDate>Wed, 08 May 2019 14:30:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/R-Script-Showcase/Decision-Trees/m-p/686579#M331</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-05-08T14:30:43Z</dc:date>
    </item>
    <item>
      <title>Re: Decision Trees</title>
      <link>https://community.fabric.microsoft.com/t5/R-Script-Showcase/Decision-Trees/m-p/1224606#M347</link>
      <description>&lt;P&gt;hello, where I can find the default.palettes option you are talking about? in the visual format pane there is no such thing. thank you.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jul 2020 12:17:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/R-Script-Showcase/Decision-Trees/m-p/1224606#M347</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-07-15T12:17:31Z</dc:date>
    </item>
    <item>
      <title>Re: Decision Trees</title>
      <link>https://community.fabric.microsoft.com/t5/R-Script-Showcase/Decision-Trees/m-p/2056642#M358</link>
      <description>&lt;P&gt;I'm very interested in using this visual. However, I keep getting this error... any help would be appreiciated. I don't have much R experience but did use SPSS for several years so the opportunity to bring similar tools was exciting.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Feedback Type:&lt;BR /&gt;Frown (Error)&lt;/P&gt;&lt;P&gt;Timestamp:&lt;BR /&gt;2021-09-03T15:01:58.9672630Z&lt;/P&gt;&lt;P&gt;Local Time:&lt;BR /&gt;2021-09-03T11:01:58.9672630-04:00&lt;/P&gt;&lt;P&gt;Session ID:&lt;BR /&gt;0e75c987-d3a5-4196-94e5-3beee65e93a5&lt;/P&gt;&lt;P&gt;Release:&lt;BR /&gt;August 2021&lt;/P&gt;&lt;P&gt;Product Version:&lt;BR /&gt;2.96.1061.0 (21.08) (x64)&lt;/P&gt;&lt;P&gt;Error Message:&lt;BR /&gt;R script error.&lt;BR /&gt;Loading required package: rpart&lt;BR /&gt;Loading required package: rpart.plot&lt;BR /&gt;Warning message:&lt;BR /&gt;package 'rpart.plot' was built under R version 4.0.5&lt;BR /&gt;Loading required package: RColorBrewer&lt;BR /&gt;Error: package or namespace load failed for 'RColorBrewer':&lt;BR /&gt;package 'RColorBrewer' was installed before R 4.0.0: please re-install it&lt;BR /&gt;Warning message:&lt;BR /&gt;In libraryRequireInstall("RColorBrewer") :&lt;BR /&gt;*** The package: 'RColorBrewer' was not installed ***&lt;BR /&gt;Error: package 'RColorBrewer' was installed before R 4.0.0: please re-install it&lt;BR /&gt;Execution halted&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Stack Trace:&lt;BR /&gt;Microsoft.PowerBI.ExploreServiceCommon.ScriptHandlerException: R script error.&lt;BR /&gt;Loading required package: rpart&lt;BR /&gt;Loading required package: rpart.plot&lt;BR /&gt;Warning message:&lt;BR /&gt;package 'rpart.plot' was built under R version 4.0.5&lt;BR /&gt;Loading required package: RColorBrewer&lt;BR /&gt;Error: package or namespace load failed for 'RColorBrewer':&lt;BR /&gt;package 'RColorBrewer' was installed before R 4.0.0: please re-install it&lt;BR /&gt;Warning message:&lt;BR /&gt;In libraryRequireInstall("RColorBrewer") :&lt;BR /&gt;*** The package: 'RColorBrewer' was not installed ***&lt;BR /&gt;Error: package 'RColorBrewer' was installed before R 4.0.0: please re-install it&lt;BR /&gt;Execution halted&lt;BR /&gt;---&amp;gt; Microsoft.PowerBI.Scripting.R.Exceptions.RScriptRuntimeException: R script error.&lt;BR /&gt;Loading required package: rpart&lt;BR /&gt;Loading required package: rpart.plot&lt;BR /&gt;Warning message:&lt;BR /&gt;package 'rpart.plot' was built under R version 4.0.5&lt;BR /&gt;Loading required package: RColorBrewer&lt;BR /&gt;Error: package or namespace load failed for 'RColorBrewer':&lt;BR /&gt;package 'RColorBrewer' was installed before R 4.0.0: please re-install it&lt;BR /&gt;Warning message:&lt;BR /&gt;In libraryRequireInstall("RColorBrewer") :&lt;BR /&gt;*** The package: 'RColorBrewer' was not installed ***&lt;BR /&gt;Error: package 'RColorBrewer' was installed before R 4.0.0: please re-install it&lt;BR /&gt;Execution halted&lt;/P&gt;&lt;P&gt;at Microsoft.PowerBI.Scripting.R.RScriptWrapper.RunScript(String originalScript, Int32 timeoutMs)&lt;BR /&gt;at Microsoft.PowerBI.Client.Windows.R.RScriptHandler.GenerateVisual(ScriptHandlerOptions options)&lt;/P&gt;</description>
      <pubDate>Fri, 03 Sep 2021 15:07:52 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/R-Script-Showcase/Decision-Trees/m-p/2056642#M358</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-09-03T15:07:52Z</dc:date>
    </item>
    <item>
      <title>Re: Decision Trees</title>
      <link>https://community.fabric.microsoft.com/t5/R-Script-Showcase/Decision-Trees/m-p/2942718#M368</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;&lt;BR /&gt;I downloaded the Decision Tree Chart not long ago, it was very useful for our purposes at PSU; however, now my boss cannot download this. I've done some looking around and can't seem to find it anywhere, has this been discontinued? Thank you&lt;/P&gt;</description>
      <pubDate>Thu, 01 Dec 2022 19:12:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/R-Script-Showcase/Decision-Trees/m-p/2942718#M368</guid>
      <dc:creator>JamesOrange</dc:creator>
      <dc:date>2022-12-01T19:12:50Z</dc:date>
    </item>
    <item>
      <title>Re: Decision Trees</title>
      <link>https://community.fabric.microsoft.com/t5/R-Script-Showcase/Decision-Trees/m-p/3384204#M381</link>
      <description>&lt;P&gt;I am working with the decision tree chart (v1.0.1.0) in the latest version of Power BI (2.119.986.0 64-bit / July 2023). For some reason, the text at the bottom indicating &lt;STRONG&gt;Rel error&lt;/STRONG&gt;, &lt;STRONG&gt;CVal error&lt;/STRONG&gt;, &lt;STRONG&gt;Root error&lt;/STRONG&gt;, and &lt;STRONG&gt;cp&lt;/STRONG&gt; does not appear (despite having &lt;EM&gt;Additional parameters&lt;/EM&gt; &amp;gt; &lt;EM&gt;show info&lt;/EM&gt; toggled on). Any suggestions on how to get this information to appear in the chart? Thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 17 Aug 2023 03:48:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/R-Script-Showcase/Decision-Trees/m-p/3384204#M381</guid>
      <dc:creator>lyndess</dc:creator>
      <dc:date>2023-08-17T03:48:26Z</dc:date>
    </item>
    <item>
      <title>Re: Decision Trees</title>
      <link>https://community.fabric.microsoft.com/t5/R-Script-Showcase/Decision-Trees/m-p/3388283#M382</link>
      <description>&lt;P&gt;After continued investigation into the problem, I discovered that the "issue" is actually a design choice.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;H3&gt;&lt;STRONG&gt;The Cause of the Problem&lt;/STRONG&gt;&lt;/H3&gt;&lt;P&gt;The decision tree visual in Power BI was designed for&amp;nbsp;&lt;EM&gt;classification&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;trees, not&lt;EM&gt;&amp;nbsp;regression&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;trees—although the visual certainly works for both (because the underlying R code is based on rpart, which supports both). How do I know this? When you add the visual to a Power BI report, you are prompted to enable "script visuals." If instead you click the "Review" button, you can actually see the underlying R code.&lt;/P&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;Not too far down, you'll come across these comments:&lt;/P&gt;&lt;PRE&gt;# WARNINGS: 
#     This visual intended to be used for classification tasks. It was not tested for regression trees. &lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;... And if you scroll down much further, you'll can find the code that prints out the error text at the bottom:&lt;/P&gt;&lt;PRE&gt;#info for classifier
if( showInfo &amp;amp;&amp;amp; !is.null(dtree) &amp;amp;&amp;amp; dtree$method  ==  'class')
  pbiInfo &amp;lt;- paste("Rel error  =  ", d2form(opt$relErr * rooNodeErr), 
                 "; CVal error  =  ", d2form(opt$xerror * rooNodeErr), 
                 "; Root error  =  ", d2form(rooNodeErr), 
                 ";cp  =  ", d2form(opt$CP, 3), sep  =  "")&lt;/PRE&gt;&lt;P&gt;Notice the first line of the "if" statement: "... dtree$method == '&lt;STRONG&gt;class&lt;/STRONG&gt;'. As a result of this conditional, the visual will only show the error text at the bottom if the tree is a classification tree—and not a regression tree.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(By the way: you can also review the full text of the R code on GitHub:&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://github.com/microsoft/PowerBI-visuals-decision-tree/blob/master/script.r" target="_blank" rel="noopener"&gt;https://github.com/microsoft/PowerBI-visuals-decision-tree/blob/master/script.r)&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;H3&gt;&lt;STRONG&gt;Solutions&lt;/STRONG&gt;&lt;/H3&gt;&lt;P&gt;If you need to see the error values, there are at least a few solutions to this problem. The first would be to&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;change your tree from a regression tree to a classification tree &lt;/STRONG&gt;by&amp;nbsp;converting your target variable from a continuous variable to a categorical variable. Once you do this, the error values will show up at the bottom.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A second solution, of course, would be to&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;build your decision tree directly in R, or create your own custom R visualization in Power BI&lt;/STRONG&gt;. In both cases, however, the text at the bottom still will not appear by default; you would need to manually generate that text by referencing the error values (as is done in the published decision tree chart visual). If you are interested in going down this path, here are a few links that will help you:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Creating decision trees in R:&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://www.rdocumentation.org/packages/rpart/versions/4.1.19/topics/rpart" target="_blank" rel="noopener"&gt;https://www.rdocumentation.org/packages/rpart/versions/4.1.19/topics/rpart&lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;To get the tree to look exactly like the one in Power BI:&amp;nbsp;&lt;A href="https://www.rdocumentation.org/packages/rattle/versions/5.5.1/topics/fancyRpartPlot" target="_blank" rel="noopener"&gt;https://www.rdocumentation.org/packages/rattle/versions/5.5.1/topics/fancyRpartPlot&lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;Getting your data out of Power BI and into R:&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://datakuity.com/2018/02/19/export-data-from-power-bi-into-a-file-using-r/" target="_blank" rel="noopener"&gt;https://datakuity.com/2018/02/19/export-data-from-power-bi-into-a-file-using-r/&lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;Creating R visuals in Power BI:&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://learn.microsoft.com/en-us/power-bi/create-reports/desktop-r-visuals" target="_blank" rel="noopener"&gt;https://learn.microsoft.com/en-us/power-bi/create-reports/desktop-r-visuals&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;</description>
      <pubDate>Sat, 19 Aug 2023 14:07:06 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/R-Script-Showcase/Decision-Trees/m-p/3388283#M382</guid>
      <dc:creator>lyndess</dc:creator>
      <dc:date>2023-08-19T14:07:06Z</dc:date>
    </item>
  </channel>
</rss>

