PCA and MDS corrected helpfile with more feedback

nix
Pierre Alexandre Tremblay 5 years ago
parent 9149ea184f
commit dd528d663b

@ -100,6 +100,7 @@ FluidBufMFCC.process(s,~audio, features: ~mfcc_feature);
dsWr = FluidDataSetWr.kr(\mds_help_12D, buf: buf, trig: Done.kr(stats)); dsWr = FluidDataSetWr.kr(\mds_help_12D, buf: buf, trig: Done.kr(stats));
LocalOut.kr( Done.kr(dsWr)); LocalOut.kr( Done.kr(dsWr));
FreeSelf.kr(count - 99); FreeSelf.kr(count - 99);
Poll.kr(trig,count);
}.play; }.play;
) )
// wait for the post window to acknoledge the job is done. // wait for the post window to acknoledge the job is done.
@ -120,8 +121,7 @@ FluidBufMFCC.process(s,~audio, features: ~mfcc_feature);
//Visualise the 2D projection of our original 12D data //Visualise the 2D projection of our original 12D data
( (
d = ~reducedarray.flatten(1).unlace.deepCollect(1, { |x| x.normalize}); d = ~reducedarray.flop.deepCollect(1, { |x| x.normalize});
// d = [20.collect{1.0.rand}, 20.collect{1.0.rand}];
w = Window("scatter", Rect(128, 64, 200, 200)); w = Window("scatter", Rect(128, 64, 200, 200));
w.drawFunc = { w.drawFunc = {
Pen.use { Pen.use {
@ -137,5 +137,4 @@ w.drawFunc = {
w.refresh; w.refresh;
w.front; w.front;
) )
:: ::

@ -36,9 +36,7 @@ Source data, or the DataSet name
ARGUMENT:: destDataSet ARGUMENT:: destDataSet
Destination data, or the DataSet name Destination data, or the DataSet name
ARGUMENT:: action ARGUMENT:: action
Run when done Run when done. The variance is passed as an argument, aka the error of the new representation: a lower value means a higher fidelity to the original.
RETURNS::
The variance, aka the error of the new representation: a lower value means a higher fidelity to the original.
METHOD:: fitTransform METHOD:: fitTransform
link::Classes/FluidPCA#fit:: and link::Classes/FluidPCA#transform:: in a single pass link::Classes/FluidPCA#fit:: and link::Classes/FluidPCA#transform:: in a single pass
@ -47,9 +45,7 @@ Source data, or the DataSet name
ARGUMENT:: destDataSet ARGUMENT:: destDataSet
Destination data, or the DataSet name Destination data, or the DataSet name
ARGUMENT:: action ARGUMENT:: action
Run when done Run when done. The variance is passed as an argument, aka the error of the new representation: a lower value means a higher fidelity to the original.
RETURNS::
The variance, aka the error of the new representation: a lower value means a higher fidelity to the original.
METHOD:: transformPoint METHOD:: transformPoint
Given a trained model, transform the data point in a link::Classes/Buffer:: and write to an output Given a trained model, transform the data point in a link::Classes/Buffer:: and write to an output
@ -58,9 +54,7 @@ Input data
ARGUMENT:: destBuffer ARGUMENT:: destBuffer
Output data Output data
ARGUMENT:: action ARGUMENT:: action
Run when done Run when done. The variance is passed as an argument, aka the error of the new representation: a lower value means a higher fidelity to the original.
RETURNS::
The variance, aka the error of the new representation: a lower value means a higher fidelity to the original.
EXAMPLES:: EXAMPLES::
@ -107,18 +101,19 @@ FluidBufMFCC.process(s,~audio, features: ~mfcc_feature);
dsWr = FluidDataSetWr.kr(\pca_help_12D, buf: buf, trig: Done.kr(stats)); dsWr = FluidDataSetWr.kr(\pca_help_12D, buf: buf, trig: Done.kr(stats));
LocalOut.kr( Done.kr(dsWr)); LocalOut.kr( Done.kr(dsWr));
FreeSelf.kr(count - 99); FreeSelf.kr(count - 99);
Poll.kr(trig,count);
}.play; }.play;
) )
// wait for the post window to acknoledge the job is done. // wait for the post window to acknoledge the job is done.
//First standardize our DataSet, so that the MFCC dimensions are on comensurate scales //First standardize our DataSet, so that the MFCC dimensions are on comensurate scales
//Then apply the PCA in-place on the standardized data //Then apply the PCA in-place on the standardized data
//Download the DataSet contents into an array for plotting //Download the DataSet contents into an array for plotting
( (
~reducedarray = Array.new(100); ~reducedarray = Array.new(100);
~standardizer.fitTransform(~raw, ~standardized); ~standardizer.fitTransform(~raw, ~standardized);
~pca.fitTransform(~standardized, ~reduced, action:{ ~pca.fitTransform(~standardized, ~reduced, action:{|x|
x.postln; //pass on the variance
~reduced.dump{|x| 100.do{|i| ~reduced.dump{|x| 100.do{|i|
~reducedarray.add(x["data"][i.asString]) ~reducedarray.add(x["data"][i.asString])
}}; }};
@ -127,7 +122,7 @@ FluidBufMFCC.process(s,~audio, features: ~mfcc_feature);
//Visualise the 2D projection of our original 12D data //Visualise the 2D projection of our original 12D data
( (
d = ~reducedarray.flatten(1).unlace.deepCollect(1, { |x| x.normalize}); d = ~reducedarray.flop.deepCollect(1, { |x| x.normalize});
w = Window("scatter", Rect(128, 64, 200, 200)); w = Window("scatter", Rect(128, 64, 200, 200));
w.drawFunc = { w.drawFunc = {
Pen.use { Pen.use {

Loading…
Cancel
Save