<?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 perform a KNN clustering after Proc Corresp in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-perform-a-KNN-clustering-after-Proc-Corresp/m-p/665921#M31737</link>
    <description>&lt;P&gt;I am not sure that meaningful clusters can be defined on these coordinates. I suspect that the problem you encountered with kth-Nearest-Neighbor method is due to ties, a problem which is discussed in &lt;A href="https://documentation.sas.com/?docsetId=statug&amp;amp;docsetVersion=14.3&amp;amp;docsetTarget=statug_cluster_details22.htm&amp;amp;locale=en" target="_self"&gt;the documentation&lt;/A&gt; but that I don't fully understand. &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Anyway, increasing the number of neighbors (k) can bring the number of indentifyable clusters down, but I doubt this is very useful. For reference, starting from your dim1 and dim2 values and k=36 :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc cluster data=sasforum.knn method=density k=36 outtree=tree plots=none;
var dim1 dim2;
run;

proc tree data=tree nclusters=5 out=treegraph noprint; 
copy dim1 dim2;
run;

proc sql;
select cluster, count(*) as n
from treegraph
group by cluster;
quit;

proc sgplot data=treegraph;
scatter x=dim1 y=dim2 / Group=CLUSTER;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;CLUSTER n
1 	1080
2 	124
3 	1
4 	1
5 	1&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="CorrespClusterExample23.png" style="width: 640px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/46779i0907462F26B6B987/image-size/large?v=v2&amp;amp;px=999" role="button" title="CorrespClusterExample23.png" alt="CorrespClusterExample23.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;It is hard to identify visually how meaningful clusters would look like for these data.&lt;/P&gt;</description>
    <pubDate>Mon, 29 Jun 2020 21:22:17 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2020-06-29T21:22:17Z</dc:date>
    <item>
      <title>How to perform a KNN clustering after Proc Corresp</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-perform-a-KNN-clustering-after-Proc-Corresp/m-p/665645#M31711</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I would like to perform a KNN procedure and being able to display the cluster on a 2-dim plot.&lt;BR /&gt;&lt;BR /&gt;I 'm used to perform the k-means alg with :&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Proc fastclus DATA=CORR_ACC maxclusters=8 maxiter=100 outseed=Mathis out=resultats;&lt;BR /&gt;VAR dim: ;&lt;BR /&gt;ID id ;&lt;BR /&gt;RUN ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sgplot data=resultats noautolegend ;&lt;BR /&gt;scatter x=dim1 y=dim2 / Group= CLUSTER /*datalabel=CLUSTER*/ name="ACM"&lt;BR /&gt;legendlabel="ACM";&lt;BR /&gt;keylegend "ACM";&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Where CORR_ACC nis the output of a proc Corresp. But i'm really struggling with the KNN.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any help for a simple way to do this ?&lt;/P&gt;</description>
      <pubDate>Sun, 28 Jun 2020 15:15:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-perform-a-KNN-clustering-after-Proc-Corresp/m-p/665645#M31711</guid>
      <dc:creator>Mathis1</dc:creator>
      <dc:date>2020-06-28T15:15:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to perform a KNN clustering after Proc Corresp</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-perform-a-KNN-clustering-after-Proc-Corresp/m-p/665646#M31712</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;I would like to perform a KNN procedure and being able to display the cluster on a 2-dim plot.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;BR /&gt;Which output(s) of the KNN do you want to plot in two dimensions?&lt;/P&gt;</description>
      <pubDate>Sun, 28 Jun 2020 15:56:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-perform-a-KNN-clustering-after-Proc-Corresp/m-p/665646#M31712</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-06-28T15:56:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to perform a KNN clustering after Proc Corresp</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-perform-a-KNN-clustering-after-Proc-Corresp/m-p/665654#M31713</link>
      <description>&lt;P&gt;Are you referring to the kth-Nearest-Neighbor method of &lt;STRONG&gt;proc cluster&lt;/STRONG&gt;?&lt;/P&gt;</description>
      <pubDate>Sun, 28 Jun 2020 19:57:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-perform-a-KNN-clustering-after-Proc-Corresp/m-p/665654#M31713</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2020-06-28T19:57:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to perform a KNN clustering after Proc Corresp</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-perform-a-KNN-clustering-after-Proc-Corresp/m-p/665657#M31714</link>
      <description>Yes i m referring to the kth nearest neighbors sorry.</description>
      <pubDate>Sun, 28 Jun 2020 20:18:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-perform-a-KNN-clustering-after-Proc-Corresp/m-p/665657#M31714</guid>
      <dc:creator>Mathis1</dc:creator>
      <dc:date>2020-06-28T20:18:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to perform a KNN clustering after Proc Corresp</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-perform-a-KNN-clustering-after-Proc-Corresp/m-p/665659#M31715</link>
      <description>This kind : &lt;A href="https://www.mathworks.com/help/examples/stats/win64/ClassifyingQueryDataUsingKnnsearchExample_01.png" target="_blank"&gt;https://www.mathworks.com/help/examples/stats/win64/ClassifyingQueryDataUsingKnnsearchExample_01.png&lt;/A&gt;</description>
      <pubDate>Sun, 28 Jun 2020 20:21:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-perform-a-KNN-clustering-after-Proc-Corresp/m-p/665659#M31715</guid>
      <dc:creator>Mathis1</dc:creator>
      <dc:date>2020-06-28T20:21:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to perform a KNN clustering after Proc Corresp</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-perform-a-KNN-clustering-after-Proc-Corresp/m-p/665661#M31716</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/323613"&gt;@Mathis1&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;This kind : &lt;A href="https://www.mathworks.com/help/examples/stats/win64/ClassifyingQueryDataUsingKnnsearchExample_01.png" target="_blank" rel="noopener"&gt;https://www.mathworks.com/help/examples/stats/win64/ClassifyingQueryDataUsingKnnsearchExample_01.png&lt;/A&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I'm afraid you haven't answered the question. I asked "which outputs" and you showed me "what the plot should look like". So ... which outputs from the KNN do you want to cluster? Any outputs from a KNN will be stored in a SAS data set, or printed to the output. Please be specific. Show me.&lt;/P&gt;</description>
      <pubDate>Sun, 28 Jun 2020 21:22:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-perform-a-KNN-clustering-after-Proc-Corresp/m-p/665661#M31716</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-06-28T21:22:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to perform a KNN clustering after Proc Corresp</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-perform-a-KNN-clustering-after-Proc-Corresp/m-p/665665#M31717</link>
      <description>&lt;P&gt;You must combine &lt;STRONG&gt;proc cluster&lt;/STRONG&gt; and &lt;STRONG&gt;proc tree&lt;/STRONG&gt;, like this (simplified example data from &lt;STRONG&gt;proc corresp&lt;/STRONG&gt; documentation) :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;title 'United States Population, 1920-1970';

