<div id="AOLMsgPart_1.2_aec18402-3413-4280-bcfb-e806a60d2745"><div 
class="aolReplacedBody"><div class="aolmail_WordSection1" style="page: 
WordSection1;"><p class="aolmail_MsoNormal" style="font-family: Arial, 
sans-serif; margin: 0in 0in 0.0001pt; font-size: 12pt;"><span style="font-size: 
8pt; font-family: Calibri, sans-serif; color: windowtext;">group2</span></p><p 
class="aolmail_MsoNormal" style="font-family: Arial, sans-serif; margin: 0in 
0in 0.0001pt; font-size: 12pt;"><span style="font-size: 8pt; font-family: 
Calibri, sans-serif; color: windowtext;">(+/\@(* #) I. i.@#@]) </. 
]</span></p><p class="aolmail_MsoNormal" style="font-family: Arial, sans-serif; 
margin: 0in 0in 0.0001pt; font-size: 12pt;"><span style="font-size: 8pt; 
font-family: Calibri, sans-serif; color: windowtext;">0.35 0.3 0.3 group2 
i.20</span></p><p class="aolmail_MsoNormal" style="font-family: Arial, 
sans-serif; margin: 0in 0in 0.0001pt; font-size: 12pt;"><span style="font-size: 
8pt; font-family: Calibri, sans-serif; color: 
windowtext;">┌───────────────</span><span style="font-size: 8pt; color: 
windowtext;">┬</span><span style="font-size: 8pt; font-family: Calibri, 
sans-serif; color: windowtext;">───────────────</span><span style="font-size: 
8pt; color: windowtext;">┬</span><span style="font-size: 8pt; font-family: 
Calibri, sans-serif; color: windowtext;">─────────────────┐</span></p><p 
class="aolmail_MsoNormal" style="font-family: Arial, sans-serif; margin: 0in 
0in 0.0001pt; font-size: 12pt;"><span style="font-size: 8pt; font-family: 
Calibri, sans-serif; color: windowtext;">│0 1 2 3 4 5 6 7│8 9 10 11 12 13│14 15 
16 17 18 19│</span></p><p class="aolmail_MsoNormal" style="font-family: Arial, 
sans-serif; margin: 0in 0in 0.0001pt; font-size: 12pt;"><span style="font-size: 
8pt; font-family: Calibri, sans-serif; color: 
windowtext;">└───────────────</span><span style="font-size: 8pt; color: 
windowtext;">┴</span><span style="font-size: 8pt; font-family: Calibri, 
sans-serif; color: windowtext;">───────────────</span><span style="font-size: 
8pt; color: windowtext;">┴</span><span style="font-size: 8pt; font-family: 
Calibri, sans-serif; color: windowtext;">─────────────────┘</span><span 
style="font-size: 8pt; font-family: "Lucida Console"; color: 
windowtext;"></span></p></div></div></div><div style="position: relative;"><div 
id="phone-ad" class="phone-ad msg-read-ad AdBottomOfMsgRead" aria-hidden="true" 
style="display: block; transform: scale(1.30097);"><iframe itemscope="" 
itemtype="https://schema.org/WPAdBlock"; width="320" height="50" title="Ad" 
marginwidth="0" marginheight="0" allowtransparency="true" frameborder="0" 
scrolling="no" id="adsF1" name="adsF1" 
src="https://at.atwola.com/adiframe/3.0/5113.1/221794/0/-1/size=320x50;noperf=1;alias=93420692;noaddonpl=y;kvpg=%2Fmail.aol%2Fwebmail%2Fen-us%2Fmobile;kvugc=0;kvui=ec397f0ba2e948b884df9068293bb651;kvh5lsid=0;kvrefd=my.screenname.aol.com;kvdom=mail.aol.com;kvpage=fd125c63989a78e40505e90ca827438d60689eab;kvmn=93420692;kvgrp=637491935;kvismob=1;extmirroring=0;kvtile=2;target=_blank;aduho=-240;grp=637491935";
 style="margin-bottom: 20px;"></iframe></div></div>
Sent from AOL Mobile Mail


-----Original Message-----
From: Ric Sherlock <[email protected]>
To: Programming JForum <[email protected]>
Sent: Sat, Oct 21, 2017 03:21 PM
Subject: Re: [Jprogramming] Splitting an Array into several arrays


Jon,
The following assigns each of the data points to a group, then boxes those
groups using key.

   assignGrp=: +/\@(* #) I. i.@#@]
   group=: assignGrp </. ]
   0.35 0.35 0.3 group i.14
┌─────────┬─────────┬───────────┐
│0 1 2 3 4│5 6 7 8 9│10 11 12 13│
└─────────┴─────────┴───────────┘

On 21/10/2017 02:14, "'Jon Hough' via Programming" <
<a href="mailto:[email protected]";>[email protected]</a>> wrote:

