Skip to content

Commit 9d440bd

Browse files
committed
Add style=voronoi for ClusterPlot
Add style=voronoi for ClusterPlot
1 parent 2ce94fe commit 9d440bd

File tree

8 files changed

+76
-41
lines changed

8 files changed

+76
-41
lines changed

Images/icon.png

35.7 KB
Loading

doc/ClusterAnalysis.mpl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
ClusterAnalysis := module()
2+
option package;
3+
description "a package for cluster analysis";
4+
5+
export ClusterPlot, ConfusionMatrix, ConfusionTable, KMeans;
6+
local CentralPointPlot, MVEE;
7+
8+
$include "ClusterPlot.mm"
9+
$include "ConfusionMatrix.mm"
10+
$include "KMeans.mm"
11+
$include "MVEE.mm"
12+
end module:

doc/ClusterPlot.mw

Lines changed: 28 additions & 22 deletions
Large diffs are not rendered by default.

install/ClusterAnalysis.help

12 KB
Binary file not shown.

install/ClusterAnalysis.maple

48 KB
Binary file not shown.

install/ClusterAnalysis.mla

-42.1 KB
Binary file not shown.

src/Build_Source.mw

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Worksheet>
3-
<Version major="2017" minor="0"/>
3+
<Version major="2018" minor="0"/>
44
<Label-Scheme value="2" prefix=""/>
5-
<View-Properties presentation="false" autoexpanding_sections="true" UserProfileName="Maple Default Profile" NumericFormat-ApplyInteger="true" NumericFormat-ApplyRational="true" NumericFormat-ApplyExponent="false">
5+
<View-Properties presentation="false" autoexpanding_sections="true" UserProfileName="Maple Default Profile" NumericFormat-ApplyInteger="true" NumericFormat-ApplyRational="true" NumericFormat-ApplyExponent="false" editable="true">
66
</View-Properties>
7-
<MapleNet-Properties prettyprint="3" warnlevel="3" preplot="" helpbrowser="standard" contextmenusize="automatic" displayprecision="-1" echo="1" unitattributes="&quot;fontweight&quot; = &quot;bold&quot;" imaginaryunit="I" longdelim="true" elisiontermsthreshold="10000" elisiondigitsafter="100" elisiondigitsbefore="100" plotdevice="inline" errorbreak="1" plotoptions="" plotdriver="opengl" quiet="false" elisiontermsbefore="100" elisiontermsafter="100" screenwidth="79" indentamount="4" plotoutput="terminal" screenpixelheight="900" rtablesize="10" useclientjvm="true" labelwidth="20" postplot="" typesetting="extended" ansi="false" elisiondigitsthreshold="10000" showassumed="1" errorcursor="false" labelling="true" screenheight="25" prompt="&gt; " verboseproc="1" latexwidth="8.0" ShowLabels="true"/>
7+
<MapleNet-Properties prettyprint="3" warnlevel="3" preplot="" helpbrowser="standard" displayprecision="-1" echo="1" unitattributes="&quot;fontweight&quot; = &quot;bold&quot;" imaginaryunit="I" longdelim="true" elisiontermsthreshold="10000" elisiondigitsafter="100" elisiondigitsbefore="100" plotdevice="inline" errorbreak="1" plotoptions="" plotdriver="opengl" quiet="false" elisiontermsbefore="100" elisiontermsafter="100" screenwidth="79" indentamount="4" plotoutput="terminal" screenpixelheight="900" rtablesize="10" useclientjvm="true" labelwidth="20" postplot="" typesetting="extended" ansi="false" elisiondigitsthreshold="10000" showassumed="1" errorcursor="false" labelling="true" screenheight="25" prompt="&gt; " verboseproc="1" latexwidth="8.0" ShowLabels="true"/>
88
<Styles>
99
<Font name="Heading 1" background="[255,255,255]" bold="true" executable="false" family="DejaVu Sans" foreground="[0,0,0]" italic="false" opaque="false" readonly="false" size="18" subscript="false" superscript="false" underline="false" placeholder="false"/>
1010
<Font name="Warning" background="[255,255,255]" bold="false" executable="false" family="Monospaced" foreground="[0,0,255]" italic="false" opaque="false" readonly="true" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
@@ -127,41 +127,41 @@
127127
</Input>
128128
</Group>
129129
<Group hide-output="false" labelreference="L4195" drawlabel="true" applyint="true" applyrational="true" applyexponent="false">
130-
<Input><Text-field prompt="&gt; " style="Maple Input" layout="Normal">makehelp( &quot;ClusterAnalysis&quot;, &quot;doc/ClusterAnalysis.mw&quot;, &quot;ClusterAnalysis.help&quot;, browser = [&quot;ClusterAnalysis&quot;,&quot;Overview&quot;] ):</Text-field>
130+
<Input><Text-field prompt="&gt; " style="Maple Input" layout="Normal">makehelp( &quot;ClusterAnalysis&quot;, &quot;../doc/ClusterAnalysis.mw&quot;, &quot;ClusterAnalysis.help&quot;, browser = [&quot;ClusterAnalysis&quot;,&quot;Overview&quot;], showhelp = false ):</Text-field>
131131
</Input>
132132
</Group>
133133
<Group hide-output="false" labelreference="L4196" drawlabel="true" applyint="true" applyrational="true" applyexponent="false">
134-
<Input><Text-field prompt="&gt; " style="Maple Input" layout="Normal">makehelp( &quot;ClusterAnalysis/ClusterPlot&quot;, &quot;doc/ClusterPlot.mw&quot;, &quot;ClusterAnalysis.help&quot;, browser = [&quot;ClusterAnalysis&quot;,&quot;ClusterPlot&quot;] ):</Text-field>
134+
<Input><Text-field prompt="&gt; " style="Maple Input" layout="Normal">makehelp( &quot;ClusterAnalysis/ClusterPlot&quot;, &quot;../doc/ClusterPlot.mw&quot;, &quot;ClusterAnalysis.help&quot;, browser = [&quot;ClusterAnalysis&quot;,&quot;ClusterPlot&quot;], showhelp = false ):</Text-field>
135135
</Input>
136136
</Group>
137137
<Group hide-output="false" labelreference="L4197" drawlabel="true" applyint="true" applyrational="true" applyexponent="false">
138-
<Input><Text-field prompt="&gt; " style="Maple Input" layout="Normal">makehelp( &quot;ClusterAnalysis/ConfusionMatrix&quot;, &quot;doc/ConfusionMatrix.mw&quot;, &quot;ClusterAnalysis.help&quot;, browser = [&quot;ClusterAnalysis&quot;,&quot;ConfusionMatrix&quot;] ):</Text-field>
138+
<Input><Text-field prompt="&gt; " style="Maple Input" layout="Normal">makehelp( &quot;ClusterAnalysis/ConfusionMatrix&quot;, &quot;../doc/ConfusionMatrix.mw&quot;, &quot;ClusterAnalysis.help&quot;, browser = [&quot;ClusterAnalysis&quot;,&quot;ConfusionMatrix&quot;], showhelp = false ):</Text-field>
139139
</Input>
140140
</Group>
141141
<Group hide-output="false" labelreference="L4198" drawlabel="true" applyint="true" applyrational="true" applyexponent="false">
142-
<Input><Text-field prompt="&gt; " style="Maple Input" layout="Normal">makehelp( &quot;ClusterAnalysis/ConfusionTable&quot;, &quot;doc/ConfusionTable.mw&quot;, &quot;ClusterAnalysis.help&quot;, browser = [&quot;ClusterAnalysis&quot;,&quot;ConfusionTable&quot;] ):</Text-field>
142+
<Input><Text-field prompt="&gt; " style="Maple Input" layout="Normal">makehelp( &quot;ClusterAnalysis/ConfusionTable&quot;, &quot;../doc/ConfusionTable.mw&quot;, &quot;ClusterAnalysis.help&quot;, browser = [&quot;ClusterAnalysis&quot;,&quot;ConfusionTable&quot;], showhelp = false ):</Text-field>
143143
</Input>
144144
</Group>
145145
<Group hide-output="false" labelreference="L4199" drawlabel="true" applyint="true" applyrational="true" applyexponent="false">
146-
<Input><Text-field prompt="&gt; " style="Maple Input" layout="Normal">makehelp( &quot;ClusterAnalysis/KMeans&quot;, &quot;doc/KMeans.mw&quot;, &quot;ClusterAnalysis.help&quot;, browser = [&quot;ClusterAnalysis&quot;,&quot;KMeans&quot;] ):</Text-field>
146+
<Input><Text-field prompt="&gt; " style="Maple Input" layout="Normal">makehelp( &quot;ClusterAnalysis/KMeans&quot;, &quot;../doc/KMeans.mw&quot;, &quot;ClusterAnalysis.help&quot;, browser = [&quot;ClusterAnalysis&quot;,&quot;KMeans&quot;], showhelp = false ):</Text-field>
147147
</Input>
148148
</Group>
149149
<Group hide-input="false" labelreference="L4200" drawlabel="true" applyint="true" applyrational="true" applyexponent="false">
150150
<Input><Text-field style="Text" layout="Normal"><Font bold="true">Build package workbook:</Font></Text-field><Text-field prompt="&gt; " style="Maple Input" layout="Normal">PackageTools:-Create(&quot;ClusterAnalysis.maple&quot;,
151151
&quot;ClusterAnalysis.mla&quot;,
152-
&quot;Overview&quot; = &quot;doc/ClusterAnalysis.mw&quot;,
153-
&quot;/doc/ClusterPlot.mw&quot; = &quot;doc/ClusterPlot.mw&quot;,
154-
&quot;/doc/ConfusionMatrix.mw&quot; = &quot;doc/ConfusionMatrix.mw&quot;,
155-
&quot;/doc/ConfusionTable.mw&quot; = &quot;doc/ConfusionTable.mw&quot;,
156-
&quot;/doc/KMeans.mw&quot; = &quot;doc/KMeans.mw&quot;,
152+
&quot;Overview&quot; = &quot;../doc/ClusterAnalysis.mw&quot;,
153+
&quot;/doc/ClusterPlot.mw&quot; = &quot;../doc/ClusterPlot.mw&quot;,
154+
&quot;/doc/ConfusionMatrix.mw&quot; = &quot;../doc/ConfusionMatrix.mw&quot;,
155+
&quot;/doc/ConfusionTable.mw&quot; = &quot;../doc/ConfusionTable.mw&quot;,
156+
&quot;/doc/KMeans.mw&quot; = &quot;../doc/KMeans.mw&quot;,
157157
&quot;/lib/ClusterAnalysis.mpl&quot; = &quot;ClusterAnalysis.mpl&quot;,
158158
&quot;/lib/ClusterAnalysis.help&quot; = &quot;ClusterAnalysis.help&quot;,
159159
&quot;/lib/ClusterPlot.mm&quot; = &quot;ClusterPlot.mm&quot;,
160160
&quot;/lib/ConfusionMatrix.mm&quot; = &quot;ConfusionMatrix.mm&quot;,
161161
&quot;/lib/KMeans.mm&quot; = &quot;KMeans.mm&quot;,
162162
&quot;/lib/MVEE.mm&quot; = &quot;MVEE.mm&quot;,
163163
&quot;/lib/BuildSource&quot; = &quot;Build_Source.mw&quot;,
164-
&quot;/Images/icon.png&quot; = &quot;icon.png&quot;
164+
&quot;/Images/icon.png&quot; = &quot;../Images/icon.png&quot;
165165
);</Text-field>
166166
</Input>
167167
<Output><Text-field style="2D Output" layout="Maple Output"><Equation executable="false" style="2D Output" display="LUkjbXNHNiMvSSttb2R1bGVuYW1lRzYiSSxUeXBlc2V0dGluZ0dJKF9zeXNsaWJHRic2I1E2Q2x1c3RlckFuYWx5c2lzLm1hcGxlRic=">UTZDbHVzdGVyQW5hbHlzaXMubWFwbGU2Ig==</Equation></Text-field>
@@ -179,12 +179,24 @@
179179
<Input><Text-field prompt="&gt; " style="Maple Input" layout="Normal">PackageTools:-SetProperty(&quot;ClusterAnalysis.maple&quot;, &quot;description&quot;, &quot;The ClusterAnalysis<Font encoding="UTF-8"> package is a collection of commands for cluster analysis.\134n</Font>Cluster analysis is a common technique for statistical data analysis and one of the main tasks of exploratory data mining. Also known as clustering, involves grouping a set of objects so that objects in the same group (cluster) are more similar to each other than to those in other groups (clusters).&quot;):</Text-field>
180180
</Input>
181181
</Group>
182-
<Group labelreference="L4210" drawlabel="true" applyint="true" applyrational="true" applyexponent="false">
183-
<Input><Text-field prompt="&gt; " style="Maple Input" layout="Normal">PackageTools:-SetProperty(&quot;this://&quot;,&quot;X-CloudId&quot;,&quot;5629844458045440&quot;);</Text-field>
182+
<Group hide-input="false" labelreference="L4210" drawlabel="true" applyint="true" applyrational="true" applyexponent="false">
183+
<Input><Text-field prompt="&gt; " style="Maple Input" layout="Normal">PackageTools:-SetProperty(&quot;ClusterAnalysis.maple&quot;,&quot;X-CloudId&quot;,&quot;5629844458045440&quot;):</Text-field>
184184
</Input>
185185
</Group>
186-
<Group labelreference="L4211" drawlabel="true" applyint="true" applyrational="true" applyexponent="false">
187-
<Input><Text-field prompt="&gt; " style="Maple Input" layout="Normal">PackageTools:-SetProperty(&quot;this://&quot;,&quot;X-CloudXId&quot;,&quot;137258&quot;);</Text-field>
186+
<Group hide-input="false" labelreference="L4211" drawlabel="true" applyint="true" applyrational="true" applyexponent="false">
187+
<Input><Text-field prompt="&gt; " style="Maple Input" layout="Normal">PackageTools:-SetProperty(&quot;ClusterAnalysis.maple&quot;,&quot;X-CloudXId&quot;,&quot;137258&quot;):</Text-field>
188+
</Input>
189+
</Group>
190+
<Group hide-input="false" labelreference="L4341" drawlabel="true" applyint="true" applyrational="true" applyexponent="false">
191+
<Input><Text-field prompt="&gt; " style="Maple Input" layout="Normal">PackageTools:-SetProperty(&quot;ClusterAnalysis.maple&quot;,&quot;X-CloudGroup&quot;,&quot;packages&quot;):</Text-field>
192+
</Input>
193+
</Group>
194+
<Group labelreference="L4342" drawlabel="true" applyint="true" applyrational="true" applyexponent="false">
195+
<Input><Text-field prompt="&gt; " style="Maple Input" layout="Normal">PackageTools:-SetProperty(&quot;ClusterAnalysis.maple&quot;,&quot;X-CloudURL&quot;,&quot;https://maple.cloud&quot;):</Text-field>
196+
</Input>
197+
</Group>
198+
<Group labelreference="L4343" drawlabel="true" applyint="true" applyrational="true" applyexponent="false">
199+
<Input><Text-field prompt="&gt; " style="Maple Input" layout="Normal"></Text-field>
188200
</Input>
189201
</Group><Presentation-Block>
190202
<Group view="presentation" inline-output="false" labelreference="L4209" drawlabel="true" applyint="true" applyrational="true" applyexponent="false">

src/ClusterPlot.mm

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
ClusterPlot := proc( X::{rtable,DataFrame,record}, # n x 2 data set
22
{center::listlist:=NULL},
33
{cluster::{rtable,list,DataSeries}:=NULL},
4-
{style::identical(convexhull, line, ellipse, none) := 'convexhull'}
4+
{style::identical(convexhull, line, ellipse, voronoi, none) := 'convexhull'}
55
)
66
local datawcluster, diffvalues, i, lcenter, ldata, ldatasplit, metadata, numdf, p1;
77

@@ -58,6 +58,11 @@ elif hastype(X, {'rtable', 'DataFrame'}) and cluster = NULL then
5858
ldatasplit(i) := ldata[i];
5959
p1(i) := MVEE(ldatasplit[i][..,1..2], 'output' = 'plot', 'color' = plots:-setcolors()[i], _rest);
6060
end do;
61+
elif style = voronoi then
62+
if lcenter = NULL then
63+
error("values for center required with style = voronoi");
64+
end if;
65+
p1 := [ComputationalGeometry:-VoronoiDiagram(lcenter, 'colorregions' = 'false', _rest)];
6166
else
6267
p1 := [NULL];
6368
end if;

0 commit comments

Comments
 (0)