From e89df42917878ab8df5aa1f5498f37da32d2ba09 Mon Sep 17 00:00:00 2001 From: Pierre Alexandre Tremblay Date: Wed, 20 May 2020 23:15:45 +0100 Subject: [PATCH] updating examples --- .../Examples/dataset/super-simple-1D-example.scd | 13 +++++-------- .../dataset/super-simple-1D-example2.scd | 16 ++++++++-------- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/release-packaging/Examples/dataset/super-simple-1D-example.scd b/release-packaging/Examples/dataset/super-simple-1D-example.scd index 43fa2f9..3e8d2b6 100644 --- a/release-packaging/Examples/dataset/super-simple-1D-example.scd +++ b/release-packaging/Examples/dataset/super-simple-1D-example.scd @@ -30,8 +30,8 @@ Routine{ /*** KMEANS ***/ ~kmeans = FluidKMeans.new(s) -~nClusters = 4; //play with this -~kmeans.fit(~ds,~nClusters,100,action:{"Done fitting".postln}) +~nClusters = 2; //play with this +~kmeans.fit(~ds,~nClusters,100,action:{|x| "Done fitting with these number of items per cluster ".post;x.postln;}) ( Routine{ @@ -50,12 +50,9 @@ Routine{ ( Routine{ var n; - ~labels.size({|x| n = x.asInteger;}); - n.postln; - n.do{|i| + ~labels.size({|x| + x.asInteger.do{|i| ~labels.getLabel(i.asString,action: {|l|("Label for" + i ++ ":" + l).postln}); - } + };}); }.play ) - - diff --git a/release-packaging/Examples/dataset/super-simple-1D-example2.scd b/release-packaging/Examples/dataset/super-simple-1D-example2.scd index a74a305..5a22bb9 100644 --- a/release-packaging/Examples/dataset/super-simple-1D-example2.scd +++ b/release-packaging/Examples/dataset/super-simple-1D-example2.scd @@ -1,5 +1,5 @@ s.reboot -~ds = FluidDataSet.new(s,\simple1data,1) +~ds = FluidDataSet.new(s,\simple1data) ~point = Buffer.alloc(s,1,1) ( Routine{ @@ -34,7 +34,8 @@ Routine{ ~kmeans = FluidKMeans.new(s) ~nClusters = 2; //play with this -~kmeans.fit(~ds,~nClusters,100,action:{"Done fitting".postln}) +~kmeans.fit(~ds,~nClusters,100,action:{|x| "Done fitting with these number of items per cluster ".post;x.postln;}) + ( Routine{ 10.do{|i| @@ -48,14 +49,13 @@ Routine{ ~labels = FluidLabelSet(s,\simple1label); ~kmeans.predict(~ds,~labels, {|x| ("Size of each cluster" + x).postln}) -( + +s( Routine{ var n; - ~labels.size({|x| n = x.asInt}); - n.asInt.do{|i| + ~labels.size({|x| + x.asInteger.do{|i| ~labels.getLabel(i.asString,action: {|l|("Label for" + i ++ ":" + l).postln}); - } + };}); }.play ) - -