<?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: Looping in load script (KNN Algorithm) in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Looping-in-load-script-KNN-Algorithm/m-p/398602#M148396</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thanks its very helpful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I will give it a try with Weka as well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Tomer&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 28 Apr 2013 06:07:49 GMT</pubDate>
    <dc:creator />
    <dc:date>2013-04-28T06:07:49Z</dc:date>
    <item>
      <title>Looping in load script (KNN Algorithm)</title>
      <link>https://community.qlik.com/t5/QlikView/Looping-in-load-script-KNN-Algorithm/m-p/398600#M148394</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;Looping in load script&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;I have the following data:&lt;/SPAN&gt;&lt;/P&gt;&lt;TABLE border="0" cellpadding="0" cellspacing="0" width="261"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD nowrap="nowrap" style="border: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" width="63"&gt;&lt;P&gt;&lt;SPAN style="font-size: 8.0pt; font-family: 'Lucida Console'; color: black;"&gt;Customerid&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD nowrap="nowrap" style="border: solid windowtext 1.0pt; border-left: none; padding: 0 5.4pt 0 5.4pt;" width="64"&gt;&lt;P&gt;&lt;SPAN style="font-size: 8.0pt; font-family: 'Lucida Console'; color: black;"&gt;Age&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD nowrap="nowrap" style="border: solid windowtext 1.0pt; border-left: none; padding: 0 5.4pt 0 5.4pt;" width="64"&gt;&lt;P&gt;&lt;SPAN style="font-size: 8.0pt; font-family: 'Lucida Console'; color: black;"&gt;Income (k)&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD nowrap="nowrap" style="border: solid windowtext 1.0pt; border-left: none; padding: 0 5.4pt 0 5.4pt;" width="71"&gt;&lt;P&gt;&lt;SPAN style="font-size: 8.0pt; font-family: 'Lucida Console'; color: black;"&gt;Purchased&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD nowrap="nowrap" style="border: solid windowtext 1.0pt; border-top: none; padding: 0 5.4pt 0 5.4pt;" width="63"&gt;&lt;P align="right" style="text-align: right;"&gt;&lt;SPAN style="font-size: 8.0pt; font-family: 'Lucida Console'; color: black;"&gt;1&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD nowrap="nowrap" style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" width="64"&gt;&lt;P align="right" style="text-align: right;"&gt;&lt;SPAN style="font-size: 8.0pt; font-family: 'Lucida Console'; color: black;"&gt;45&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD nowrap="nowrap" style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" width="64"&gt;&lt;P align="right" style="text-align: right;"&gt;&lt;SPAN style="font-size: 8.0pt; font-family: 'Lucida Console'; color: black;"&gt;46&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD nowrap="nowrap" style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" width="71"&gt;&lt;P&gt;&lt;SPAN style="font-size: 8.0pt; font-family: 'Lucida Console'; color: black;"&gt;Book&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD nowrap="nowrap" style="border: solid windowtext 1.0pt; border-top: none; padding: 0 5.4pt 0 5.4pt;" width="63"&gt;&lt;P align="right" style="text-align: right;"&gt;&lt;SPAN style="font-size: 8.0pt; font-family: 'Lucida Console'; color: black;"&gt;2&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD nowrap="nowrap" style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" width="64"&gt;&lt;P align="right" style="text-align: right;"&gt;&lt;SPAN style="font-size: 8.0pt; font-family: 'Lucida Console'; color: black;"&gt;39&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD nowrap="nowrap" style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" width="64"&gt;&lt;P align="right" style="text-align: right;"&gt;&lt;SPAN style="font-size: 8.0pt; font-family: 'Lucida Console'; color: black;"&gt;100&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD nowrap="nowrap" style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" width="71"&gt;&lt;P&gt;&lt;SPAN style="font-size: 8.0pt; font-family: 'Lucida Console'; color: black;"&gt;TV&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD nowrap="nowrap" style="border: solid windowtext 1.0pt; border-top: none; padding: 0 5.4pt 0 5.4pt;" width="63"&gt;&lt;P align="right" style="text-align: right;"&gt;&lt;SPAN style="font-size: 8.0pt; font-family: 'Lucida Console'; color: black;"&gt;3&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD nowrap="nowrap" style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" width="64"&gt;&lt;P align="right" style="text-align: right;"&gt;&lt;SPAN style="font-size: 8.0pt; font-family: 'Lucida Console'; color: black;"&gt;35&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD nowrap="nowrap" style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" width="64"&gt;&lt;P align="right" style="text-align: right;"&gt;&lt;SPAN style="font-size: 8.0pt; font-family: 'Lucida Console'; color: black;"&gt;38&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD nowrap="nowrap" style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" width="71"&gt;&lt;P&gt;&lt;SPAN style="font-size: 8.0pt; font-family: 'Lucida Console'; color: black;"&gt;DVD&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD nowrap="nowrap" style="border: solid windowtext 1.0pt; border-top: none; padding: 0 5.4pt 0 5.4pt;" width="63"&gt;&lt;P align="right" style="text-align: right;"&gt;&lt;SPAN style="font-size: 8.0pt; font-family: 'Lucida Console'; color: black;"&gt;4&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD nowrap="nowrap" style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" width="64"&gt;&lt;P align="right" style="text-align: right;"&gt;&lt;SPAN style="font-size: 8.0pt; font-family: 'Lucida Console'; color: black;"&gt;69&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD nowrap="nowrap" style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" width="64"&gt;&lt;P align="right" style="text-align: right;"&gt;&lt;SPAN style="font-size: 8.0pt; font-family: 'Lucida Console'; color: black;"&gt;150&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD nowrap="nowrap" style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" width="71"&gt;&lt;P&gt;&lt;SPAN style="font-size: 8.0pt; font-family: 'Lucida Console'; color: black;"&gt;Car Cover&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD nowrap="nowrap" style="border: solid windowtext 1.0pt; border-top: none; padding: 0 5.4pt 0 5.4pt;" width="63"&gt;&lt;P align="right" style="text-align: right;"&gt;&lt;SPAN style="font-size: 8.0pt; font-family: 'Lucida Console'; color: black;"&gt;5&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD nowrap="nowrap" style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" width="64"&gt;&lt;P align="right" style="text-align: right;"&gt;&lt;SPAN style="font-size: 8.0pt; font-family: 'Lucida Console'; color: black;"&gt;58&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD nowrap="nowrap" style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" width="64"&gt;&lt;P align="right" style="text-align: right;"&gt;&lt;SPAN style="font-size: 8.0pt; font-family: 'Lucida Console'; color: black;"&gt;51&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD nowrap="nowrap" style="border-top: none; border-left: none; border-bottom: solid windowtext 1.0pt; border-right: solid windowtext 1.0pt; padding: 0 5.4pt 0 5.4pt;" width="71"&gt;&lt;P&gt;&lt;SPAN style="font-size: 8.0pt; font-family: 'Lucida Console'; color: black;"&gt;CD player&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;What I like to do is to find the nearest neighbor,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;Meaning, which customer id are relatively close to each other.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;The formula I’m using is:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;SQRT(((( (customerid(X)Age) - customerid(Y)Age))/(MAX(age)-Min(Age)))^2) + (((customerid(X)Income) - (customerid(Y)Income))/(MAX(Income)-MIN(Income)))^2 )&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;What I like to do is, run this in a loop in the load script,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;And get the nearest neighbor for each customer id.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;My expected output should be:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;Customer, neighbored, score&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;For example:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;For customer 5&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;SQRT((((58 - 45)/(69-35))^2) + ((51 - 46)/(150-38))^2 ) = 0.38495&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;Customer =5&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;Neighbor = 1 &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;Score = 0.38495&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;Checking customer 5 against other customers will result a higher scores, so eventually, I need the minimum for each customer that was checked.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;Thanks for your help,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;Tomer&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Apr 2013 06:43:36 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Looping-in-load-script-KNN-Algorithm/m-p/398600#M148394</guid>
      <dc:creator />
      <dc:date>2013-04-25T06:43:36Z</dc:date>
    </item>
    <item>
      <title>Re: Looping in load script (KNN Algorithm)</title>
      <link>https://community.qlik.com/t5/QlikView/Looping-in-load-script-KNN-Algorithm/m-p/398601#M148395</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;See attached qvw. I don't think this is suitable for very large number of records. You may want to use a specialized tool voor this kind of analysis. Maybe R with the Rweka package.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Apr 2013 15:02:24 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Looping-in-load-script-KNN-Algorithm/m-p/398601#M148395</guid>
      <dc:creator>Gysbert_Wassenaar</dc:creator>
      <dc:date>2013-04-25T15:02:24Z</dc:date>
    </item>
    <item>
      <title>Re: Looping in load script (KNN Algorithm)</title>
      <link>https://community.qlik.com/t5/QlikView/Looping-in-load-script-KNN-Algorithm/m-p/398602#M148396</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thanks its very helpful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I will give it a try with Weka as well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Tomer&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 28 Apr 2013 06:07:49 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Looping-in-load-script-KNN-Algorithm/m-p/398602#M148396</guid>
      <dc:creator />
      <dc:date>2013-04-28T06:07:49Z</dc:date>
    </item>
  </channel>
</rss>