data USPop;

input Region $14. y1920 y1930 y1940 y1950 y1960 y1970;

label y1920 = '1920'    y1930 = '1930'    y1940 = '1940'
      y1950 = '1950'    y1960 = '1960'    y1970 = '1970';

datalines;
New England        7401  8166  8437  9314 10509 11842
NY, NJ, PA        22261 26261 27539 30146 34168 37199
Great Lakes       21476 25297 26626 30399 36225 40252
Midwest           12544 13297 13517 14061 15394 16319
South Atlantic    13990 15794 17823 21182 25972 30671
KY, TN, AL, MS     8893  9887 10778 11447 12050 12803
AR, LA, OK, TX    10242 12177 13065 14538 16951 19321
Mountain           3336  3702  4150  5075  6855  8282
Pacific            5567  8195  9733 14486 20339 25454
;

* Perform Simple Correspondence Analysis;
proc corresp data=uspop out=dims plots=none;
   var y1920 -- y1970;
   id Region;
run;

proc cluster data=dims method=density k=3 outtree=tree;
where _type_ = "OBS";
var dim1 dim2;
id region;
run;

proc tree data=tree nclusters=3 out=treegraph noprint; 
copy dim1 dim2;
run;

proc sgplot data=treegraph noautolegend ;
scatter x=dim1 y=dim2 / Group= CLUSTER datalabel=_name_
    name="ACM" legendlabel="ACM";
keylegend "ACM" / title="Cluster";
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="CorrespClusterExample.png" style="width: 640px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/46745iA703D048C71C98EE/image-size/large?v=v2&amp;amp;px=999" role="button" title="CorrespClusterExample.png" alt="CorrespClusterExample.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 28 Jun 2020 21:59:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-perform-a-KNN-clustering-after-Proc-Corresp/m-p/665665#M31717</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2020-06-28T21:59:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to perform a KNN clustering after Proc Corresp</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-perform-a-KNN-clustering-after-Proc-Corresp/m-p/665729#M31724</link>
      <description>&lt;P&gt;Hello PG and thank you very much for your reply &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;I had tried to do something like this, but the issue i have is that i get way too many clusters, even when specifying "nclusters=5" in the proc tree.&lt;/P&gt;
