<?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>shunping Tracker</title>
    <link>https://communities.sas.com/kntur85557/tracker</link>
    <description>shunping Tracker</description>
    <pubDate>Wed, 10 Jun 2026 09:03:49 GMT</pubDate>
    <dc:date>2026-06-10T09:03:49Z</dc:date>
    <item>
      <title>Tip: Spectral Clustering in SAS® Enterprise Miner™ Using Open Source Integration Node</title>
      <link>https://communities.sas.com/t5/SAS-Communities-Library/Tip-Spectral-Clustering-in-SAS-Enterprise-Miner-Using-Open/ta-p/221665</link>
      <description>&lt;DIV class="lia-message-template-content-zone"&gt;&lt;H1&gt;Introduction&lt;/H1&gt;
&lt;P&gt;Are you looking for a way to incorporate your R code into SAS® Enterprise Miner™ (EM)? The &lt;STRONG&gt;Open Source Integration&lt;/STRONG&gt; node is what you need. This node not only offers a bridge between EM and R, but also empowers EM users to access to a wider range of statistical learning methods.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the example below, I will demonstrate how to use the &lt;STRONG&gt;Open Source Integration&lt;/STRONG&gt; node to run a spectral clustering method within EM.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H1&gt;Load Data&lt;/H1&gt;
&lt;P&gt;The data in this example can be downloaded from a public website. It is available in the tab-delimited format without a name (header) row. The steps of importing the example data are as follows.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Download the data set from &lt;A href="http://cs.joensuu.fi/sipu/datasets/jain.txt"&gt;http://cs.joensuu.fi/sipu/datasets/jain.txt&lt;/A&gt; to your local machine.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Drag a &lt;STRONG&gt;File Import&lt;/STRONG&gt; node from the &lt;STRONG&gt;Sample&lt;/STRONG&gt; tab to your diagram workspace.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Enter &lt;STRONG&gt;TAB&lt;/STRONG&gt; into the &lt;STRONG&gt;Delimiter&lt;/STRONG&gt; property.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Set the &lt;STRONG&gt;Name Row&lt;/STRONG&gt; property to &lt;STRONG&gt;No&lt;/STRONG&gt;.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Click the &lt;/SPAN&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;... &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;to the right of the &lt;STRONG&gt;Import File&lt;/STRONG&gt; property. &lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Select the &lt;STRONG&gt;My Computer&lt;/STRONG&gt; option.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Click the &lt;STRONG&gt;Browse&lt;/STRONG&gt; button to locate your downloaded file, and then click the &lt;STRONG&gt;OK&lt;/STRONG&gt; button.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&lt;IMG style="font-size: 10pt; line-height: 1.5em; float: none;" class="jive-image" src="https://communities.sas.com/legacyfs/online/7598_import_property_marked.png" border="0" alt="import_property_marked.png" /&gt;&lt;/P&gt;
&lt;P&gt;U&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;se the &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;STRONG&gt;File Import&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt; node to load data sets that are s&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;tored in common delimited text formats, such as csv, tsv, etc. If your data is in SAS data set format, you should import it as a standard EM data source.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;H1&gt;Set Up Open Source Integration Node&lt;/H1&gt;
&lt;OL&gt;
&lt;LI&gt;Drag an &lt;STRONG&gt;Open Source Integration&lt;/STRONG&gt; node from the &lt;STRONG&gt;Utility&lt;/STRONG&gt; tab to your diagram workspace.&lt;/LI&gt;
&lt;LI&gt;Connect the &lt;STRONG&gt;File Import&lt;/STRONG&gt; node to the &lt;STRONG&gt;Open Source Integration&lt;/STRONG&gt; node.&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Set the value of the &lt;STRONG&gt;Training Mode&lt;/STRONG&gt; property to &lt;STRONG&gt;Unsupervised&lt;/STRONG&gt; and the value of the &lt;STRONG&gt;Output Mode&lt;/STRONG&gt; property to &lt;STRONG&gt;None&lt;/STRONG&gt;. Note that the other output modes (&lt;STRONG&gt;PMML&lt;/STRONG&gt; and &lt;STRONG&gt;Merge&lt;/STRONG&gt;) can allow variables created in R to be used in subsequent nodes in a workflow. You can find the detailed usage of these modes in SAS Enterprise Miner 13.2 Reference Help.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Click the &lt;SPAN style="font-family: 'courier new', courier;"&gt;... &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;to the right of the &lt;STRONG&gt;Code Editor&lt;/STRONG&gt; property to open the &lt;STRONG&gt;Code Editor&lt;/STRONG&gt; window.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Enter the following code into the &lt;STRONG&gt;Code Editor&lt;/STRONG&gt;.&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;library('kernlab')&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;sc &amp;lt;- specc(as.matrix(&amp;amp;EMR_IMPORT_DATA[1:2]), centers=2)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;png("EMR_SPECC.png")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;plot(&amp;amp;EMR_IMPORT_DATA[1:2], col=sc)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;dev.off()&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;To compare the result between spectral clustering and K-means, you can follow the previous steps to create another &lt;STRONG&gt;Open Source Integration&lt;/STRONG&gt; node. Enter the following code into the the &lt;STRONG&gt;Code Editor&lt;/STRONG&gt;.&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;m &amp;lt;- kmeans(&amp;amp;EMR_IMPORT_DATA[1:2], 2)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;png("EMR_KMEANS.png")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;plot(&amp;amp;EMR_IMPORT_DATA[1:2], col=m$cluster)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;dev.off()&lt;/SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the first &lt;STRONG&gt;Open Source Integration&lt;/STRONG&gt; node, we load the &lt;SPAN style="font-family: 'courier new', courier;"&gt;kernlab&lt;/SPAN&gt; library in R and run the spectral clustering function &lt;SPAN style="font-family: 'courier new', courier;"&gt;specc&lt;/SPAN&gt; on the first and second columns of the data (i.e. &lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;amp;EMR_IMPORT_DATA[1:2]&lt;/SPAN&gt;). Note that these columns should be numeric columns. We specify the number of clusters to be two and plot the result in a scatter plot where data points are colored based on their cluster membership. We save the output figure to ''EMR_SPECC.png''.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the second &lt;STRONG&gt;Open Source Integration&lt;/STRONG&gt; node, we call the &lt;SPAN style="font-family: 'courier new', courier;"&gt;kmeans&lt;/SPAN&gt; function. To see the difference between spectral clustering and K-means, we also set the number of result clusters to be two. The file name of the output figure is ''EMR_KMEANS.png''.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below is the complete diagram.&lt;/P&gt;
&lt;P&gt;&lt;IMG class="jive-image" src="https://communities.sas.com/legacyfs/online/7599_diagram_clustering.png" border="0" alt="diagram_clustering.png" /&gt;&lt;/P&gt;
&lt;H1&gt;Run and Get Results&lt;/H1&gt;
&lt;OL&gt;
&lt;LI&gt;Right-click each of the &lt;STRONG&gt;Open Source Integration&lt;/STRONG&gt; nodes and select &lt;STRONG&gt;Run&lt;/STRONG&gt;. In the &lt;STRONG&gt;Confirmation&lt;/STRONG&gt; window, click &lt;STRONG&gt;Yes&lt;/STRONG&gt;. After the node has successfully run, click &lt;STRONG&gt;Results&lt;/STRONG&gt; in the &lt;STRONG&gt;Run Status&lt;/STRONG&gt; window.&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;To view the output figure, click &lt;STRONG&gt;View&lt;/STRONG&gt; &lt;SPAN style="color: #333333; font-family: Arial, sans-serif; font-size: 14px; background-color: #ffffff;"&gt;→&lt;/SPAN&gt; &lt;STRONG&gt;SAS Results&lt;/STRONG&gt; &lt;SPAN style="color: #333333; font-family: Arial, sans-serif; font-size: 14px; background-color: #ffffff;"&gt;→&lt;/SPAN&gt; &lt;STRONG&gt;Train Graphs&lt;/STRONG&gt;.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Below are the two output figures.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;IMG style="width: 362px; height: 408.410256410256px;" class="jive-image" src="https://communities.sas.com/legacyfs/online/7601_train_spectral.png" border="0" alt="train_spectral.png" width="362" height="408" /&gt;&lt;IMG style="width: 362px; height: 411.409470752089px;" class="jive-image" src="https://communities.sas.com/legacyfs/online/7602_train_kmeans.png" border="0" alt="train_kmeans.png" width="362" height="411" /&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;As shown in the figures, spectral clustering (on the left) performs better on this data set than K-Means (on the right) in terms of accuracy.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;H1 id="summary"&gt;Summary&lt;/H1&gt;
&lt;P style="margin: 0 0 1.4em;"&gt;To sum up, the &lt;STRONG&gt;Open Source Integration&lt;/STRONG&gt; node enables users to integrate R code into Enterprise Miner workflows. For more details about the node, please refer to the help document in SAS® Enterprise Miner™.&lt;/P&gt;
&lt;H1&gt;Reference&lt;/H1&gt;
&lt;UL&gt;
&lt;LI&gt;SAS Enterprise Miner 13.2 Reference Help&lt;/LI&gt;
&lt;LI&gt;&lt;A title="http://artax.karlin.mff.cuni.cz/r-help/library/kernlab/html/specc.html" href="http://artax.karlin.mff.cuni.cz/r-help/library/kernlab/html/specc.html" target="_blank" rel="nofollow"&gt;Spectral Clustering in R&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A title="https://stat.ethz.ch/R-manual/R-devel/library/stats/html/kmeans.html" href="https://stat.ethz.ch/R-manual/R-devel/library/stats/html/kmeans.html" target="_blank" rel="nofollow"&gt;K-Means in R&lt;/A&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;/DIV&gt;</description>
      <pubDate>Tue, 06 Oct 2015 17:32:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Communities-Library/Tip-Spectral-Clustering-in-SAS-Enterprise-Miner-Using-Open/ta-p/221665</guid>
      <dc:creator>shunping</dc:creator>
      <dc:date>2015-10-06T17:32:50Z</dc:date>
    </item>
  </channel>
</rss>