> Hi,
>
> What I am really after is a verb that splits by percentage. To give a
> concrete uses case:
> I have a dataset, which I wish to split into training set, validation set,
> and testing set.
>
> I want 35% of the datapoints to go in the training set,
> 35% go in the validation set,
> the rest go in the test set. (Just example numbers).
>
>
> No need to worry about shuffling, randomizing etc, I am assuming the data
> is sufficiently random.
> As Raul said, I can simplify slightly by just using the size of the
> dataset as the right argument.
>
> --------------------------------------------
> On Fri, 10/20/17, Erling Hellenäs <<a 
> href="mailto:[email protected]";>[email protected]</a>> wrote:
>
>  Subject: Re: [Jprogramming] Splitting an Array into several arrays
>  To: <a href="mailto:[email protected]";>[email protected]</a>
>  Date: Friday, October 20, 2017, 10:06 PM
>
>  Hi all !
>
>  A splitSubs with CutN could possibly look like
>  this:
>
>  splitSubsE=: ([ (([:
>  # [) {. ]) ([: <. 0.5 + [: }: [ * [: # ]) ( [ , ([:
>  # ]) - [: +/ [) ]) CutN ]
>
>      (i.0) splitSubsE i.0
>
>      (,55) splitSubsE ,5
>  ┌─┐
>  │5│
>  └─┘
>      split
>  splitSubsE i.0
>  ┌┬┬┐
>  ││││
>  └┴┴┘
>      split splitSubsE i.1
>  ┌┬┬─┐
>  │││0│
>  └┴┴─┘
>      split
>  splitSubsE i.2
>  ┌─┬─┬┐
>  │0│1││
>  └─┴─┴┘
>    split
>  splitSubsE i.3
>  ┌─┬─┬─┐
>  │0│1│2│
>  └─┴─┴─┘
>
>  split splitSubsE i.4
>  ┌─┬─┬───┐
>  │0│1│2 3│
>  └─┴─┴───┘
>
>  Cheers
>
>  Erling
>  Hellenäs
>
>
>  Den 2017-10-20 kl. 14:11, skrev Erling
>  Hellenäs:
>  > Hi all!
>  >
>  > I looked for a
>  version of Cut which takes the number of items in each
>  > group as left argument. I didn't find
>  one. I think it is what you most
>  > often
>  need, because it allows groups with zero length content.
>  >
>  > I made CutN as an
>  illustration:
>  >
>  >
>  CutN=:((# {. 0 , [: }: [: +/\ ])([: < [ + [: i. ])"0
>  ])@:[ {&.>/ [: < ]
>  >
>  >    (i.0) CutN i.0
>  >
>  >    (,0) CutN i.0
>  > ┌┐
>  > ││
>  > └┘
>  >    (,1) CutN
>  10+i.1
>  > ┌──┐
>  > │10│
>  >
>  └──┘
>  >    0 2 CutN 10+i.2
>  > ┌┬─────┐
>  > ││10 11│
>  >
>  └┴─────┘
>  >    2 5 0
>  CutN 10+i.7
>  >
>  ┌─────┬──────────────┬┐
>  > │10 11│12 13 14 15 16││
>  >
>  └─────┴──────────────┴┘
>  >    0 7 0 CutN 10+i.7
>  >
>  ┌┬────────────────────┬┐
>  > ││10 11 12 13 14 15 16││
>  >
>  └┴────────────────────┴┘
>  >
>  > Cheers,
>  >
>  > Erling Hellenäs
>  >
>  >
> >
>  Den 2017-10-20 kl. 10:42, skrev 'Jon Hough' via
>  Programming:
>  >> The problem:
>  >> Let X be an array.
>  >> X=: i. 50 NB.  example
>  >>
>  >> Let
> 'split' be the percentages that each subarray takes
>  from X,
>  >> sequentially
>  >> e.g
>  >> split =:
>  0.35 0.35 0.3 NB. first array takes 35% , second sub array
>
>  >> takes  35%, third takes 30%
>  >> So in the end
>  >>
>  >> My
>  solution
>  >>
>  >>
>  splitSubs =:
>  -.~&.>/\@:(i.&.>"0@:<"0)@:}.@:>.@:((+/\
>  - ])@:[ (* , ])
>  >> #@:])
>  >>
>  >> split
>  splitSubs X
>  >>
>  >>
>  >> This gives 3
>  boxed arrays. Each array holds the indices to take from
>  X.
>  >>
>  >>
>  There is a slight problem in that the first and second
>  subarrays
>  >> have different
>  >> length, due to rounding error. I am
>  not too bothered about that
>  >> since,
>  depending on the size of X and the percentages, this is
>  >> unavoidable.
>  >>
>  >> Any more
>  succinct, nicer solutions?
>  >>
>  ----------------------------------------------------------------------
>  >> For information about J forums see <a 
> href="http://www.jsoftware.com/forums.htm"; 
> target="_blank">http://www.jsoftware.com/forums.htm</a>
>  >
>  >
>  ----------------------------------------------------------------------
>  > For information about J forums see <a 
> href="http://www.jsoftware.com/forums.htm"; 
> target="_blank">http://www.jsoftware.com/forums.htm</a>
>
>  ----------------------------------------------------------------------
>  For information about J forums see <a 
> href="http://www.jsoftware.com/forums.htm"; 
> target="_blank">http://www.jsoftware.com/forums.htm</a>
> ----------------------------------------------------------------------
> For information about J forums see <a 
> href="http://www.jsoftware.com/forums.htm"; 
> target="_blank">http://www.jsoftware.com/forums.htm</a>
----------------------------------------------------------------------
For information about J forums see <a 
href="http://www.jsoftware.com/forums.htm"; 
target="_blank">http://www.jsoftware.com/forums.htm</a>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to