&lt;P&gt;Please look at the table "TreeGraph", you'll se there are at least 70 Clusters :&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="TreeGraph.PNG" style="width: 692px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/46754iDB2B63B9FA2A59B8/image-size/large?v=v2&amp;amp;px=999" role="button" title="TreeGraph.PNG" alt="TreeGraph.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;Do you have any idea to remedy this ?&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jun 2020 09:49:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-perform-a-KNN-clustering-after-Proc-Corresp/m-p/665729#M31724</guid>
      <dc:creator>Mathis1</dc:creator>
      <dc:date>2020-06-29T09:49:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to perform a KNN clustering after Proc Corresp</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-perform-a-KNN-clustering-after-Proc-Corresp/m-p/665759#M31726</link>
      <description>PG ,&lt;BR /&gt;I think KNN is under PROC MODECLUS</description>
      <pubDate>Mon, 29 Jun 2020 11:39:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-perform-a-KNN-clustering-after-Proc-Corresp/m-p/665759#M31726</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2020-06-29T11:39:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to perform a KNN clustering after Proc Corresp</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-perform-a-KNN-clustering-after-Proc-Corresp/m-p/665865#M31734</link>
      <description>&lt;P&gt;There are exactly 5 clusters defined in that dataset, they are identified as : 70, 3, 71, 59 and 22.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jun 2020 17:39:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-perform-a-KNN-clustering-after-Proc-Corresp/m-p/665865#M31734</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2020-06-29T17:39:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to perform a KNN clustering after Proc Corresp</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-perform-a-KNN-clustering-after-Proc-Corresp/m-p/665873#M31735</link>
      <description>No, this is only the end of the dataset, there are way more</description>
      <pubDate>Mon, 29 Jun 2020 17:54:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-perform-a-KNN-clustering-after-Proc-Corresp/m-p/665873#M31735</guid>
      <dc:creator>Mathis1</dc:creator>
      <dc:date>2020-06-29T17:54:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to perform a KNN clustering after Proc Corresp</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-perform-a-KNN-clustering-after-Proc-Corresp/m-p/665877#M31736</link>
      <description>&lt;P&gt;Look, this is the table&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jun 2020 18:04:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-perform-a-KNN-clustering-after-Proc-Corresp/m-p/665877#M31736</guid>
      <dc:creator>Mathis1</dc:creator>
      <dc:date>2020-06-29T18:04:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to perform a KNN clustering after Proc Corresp</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/How-to-perform-a-KNN-clustering-after-Proc-Corresp/m-p/665921#M31737</link>
      <description>&lt;P&gt;I am not sure that meaningful clusters can be defined on these coordinates. I suspect that the problem you encountered with kth-Nearest-Neighbor method is due to ties, a problem which is discussed in &lt;A href="https://documentation.sas.com/?docsetId=statug&amp;amp;docsetVersion=14.3&amp;amp;docsetTarget=statug_cluster_details22.htm&amp;amp;locale=en" target="_self"&gt;the documentation&lt;/A&gt; but that I don't fully understand. &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Anyway, increasing the number of neighbors (k) can bring the number of indentifyable clusters down, but I doubt this is very useful. For reference, starting from your dim1 and dim2 values and k=36 :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc cluster data=sasforum.knn method=density k=36 outtree=tree plots=none;
var dim1 dim2;
run;

proc tree data=tree nclusters=5 out=treegraph noprint; 
copy dim1 dim2;
run;

proc sql;
select cluster, count(*) as n
from treegraph
group by cluster;
quit;

proc sgplot data=treegraph;
scatter x=dim1 y=dim2 / Group=CLUSTER;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;CLUSTER n
1 	1080
2 	124
3 	1
4 	1
5 	1&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="CorrespClusterExample23.png" style="width: 640px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/46779i0907462F26B6B987/image-size/large?v=v2&amp;amp;px=999" role="button" title="CorrespClusterExample23.png" alt="CorrespClusterExample23.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;It is hard to identify visually how meaningful clusters would look like for these data.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jun 2020 21:22:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/How-to-perform-a-KNN-clustering-after-Proc-Corresp/m-p/665921#M31737</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2020-06-29T21:22:17Z</dc:date>
    </item>
  </channel>
</rss>

