<?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: How to make a validation column in regular JMP using JSL? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-make-a-validation-column-in-regular-JMP-using-JSL/m-p/394313#M64469</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Subject to Dan's caveats regarding random assignment, this will do it (in this case, for 75% training data).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt &amp;lt;&amp;lt; new column ("Validation", nominal, &amp;lt;&amp;lt;set values(randomshuffle( (1::nrow(dt))` &amp;gt; 0.75*nrow(dt))));
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Why this works:&lt;/P&gt;
&lt;P&gt;1) The (1::nrow)`piece creates a column vector [1 2 3 ... nrow(dt)], and transposes (using the ` operator) it into a row vector [1,2,3, ... nrow(dt)].&lt;/P&gt;
&lt;P&gt;2) Then, this row vector is compared to 0.75*nrow(dt). If greater, assign 1, if not, assign 0. So, suppose we have nrow(dt) = 100. Then the original vector is:&lt;/P&gt;
&lt;P&gt;[1, 2, 3, ... , 74, 75, 76, 77, ... 100]. After the comparison with 75, the result vector is:&lt;/P&gt;
&lt;P&gt;[0, 0, 0, ... , 0, 0, 1, 1, ... 1]. That is, 75 0s followed by 25 1s.&lt;/P&gt;
&lt;P&gt;3) Randomshuffle ( ) puts the contents of a vector into random order... so the 75 0s and 25 1s (still using a 100-row table as an example) will be encountered in random fashion.&lt;/P&gt;
&lt;P&gt;4) Finally, the &amp;lt;&amp;lt; set values message fills the column with this random assortment of 75 0s and 25 1s.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;FWIW, another way to do this interactively is to select Cols &amp;gt; New Columns... from the main menu, then fill out the dialog as below:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="brady_brady_0-1623965977282.png" style="width: 1600px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/33650i255A92076C937F0F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="brady_brady_0-1623965977282.png" alt="brady_brady_0-1623965977282.png" /&gt;&lt;/span&gt;&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;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;Brady&lt;/P&gt;</description>
    <pubDate>Thu, 17 Jun 2021 21:54:57 GMT</pubDate>
    <dc:creator>brady_brady</dc:creator>
    <dc:date>2021-06-17T21:54:57Z</dc:date>
    <item>
      <title>How to make a validation column in regular JMP using JSL?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-make-a-validation-column-in-regular-JMP-using-JSL/m-p/394270#M64462</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think there is a "Make Validation Column" function in JMP pro but I am wondering how to make a validation column (with 25% training and 75% validation) using JSL in &lt;U&gt;&lt;STRONG&gt;regular JMP&lt;/STRONG&gt;&lt;/U&gt;? Any help is appreciated.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 19:50:06 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-make-a-validation-column-in-regular-JMP-using-JSL/m-p/394270#M64462</guid>
      <dc:creator>shasheminassab</dc:creator>
      <dc:date>2023-06-09T19:50:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to make a validation column in regular JMP using JSL?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-make-a-validation-column-in-regular-JMP-using-JSL/m-p/394293#M64465</link>
      <description>&lt;P&gt;It is pretty simple to do interactively. The JSL steps should be straight-forward using this approach, too.&lt;/P&gt;
&lt;P&gt;Create a columns called Validation.&lt;/P&gt;
&lt;P&gt;Fill the entire column with 0s. A zero will indicate a training set observation.&lt;/P&gt;
&lt;P&gt;Go to Tables &amp;gt; Subset.&lt;/P&gt;
&lt;P&gt;Enter a Random-Sampling Rate of 0.75 (for your 75% validation set).&lt;/P&gt;
&lt;P&gt;Check the box for Link to Original Data Table.&lt;/P&gt;
&lt;P&gt;Click OK.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the subset table, change a validation field from 0 to 1.&lt;/P&gt;
&lt;P&gt;Right-click the 1 and Fill to end of Table.&lt;/P&gt;
&lt;P&gt;Close the subset table.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I was pretty loose with my JSL (didn't bother with proper scoping to avoid potential issues), but it should give you a pretty good start.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt=Current Data Table();
dt &amp;lt;&amp;lt; New Column( "Validation",
	Numeric,
	"Nominal",
	Format( "Best", 12 )
);
For Each Row (:Validation = 0);

dt &amp;lt;&amp;lt; Subset(
	Output Table("ValData"),
	Linked,
	Suppress formula evaluation( 0 ),
	Sampling Rate( 0.75 ),
	Selected columns only( 0 )
);
For Each Row (:Validation = 1);

Close( "ValData" );

dt &amp;lt;&amp;lt; Clear Select;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note that this is going strictly with a random assignment. Many times you really should stratify the validation by the target variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My approach was something I had kept hidden away for several years. Brady has two better approaches down below.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Jun 2021 14:05:32 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-make-a-validation-column-in-regular-JMP-using-JSL/m-p/394293#M64465</guid>
      <dc:creator>Dan_Obermiller</dc:creator>
      <dc:date>2021-06-18T14:05:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to make a validation column in regular JMP using JSL?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-make-a-validation-column-in-regular-JMP-using-JSL/m-p/394313#M64469</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Subject to Dan's caveats regarding random assignment, this will do it (in this case, for 75% training data).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt &amp;lt;&amp;lt; new column ("Validation", nominal, &amp;lt;&amp;lt;set values(randomshuffle( (1::nrow(dt))` &amp;gt; 0.75*nrow(dt))));
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Why this works:&lt;/P&gt;
&lt;P&gt;1) The (1::nrow)`piece creates a column vector [1 2 3 ... nrow(dt)], and transposes (using the ` operator) it into a row vector [1,2,3, ... nrow(dt)].&lt;/P&gt;
&lt;P&gt;2) Then, this row vector is compared to 0.75*nrow(dt). If greater, assign 1, if not, assign 0. So, suppose we have nrow(dt) = 100. Then the original vector is:&lt;/P&gt;
&lt;P&gt;[1, 2, 3, ... , 74, 75, 76, 77, ... 100]. After the comparison with 75, the result vector is:&lt;/P&gt;
&lt;P&gt;[0, 0, 0, ... , 0, 0, 1, 1, ... 1]. That is, 75 0s followed by 25 1s.&lt;/P&gt;
&lt;P&gt;3) Randomshuffle ( ) puts the contents of a vector into random order... so the 75 0s and 25 1s (still using a 100-row table as an example) will be encountered in random fashion.&lt;/P&gt;
&lt;P&gt;4) Finally, the &amp;lt;&amp;lt; set values message fills the column with this random assortment of 75 0s and 25 1s.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;FWIW, another way to do this interactively is to select Cols &amp;gt; New Columns... from the main menu, then fill out the dialog as below:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="brady_brady_0-1623965977282.png" style="width: 1600px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/33650i255A92076C937F0F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="brady_brady_0-1623965977282.png" alt="brady_brady_0-1623965977282.png" /&gt;&lt;/span&gt;&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;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;Brady&lt;/P&gt;</description>
      <pubDate>Thu, 17 Jun 2021 21:54:57 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-make-a-validation-column-in-regular-JMP-using-JSL/m-p/394313#M64469</guid>
      <dc:creator>brady_brady</dc:creator>
      <dc:date>2021-06-17T21:54:57Z</dc:date>
    </item>
  </channel>
</rss>

