diff --git a/buildsample/Build.DataMiningSample.cls b/buildsample/Build.DataMiningSample.cls
index d45d27b..b67629d 100644
--- a/buildsample/Build.DataMiningSample.cls
+++ b/buildsample/Build.DataMiningSample.cls
@@ -38,12 +38,12 @@ ClassMethod Build()
}
/// This method enables you to build the sample with a minimum of output to the Terminal.
-/// stagingroot is the name of the directory that contains the downloaded files.
-/// interactive controls whether this method displays output.
-/// Build calls this method with interactive=1.
+/// stagingroot is the name of the directory that contains the downloaded files.
+/// interactive controls whether this method displays output.
+/// Build calls this method with interactive=1.
ClassMethod run(stagingroot As %String = "", interactive As %Boolean = 0)
{
- //repeat this test here in case we go directly to this method
+ // Repeat this test here in case we go directly to this method
if $ZSTRIP(stagingroot,"<>W")="" {
if interactive {
write !, "Not a valid directory... Quitting."
@@ -51,7 +51,7 @@ ClassMethod run(stagingroot As %String = "", interactive As %Boolean = 0)
return 0
}
- //load and compile classes ***************************
+ // Load and compile classes ***************************
set dir=stagingroot_"/cls/" ;works on both Windows and Unix
if '##class(%File).DirectoryExists(dir) {
if interactive {
@@ -65,7 +65,7 @@ ClassMethod run(stagingroot As %String = "", interactive As %Boolean = 0)
}
do $system.OBJ.LoadDir(dir,"ck",,1)
- // execute the setup code in the loaded classes *********************
+ // Execute the setup code in the loaded classes *********************
if '##class(%Dictionary.CompiledClass).%ExistsId("DataMining.IrisDataset") {
if interactive {
write !!, "Looking for the class DataMining.IrisDataset"
diff --git a/cls/DataMining/ClusterAnalysis/Iris.cls b/cls/DataMining/ClusterAnalysis/Iris.cls
index fac0899..ab576d3 100644
--- a/cls/DataMining/ClusterAnalysis/Iris.cls
+++ b/cls/DataMining/ClusterAnalysis/Iris.cls
@@ -2,47 +2,43 @@ Include %occInclude
/// Use or operation of this code is subject to acceptance of the license available in the code repository for this code.
/// The test and demo for application of Cluster Analysis to Iris dataset contained in class
-/// DataMining.IrisDataset
-///
+/// DataMining.IrisDataset
/// Run method ##class(DataMining.ClusterAnalysis.Iris).test()
-///
/// See also Graphical Zen Demo implemented in class
-/// DataMining.ClusterAnalysis.ZenDemoPage
+/// DataMining.ClusterAnalysis.ZenDemoPage
Class DataMining.ClusterAnalysis.Iris [ Abstract ]
{
/// This method runs the full Cluster Analysis procedure for Iris dataset.
/// Parameters:
-///
-/// - verbose - Level of verbosity. Defualt is 2 that prints the information readable on a single screen.
+/// - verbose - Level of verbosity. Defualt is 2 that prints the information readable on a single screen.
/// Increasing verbosity might yield to too much information being printed but provides more details.
/// Verbosity 1 prints just the results but no processing information. Set to 0
/// for silent run.
-///
- NClusters - Number of clusters. The default is 3 and corresponds to the number of actual species in the
+/// - NClusters - Number of clusters. The default is 3 and corresponds to the number of actual species in the
/// dataset.
-///
- method - Algorithm to use. Default is 1 which will run "PAM with SA" implemented by class
-/// %DeepSee.extensions.clusters.PAMSA. Setting to 0 will run simple and pure PAM algorithm
-/// implemented in %DeepSee.extensions.clusters.PAM which is faster but produces less
-/// reliable results. Setting it to 2 will run CLARA implemented by %DeepSee.extensions.clusters.CLARA
+/// - method - Algorithm to use. Default is 1 which will run "PAM with SA" implemented by class
+/// %DeepSee.extensions.clusters.PAMSA. Setting to 0 will run simple and pure PAM algorithm
+/// implemented in %DeepSee.extensions.clusters.PAM which is faster but produces less
+/// reliable results. Setting it to 2 will run CLARA implemented by %DeepSee.extensions.clusters.CLARA
/// which is certainly an overkill for a small dataset like Iris.
-///
ClassMethod test(verbose As %Integer = 2, NClusters As %Integer = 3, method As %Integer = 1)
{
#dim sc As %Status = $$$OK
#dim ex As %Exception.AbstractException
#dim pam As %DeepSee.extensions.clusters.PAM
- Try{
+ try{
set pam = ..GetModel($s(method=2:"clara",method:"sa",1:"pam"), .sc)
- Quit:$$$ISERR(sc)
+ quit:$$$ISERR(sc)
set pam.K = NClusters
set pam.Verbose = verbose - 1
set sc = pam.Execute()
- Quit:$$$ISERR(sc)
+ quit:$$$ISERR(sc)
- Quit:'verbose
+ quit:'verbose
if (verbose > 2) {
do pam.printAll()
@@ -63,7 +59,7 @@ ClassMethod test(verbose As %Integer = 2, NClusters As %Integer = 3, method As %
set sc = tPMML.%SaveToClass(tModelClassName, 1, verbose)
quit:$$$ISERR(sc)
- // run PMML model against the whole dataset
+ // Run PMML model against the whole dataset
if (verbose) {
set tClusterID = ""
for i = 1:1:3 {
@@ -81,7 +77,7 @@ ClassMethod test(verbose As %Integer = 2, NClusters As %Integer = 3, method As %
quit:$$$ISERR(sc)
}
- }Catch(ex){
+ }catch(ex){
set sc = ex.AsStatus()
}
do:$$$ISERR(sc) $system.OBJ.DisplayError(sc)
@@ -97,9 +93,9 @@ ClassMethod speciesMatrix(model As %DeepSee.extensions.clusters.AbstractModel, k
set i = ""
set mostFrequent = ""
- Do {
+ do {
do model.iterateCluster(k, .i, .id, .x)
- Quit:i=""
+ quit:i=""
set flower = ##class(DataMining.IrisDataset).%OpenId(id)
set species = flower.Species
@@ -112,7 +108,7 @@ ClassMethod speciesMatrix(model As %DeepSee.extensions.clusters.AbstractModel, k
} While(i'="")
- Quit sc
+ quit sc
}
ClassMethod Summary(model As %DeepSee.extensions.clusters.AbstractModel, Output pClusterNames) As %Status
@@ -127,7 +123,7 @@ ClassMethod Summary(model As %DeepSee.extensions.clusters.AbstractModel, Output
k pClusterNames
set sc = ..GetResults(model, .correct, .error, .s1, .s2, .s3)
- Quit:$$$ISERR(sc) sc
+ quit:$$$ISERR(sc) sc
set pClusterNames(1) = s1
set pClusterNames(2) = s2
@@ -141,11 +137,11 @@ ClassMethod Summary(model As %DeepSee.extensions.clusters.AbstractModel, Output
w "Indices:", !
set asw = model.GetASWIndex().calculate(.sc)
- Quit:$$$ISERR(sc) sc
+ quit:$$$ISERR(sc) sc
set r = model.GetPearsonGammaIndex().calculate(.sc)
- Quit:$$$ISERR(sc) sc
+ quit:$$$ISERR(sc) sc
set ch = model.GetCalinskiHarabaszIndex().calculate(.sc)
- Quit:$$$ISERR(sc) sc
+ quit:$$$ISERR(sc) sc
set cost = model.TotalCost()
w "Total Final Cost = "_cost, !
@@ -153,7 +149,7 @@ ClassMethod Summary(model As %DeepSee.extensions.clusters.AbstractModel, Output
w "Pearson-Gamma (PG) = "_r, !
w "Calinski-Harabasz (CH) = "_ch, !
- Quit sc
+ quit sc
}
ClassMethod GetResults(model As %DeepSee.extensions.clusters.AbstractModel, Output correct As %Integer, Output error As %Integer, Output s1 As %String, Output s2 As %String, Output s3 As %String)
@@ -162,20 +158,20 @@ ClassMethod GetResults(model As %DeepSee.extensions.clusters.AbstractModel, Outp
#dim matrix
set sc = ..speciesMatrix(model, 1, .matrix, .s1)
- Quit:$$$ISERR(sc) sc
+ quit:$$$ISERR(sc) sc
set sc = ..speciesMatrix(model, 2, .matrix, .s2)
- Quit:$$$ISERR(sc) sc
+ quit:$$$ISERR(sc) sc
set sc = ..speciesMatrix(model, 3, .matrix, .s3)
- Quit:$$$ISERR(sc) sc
+ quit:$$$ISERR(sc) sc
set correct = $g(matrix(1,s1)) + $g(matrix(2,s2)) + $g(matrix(3,s3))
set error = $g(matrix(1,s2),0) + $g(matrix(1,s3),0)
set error = error + $g(matrix(2,s1),0) + $g(matrix(2,s3),0)
set error = error + $g(matrix(3,s1),0) + $g(matrix(3,s2),0)
- Quit sc
+ quit sc
}
ClassMethod GetModel(method As %String, Output sc As %Status) As %DeepSee.extensions.clusters.AbstractModel
@@ -187,7 +183,7 @@ ClassMethod GetModel(method As %String, Output sc As %Status) As %DeepSee.extens
if ('##class(%DeepSee.extensions.clusters.AbstractModel).Exists(dataset)){
set sc = ..PrepareModel(dataset)
- Quit:$$$ISERR(sc) ""
+ quit:$$$ISERR(sc) ""
}
if (method="sa") {
@@ -203,7 +199,7 @@ ClassMethod GetModel(method As %String, Output sc As %Status) As %DeepSee.extens
set pam.Normalize = 0
- Quit pam
+ quit pam
}
ClassMethod checkData() As %Status
@@ -211,19 +207,19 @@ ClassMethod checkData() As %Status
#dim sc As %Status = $$$OK
#dim ex As %Exception.AbstractException
- Try{
+ try{
&sql(select count(%ID) into :count from DataMining.IrisDataset)
if (count'=150) {
set sc = ##class(DataMining.IrisDataset).%KillExtent()
- Quit:$$$ISERR(sc)
+ quit:$$$ISERR(sc)
set sc = ##class(DataMining.IrisDataset).load()
- Quit:$$$ISERR(sc)
+ quit:$$$ISERR(sc)
}
- }Catch(ex){
+ }catch(ex){
set sc = ex.AsStatus()
}
- Quit sc
+ quit sc
}
ClassMethod PrepareModel(dataset As %String) As %Status
@@ -232,35 +228,35 @@ ClassMethod PrepareModel(dataset As %String) As %Status
#dim ex As %Exception.AbstractException
#dim pam As %DeepSee.extensions.clusters.PAM
- Try{
+ try{
set sc = ..checkData()
set pam = ##class(%DeepSee.extensions.clusters.PAM).New(dataset,.sc)
- Quit:$$$ISERR(sc)
+ quit:$$$ISERR(sc)
set pam.Normalize = 0
set rs = ##class(%ResultSet).%New("%DynamicQuery:SQL")
set sc = rs.Prepare("select %ID, SepalLength, SepalWidth, PetalLength, PetalWidth from DataMining.IrisDataset")
- Quit:$$$ISERR(sc)
+ quit:$$$ISERR(sc)
set sc = rs.Execute()
- Quit:$$$ISERR(sc)
+ quit:$$$ISERR(sc)
set sc = pam.SetData(rs, 4)
- Quit:$$$ISERR(sc)
+ quit:$$$ISERR(sc)
set sc = pam.Prepare()
- Quit:$$$ISERR(sc)
- }Catch(ex){
+ quit:$$$ISERR(sc)
+ }catch(ex){
set sc = ex.AsStatus()
}
do:$$$ISERR(sc) $system.OBJ.DisplayError(sc)
- Quit sc
+ quit sc
}
ClassMethod DeleteModel() As %Status
{
- Quit ##class(%DeepSee.extensions.clusters.AbstractModel).Delete("iris")
+ quit ##class(%DeepSee.extensions.clusters.AbstractModel).Delete("iris")
}
}
diff --git a/cls/DataMining/ClusterAnalysis/SimpleTest.cls b/cls/DataMining/ClusterAnalysis/SimpleTest.cls
index 9e18535..d5d3aa9 100644
--- a/cls/DataMining/ClusterAnalysis/SimpleTest.cls
+++ b/cls/DataMining/ClusterAnalysis/SimpleTest.cls
@@ -1,11 +1,9 @@
/// Use or operation of this code is subject to acceptance of the license available in the code repository for this code.
/// This is a simple demo and test for Cluster Analysis algorithms included with DeepSee.
-///
/// The 2-dimensional dataset consists of 9 points clearly distributed between two clusters.
-///
-/// Run ##class(DataMining.ClusterAnalysis.SimpleTest).test()
-/// or see also Graphical Zen Demo implemented in class
-/// DataMining.ClusterAnalysis.ZenDemoPage
+/// Run ##class(DataMining.ClusterAnalysis.SimpleTest).test()
+/// or see also Graphical Zen Demo implemented in class
+/// DataMining.ClusterAnalysis.ZenDemoPage
Class DataMining.ClusterAnalysis.SimpleTest Extends %Persistent
{
@@ -126,26 +124,5 @@ ClassMethod test(verbose As %Integer = 1, NClusters As %Integer = 2)
do:$$$ISERR(sc) $system.OBJ.DisplayError(sc)
}
-Storage Default
-{
-
-
-%%CLASSNAME
-
-
-X
-
-
-Y
-
-
-^DataMining.Clus7500.SimpleTestD
-SimpleTestDefaultData
-^DataMining.Clus7500.SimpleTestD
-^DataMining.Clus7500.SimpleTestI
-^DataMining.Clus7500.SimpleTestS
-%Library.CacheStorage
-}
-
}
diff --git a/cls/DataMining/IrisCube.cls b/cls/DataMining/IrisCube.cls
index 9ed4230..9de3361 100644
--- a/cls/DataMining/IrisCube.cls
+++ b/cls/DataMining/IrisCube.cls
@@ -1,5 +1,4 @@
/// Use or operation of this code is subject to acceptance of the license available in the code repository for this code.
-///
Class DataMining.IrisCube Extends %DeepSee.CubeDefinition [ DependsOn = DataMining.IrisDataset, ProcedureBlock ]
{
@@ -34,28 +33,28 @@ XData Cube [ XMLNamespace = "http://www.intersystems.com/deepsee" ]
ClassMethod GetPredictedSpecies(pID As %String) As %String
{
- // execute the Decision Tree model to predict the species of the IrisDataset instance for pID
+ // Execute the Decision Tree model to predict the species of the IrisDataset instance for pID
set tSC = $$$OK, tOutcome = ""
try {
- // 1: fetch the IrisDataset instance
+ // 1: Fetch the IrisDataset instance
set tIris = ##class(DataMining.IrisDataset).%OpenId(pID)
if (tIris="") {
set tSC = $$$ERROR($$$GeneralError, "Could not open IrisDataset object with ID '"_pID_"'")
quit
}
- // 2: load its properties into an array
+ // 2: Load its properties into an array
kill tData
set tData("PetalLength") = tIris.PetalLength
set tData("PetalWidth") = tIris.PetalWidth
set tData("SepalLength") = tIris.SepalLength
set tData("SepalWidth") = tIris.SepalWidth
- // 3: instantiate the Decision Tree model
+ // 3: Instantiate the Decision Tree model
set tSC = ##class(DataMining.PMML.Iris).%GetModelInstance("DecisionTree", .tModel)
quit:$$$ISERR(tSC)
- // 4: execute the model and retrieve the predicted species
+ // 4: Execute the model and retrieve the predicted species
set tSC = tModel.%ExecuteModel(.tData, .tOutput)
quit:$$$ISERR(tSC)
set tOutcome = tOutput.%GetFeatureValue("predictedValue")
@@ -67,7 +66,7 @@ ClassMethod GetPredictedSpecies(pID As %String) As %String
quit tOutcome
}
-/// Ensure DataMiningIrisDataset contains data
+/// Ensure DataMiningIrisDataset contains data
ClassMethod %OnBuildCube() As %Status
{
set tSC = ##class(DataMining.IrisDataset).%DeleteExtent()
diff --git a/cls/DataMining/IrisDataset.cls b/cls/DataMining/IrisDataset.cls
index a8a0735..9dd52df 100644
--- a/cls/DataMining/IrisDataset.cls
+++ b/cls/DataMining/IrisDataset.cls
@@ -1,20 +1,14 @@
/// Use or operation of this code is subject to acceptance of the license available in the code repository for this code.
/// This class represents the Iris dataset, perhaps the best known database to be found in the pattern recognition literature.
-///
/// The data set contains 3 classes of 50 instances each, where each class refers to a type of iris plant. One class is linearly separable from the other 2; the latter are NOT linearly separable from each other. Each record has 5 attributes:
-///
-/// - sepal length in cm
-///
- sepal width in cm
-///
- petal length in cm
-///
- petal width in cm
-///
- class (species):
-///
-/// - Iris Setosa
-///
- Iris Versicolour
-///
- Iris Virginica
-///
-///
-///
+/// sepal length in cm
+/// sepal width in cm
+/// petal length in cm
+/// petal width in cm
+/// class (species):
+/// Iris Setosa
+/// Iris Versicolour
+/// Iris Virginica
/// The dataset is taken from UCI Machine Learning Repository [http://archive.ics.uci.edu/ml]. Irvine, CA: University of California, School of Information and Computer Science by Frank, A. & Asuncion, A. (2010).
Class DataMining.IrisDataset Extends %Persistent
{
@@ -37,21 +31,21 @@ ClassMethod load() As %Status
#dim line As %String
#dim len, count As %Integer
- Try {
- Set input=##class(%Dictionary.CompiledXData).%OpenId("DataMining.IrisDataset||Iris").Data
- If '$IsObject(input) Set sc=%objlasterror Quit
+ try {
+ set input=##class(%Dictionary.CompiledXData).%OpenId("DataMining.IrisDataset||Iris").Data
+ if '$IsObject(input) set sc=%objlasterror quit
- Quit:$$$ISERR(sc)
+ quit:$$$ISERR(sc)
- Set count = 0
- While ($$$ISOK(sc)) {
+ set count = 0
+ while ($$$ISOK(sc)) {
set len = 32000
set line = input.ReadLine(.len,.sc)
- Quit:len<1
- Quit:$$$ISERR(sc)
+ quit:len<1
+ quit:$$$ISERR(sc)
- Continue:line["<"
- Continue:line[">"
+ continue:line["<"
+ continue:line[">"
set count = $i(count)
@@ -63,10 +57,10 @@ ClassMethod load() As %Status
set flower.Species = $p(line,",",5)
set sc = flower.%Save()
- Quit:$$$ISERR(sc)
+ quit:$$$ISERR(sc)
}
- } Catch (ex) {
+ } catch (ex) {
set sc = ex.AsStatus()
}
@@ -74,7 +68,7 @@ ClassMethod load() As %Status
do $system.OBJ.DisplayError(sc)
}
- Quit sc
+ quit sc
}
XData Iris
@@ -234,36 +228,5 @@ XData Iris
]]>
}
-
-Storage Default
-{
-
-
-%%CLASSNAME
-
-
-SepalLength
-
-
-SepalWidth
-
-
-PetalLength
-
-
-PetalWidth
-
-
-Species
-
-
-^DataMining.IrisDatasetD
-IrisDatasetDefaultData
-^DataMining.IrisDatasetD
-^DataMining.IrisDatasetI
-^DataMining.IrisDatasetS
-%Storage.Persistent
-}
-
}