<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.appian.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Data clustering - Classification Problem</title><link>https://community.appian.com/discussions/f/data/25158/data-clustering---classification-problem</link><description>I have a CDT with some kinds of information 
 Alle data in these cdt list have a start date and an end data. I have to find period overlaps. But I&amp;#39;m just resolved that problem. My req now is another, after I find all period that overlaps Ex: index of</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Data clustering - Classification Problem</title><link>https://community.appian.com/thread/97686?ContentTypeID=1</link><pubDate>Wed, 13 Jul 2022 15:39:50 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:cf231292-d828-43d7-862b-67083451b82e</guid><dc:creator>Stefan Helzle</dc:creator><description>&lt;p&gt;You are welcome :-)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Data clustering - Classification Problem</title><link>https://community.appian.com/thread/97685?ContentTypeID=1</link><pubDate>Wed, 13 Jul 2022 15:24:23 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:ab3b7e9c-9d3c-48f3-a564-d263dac75ac1</guid><dc:creator>Carmine Mele</dc:creator><description>&lt;p&gt;yes obviously it&amp;#39;s a very good start and it&amp;#39;s a smartes solution than mine.&lt;/p&gt;
&lt;p&gt;So thankyou soo much for sharing this solution with me&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Data clustering - Classification Problem</title><link>https://community.appian.com/thread/97683?ContentTypeID=1</link><pubDate>Wed, 13 Jul 2022 15:22:04 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:dc69086c-85a1-4788-bddc-f36152cd45bf</guid><dc:creator>Stefan Helzle</dc:creator><description>&lt;p&gt;I figured this solution wasn&amp;#39;t quite what you were looking for.&amp;nbsp;But you can now modify it to exactly match your use case. Adapt the logic in the helper expression directly.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Data clustering - Classification Problem</title><link>https://community.appian.com/thread/97675?ContentTypeID=1</link><pubDate>Wed, 13 Jul 2022 15:02:34 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:18a730ab-4528-4ee8-a8b5-6326b228c004</guid><dc:creator>Carmine Mele</dc:creator><description>&lt;p&gt;Wow this is a precious contribute, and push me to better study the reduce function.&lt;/p&gt;
&lt;p&gt;But in a more articulated Manner i&amp;#39;m just do this, the problem is to have, for example:&lt;/p&gt;
&lt;p&gt;if&lt;/p&gt;
&lt;p&gt;1-2-3 overlaps eachother&lt;/p&gt;
&lt;p&gt;and then&lt;/p&gt;
&lt;p&gt;5-6&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;With&amp;nbsp;my solution and in yours we have 5 with 6 2 times, but remove duplication is not a problem (we can just use a union).&lt;/p&gt;
&lt;p&gt;the real problem is that i want to have only on times 1-2-3 and not&lt;/p&gt;
&lt;p&gt;1-2, 2-3 and then 1-2-3&lt;/p&gt;
&lt;p&gt;So if because of 2, 1 and 3 overlaps eachother i want to find only onetime 1-2-3 and not 1-2, 2-3 and then 1-2-3.&lt;/p&gt;
&lt;p&gt;Obv i want to have even 5-6 and so on, with all possibile combination.&lt;/p&gt;
&lt;p&gt;So a single entry for the maxium overlaps gradient of every single subgroup.&lt;/p&gt;
&lt;p&gt;I&amp;#39;m scaried about the possibility to try to apply matemathics Group Theory :\&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Data clustering - Classification Problem</title><link>https://community.appian.com/thread/97643?ContentTypeID=1</link><pubDate>Wed, 13 Jul 2022 06:46:58 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:a58e775a-2320-4e57-b6a5-7d0fa05e5f4e</guid><dc:creator>Stefan Helzle</dc:creator><description>&lt;p&gt;Took me a while, but here you go. The trick is to use the reduce function which allows you to keep a &amp;quot;shared memory&amp;quot; and modify this during the loop iterations. Each iteration checks one item for an overlaps with the other items. If there is a overlap, I calculate a unique identifier and check whether this already exists in the list of overlaps. If no, I add it to the list, else I just increase the size.&lt;/p&gt;
&lt;p&gt;There is a related use case to calculate the IBAN checksum you can find&amp;nbsp;in the forum as well.&lt;/p&gt;
&lt;p&gt;It requires two expressions:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!data: {
    a!map(start_date: todate(&amp;quot;01/01/2020&amp;quot;), end_date: todate(&amp;quot;01/31/2020&amp;quot;)),
    a!map(start_date: todate(&amp;quot;03/01/2020&amp;quot;), end_date: todate(&amp;quot;03/31/2020&amp;quot;)),
    a!map(start_date: todate(&amp;quot;03/29/2020&amp;quot;), end_date: todate(&amp;quot;04/02/2020&amp;quot;)),
    a!map(start_date: todate(&amp;quot;04/01/2020&amp;quot;), end_date: todate(&amp;quot;04/30/2020&amp;quot;)),
    a!map(start_date: todate(&amp;quot;05/01/2020&amp;quot;), end_date: todate(&amp;quot;05/31/2020&amp;quot;)),
    a!map(start_date: todate(&amp;quot;05/18/2020&amp;quot;), end_date: todate(&amp;quot;05/31/2020&amp;quot;)),
    a!map(start_date: todate(&amp;quot;06/01/2020&amp;quot;), end_date: todate(&amp;quot;06/33/2020&amp;quot;))
  },
  reduce(
    rule!SSH_GroupOverlapsHelper(
      shared:_,
      item:_,
      data:_
    ),
    {},
    local!data,
    local!data,
  )
)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Rule inputs: shared(any), item(any), data(any):&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!overlaps: a!forEach(
    items: ri!data,
    expression: and(
      ri!item.start_date &amp;lt;= fv!item.end_date,
      ri!item.end_date &amp;gt;= fv!item.start_date
    )
  ),
  local!groupId: joinarray(where(local!overlaps), &amp;quot;-&amp;quot;),
  if(
    sum(local!overlaps) &amp;gt; 1,
    /* We have &amp;gt; 1 overlap */
    if(
      contains(touniformstring(index(ri!shared, &amp;quot;id&amp;quot;, {})), local!groupId),
      /* Existing group */
      a!localVariables(
        local!index: lookup(ri!shared.id, local!groupId, 0),
        a!update(
          ri!shared,
          local!index,
          a!update(
            ri!shared[local!index],
            &amp;quot;size&amp;quot;,
            ri!shared[local!index].size + 1,
          )
        )
      ),
      /* New group */
      append(
        ri!shared,
        a!map(
          id: local!groupId,
          ovs: ri!data[where(local!overlaps)],
          size: 1
        )
      )
    ),
    /* An item always overlaps with itself, so ignore that case */
    ri!shared
  )
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Data clustering - Classification Problem</title><link>https://community.appian.com/thread/97627?ContentTypeID=1</link><pubDate>Tue, 12 Jul 2022 17:08:41 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:78f2250a-31be-4fcb-b2f8-95ea7fbd62a9</guid><dc:creator>Carmine Mele</dc:creator><description>&lt;p&gt;thankyou soo much for your answer, meanwhile i&amp;#39;m arrived to find all the &amp;quot;who overlaps with who&amp;quot; the problem is that with thats information i have to find all the data subgroups. so for examples if 3 overlaps with 2 and with 4 index in the map, i have to find a structure that say me the who overlaps are 2,3,4 together for a group and 5,6&amp;nbsp;together for another group&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Data clustering - Classification Problem</title><link>https://community.appian.com/thread/97626?ContentTypeID=1</link><pubDate>Tue, 12 Jul 2022 16:44:16 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:dc616bb3-4e2e-4723-a440-04291ef1733c</guid><dc:creator>Chris</dc:creator><description>&lt;p&gt;This may get you closer, this expression returns a list of maps containing overlaps.&amp;nbsp; Current version will list both ways, for instance that 2 overlaps with 3 and 3 overlaps with 2:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="csharp"&gt;a!localVariables(
  local!data: {
    a!map(start_date: todate(&amp;quot;01/01/2020&amp;quot;), end_date: todate(&amp;quot;01/31/2020&amp;quot;)),
    a!map(start_date: todate(&amp;quot;03/01/2020&amp;quot;), end_date: todate(&amp;quot;03/31/2020&amp;quot;)),
    a!map(start_date: todate(&amp;quot;03/29/2020&amp;quot;), end_date: todate(&amp;quot;04/02/2020&amp;quot;)),
    a!map(start_date: todate(&amp;quot;04/01/2020&amp;quot;), end_date: todate(&amp;quot;04/30/2020&amp;quot;)),
    a!map(start_date: todate(&amp;quot;05/01/2020&amp;quot;), end_date: todate(&amp;quot;05/31/2020&amp;quot;)),
    a!map(start_date: todate(&amp;quot;05/18/2020&amp;quot;), end_date: todate(&amp;quot;05/31/2020&amp;quot;)),
    a!map(start_date: todate(&amp;quot;06/01/2020&amp;quot;), end_date: todate(&amp;quot;06/33/2020&amp;quot;))
  },
  
  a!forEach(
    items: local!data,
    expression: {
      a!localVariables(
        local!index: fv!index,
        local!row: local!data[local!index],
        a!flatten(
          fn!reject(
            fn!isnull,
            a!forEach(
              items: local!data,
              expression: {
                if(
                  fv!index=local!index,
                  null, /* do not review row against itself */
                  if(
                    or(
                      and( /* start date is within start/end for another row */
                        local!row.start_date&amp;gt;=fv!item.start_date,
                        local!row.start_date&amp;lt;=fv!item.end_date
                      ),
                      and( /* end date is within start/end for another row */
                        local!row.end_date&amp;gt;=fv!item.start_date,
                        local!row.end_date&amp;lt;=fv!item.end_date
                      ),
                      and( /* row starts before and ends after evaluating row */
                        local!row.start_date&amp;lt;fv!item.start_date,
                        local!row.end_date&amp;gt;fv!item.end_date
                      )
                    ),
                    a!map( /* return an overlap */
                      row: local!index,
                      overlapsWith: fv!index
                    ),
                    null /* no overlap */
                  )
                )
              }
            )
          )
        )
      )
    }
  )
)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="/resized-image/__size/320x240/__key/communityserver-discussions-components-files/16/pastedimage1657644195914v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;We could refine further if you can define what you would like to see exactly for an output?&amp;nbsp; E.g. how are the &amp;quot;sub groups&amp;quot; to be found, any chain of overlaps essentially?&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Data clustering - Classification Problem</title><link>https://community.appian.com/thread/97594?ContentTypeID=1</link><pubDate>Tue, 12 Jul 2022 09:04:07 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:86084126-36ab-4ffb-bf54-93e3af09981a</guid><dc:creator>Carmine Mele</dc:creator><description>&lt;p&gt;&lt;span&gt;[ start_date:&amp;nbsp; 01/01/2020&amp;nbsp; &amp;nbsp;-&amp;nbsp; &amp;nbsp;end_date: 31/01/2020 ]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;[ start_date:&amp;nbsp; 01/03/2020&amp;nbsp; &amp;nbsp;-&amp;nbsp; &amp;nbsp;end_date: 31/03/2020 ]&lt;/p&gt;
&lt;p&gt;&lt;span&gt;[ start_date:&amp;nbsp; 29/03/2020&amp;nbsp; &amp;nbsp;-&amp;nbsp; &amp;nbsp;end_date: 02/04/2020 ]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;[ start_date:&amp;nbsp; 01/04/2020&amp;nbsp; &amp;nbsp;-&amp;nbsp; &amp;nbsp;end_date: 30/04/2020 ]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;[ start_date:&amp;nbsp; 01/05/2020&amp;nbsp; &amp;nbsp;-&amp;nbsp; &amp;nbsp;end_date: 31/05/2020 ]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;[ start_date:&amp;nbsp; 18/05/2020&amp;nbsp; &amp;nbsp;-&amp;nbsp; &amp;nbsp;end_date: 31/05/2020 ]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;[ start_date:&amp;nbsp; 01/06/2020&amp;nbsp; &amp;nbsp;-&amp;nbsp; &amp;nbsp;end_date: 30/06/2020 ]&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;now i&amp;#39;m find that index of array that have overlaps are 2,3,4,5,6&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;but i&amp;#39;m not capable to find that 2 overlaps with 3 and 4 and that 5 overlaps with 6&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>