//notice how the interpolation quantizes to the FFT bins. Like most spectral processes, it benefits from oversampling the fft... at the cost of CPU power, obviously.
// when the signal is steady, larger hopSize can be accommodated to save back on the CPU
{FluidAudioTransport.ar(SinOsc.ar(220,mul: 0.1),SinOsc.ar(440,mul: 0.02),MouseX.kr(),windowSize: 8192)}.play; // here we get a default hop of half the window so 8 times less than above.
//if you CPU can cope, try this setting, almost smooth, but attacks would smear (the Y axis mixes some in to hear the effect)
// note that the process is quantized by the spectral bins. For an example of the pros and cons of these settings on this given process, please see the real-time FluidAudioTransport helpfile.
// more interesting sources: two cardboard bowing gestures
// more interesting sources: two cardboard bowing gestures
(
(
b = Buffer.read(s,File.realpath(FluidBufAudioTransport.class.filenameSymbol).dirname.withTrailingSlash ++ "../AudioFiles/Green-Box641.wav");
b = Buffer.read(s,File.realpath(FluidBufAudioTransport.class.filenameSymbol).dirname.withTrailingSlash ++ "../AudioFiles/Green-Box641.wav");
How much the buffered window moves forward, in samples. By default 512 to be similar with all other FluCoMa objects, the EBU specifies other values as per the examples below.
How much the buffered window moves forward, in samples. By default 512 to be similar with all other FluCoMa objects, the EBU specifies other values as per the examples below.
ARGUMENT:: padding
Controls the zero-padding added to either end of the source buffer or segment. Possible values are 0 (no padding), 1 (default, half the window size), or 2 (window size - hop size). Padding ensures that all input samples are completely analysed: with no padding, the first analysis window starts at time 0, and the samples at either end will be tapered by the STFT windowing function. Mode 1 has the effect of centering the first sample in the analysis window and ensuring that the very start and end of the segment are accounted for in the analysis. Mode 2 can be useful when the overlap factor (window size / hop size) is greater than 2, to ensure that the input samples at either end of the segment are covered by the same number of analysis frames as the rest of the analysed material.
ARGUMENT:: freeWhenDone
ARGUMENT:: freeWhenDone
Free the server instance when processing complete. Default true
Free the server instance when processing complete. Default true
The inner FFT/IFFT size. It should be at least 4 samples long, at least the size of the window, and a power of 2. Making it larger allows an oversampling of the spectral precision. The -1 default value will use the next power of 2 equal or above the windowSize.
The inner FFT/IFFT size. It should be at least 4 samples long, at least the size of the window, and a power of 2. Making it larger allows an oversampling of the spectral precision. The -1 default value will use the next power of 2 equal or above the windowSize.
ARGUMENT:: padding
Controls the zero-padding added to either end of the source buffer or segment. Possible values are 0 (no padding), 1 (default, half the window size), or 2 (window size - hop size). Padding ensures that all input samples are completely analysed: with no padding, the first analysis window starts at time 0, and the samples at either end will be tapered by the STFT windowing function. Mode 1 has the effect of centering the first sample in the analysis window and ensuring that the very start and end of the segment are accounted for in the analysis. Mode 2 can be useful when the overlap factor (window size / hop size) is greater than 2, to ensure that the input samples at either end of the segment are covered by the same number of analysis frames as the rest of the analysed material.
ARGUMENT:: freeWhenDone
ARGUMENT:: freeWhenDone
Free the server instance when processing complete. Default true
Free the server instance when processing complete. Default true
ARGUMENT:: action
ARGUMENT:: action
A Function to be evaluated once the offline process has finished and all Buffer's instance variables have been updated on the client side. The function will be passed [features] as an argument.
A Function to be evaluated once the offline process has finished and all Buffer's instance variables have been updated on the client side. The function will be passed [features] as an argument.
The inner FFT/IFFT size. It should be at least 4 samples long, at least the size of the window, and a power of 2. Making it larger allows an oversampling of the spectral precision. The -1 default value will use the next power of 2 equal or above the windowSize.
The inner FFT/IFFT size. It should be at least 4 samples long, at least the size of the window, and a power of 2. Making it larger allows an oversampling of the spectral precision. The -1 default value will use the next power of 2 equal or above the windowSize.
ARGUMENT:: padding
Controls the zero-padding added to either end of the source buffer or segment. Possible values are 0 (no padding), 1 (default, half the window size), or 2 (window size - hop size). Padding ensures that all input samples are completely analysed: with no padding, the first analysis window starts at time 0, and the samples at either end will be tapered by the STFT windowing function. Mode 1 has the effect of centering the first sample in the analysis window and ensuring that the very start and end of the segment are accounted for in the analysis. Mode 2 can be useful when the overlap factor (window size / hop size) is greater than 2, to ensure that the input samples at either end of the segment are covered by the same number of analysis frames as the rest of the analysed material.
ARGUMENT:: freeWhenDone
ARGUMENT:: freeWhenDone
Free the server instance when processing complete. Default true
Free the server instance when processing complete. Default true
The inner FFT/IFFT size. It should be at least 4 samples long, at least the size of the window, and a power of 2. Making it larger allows an oversampling of the spectral precision. The -1 default value will use the next power of 2 equal or above the windowSize.
The inner FFT/IFFT size. It should be at least 4 samples long, at least the size of the window, and a power of 2. Making it larger allows an oversampling of the spectral precision. The -1 default value will use the next power of 2 equal or above the windowSize.
ARGUMENT:: padding
Controls the zero-padding added to either end of the source buffer or segment. Possible values are 0 (no padding), 1 (default, half the window size), or 2 (window size - hop size). Padding ensures that all input samples are completely analysed: with no padding, the first analysis window starts at time 0, and the samples at either end will be tapered by the STFT windowing function. Mode 1 has the effect of centering the first sample in the analysis window and ensuring that the very start and end of the segment are accounted for in the analysis. Mode 2 can be useful when the overlap factor (window size / hop size) is greater than 2, to ensure that the input samples at either end of the segment are covered by the same number of analysis frames as the rest of the analysed material.
ARGUMENT:: freeWhenDone
ARGUMENT:: freeWhenDone
Free the server instance when processing complete. Default true
Free the server instance when processing complete. Default true
ARGUMENT:: action
ARGUMENT:: action
A Function to be evaluated once the offline process has finished and all Buffer's instance variables have been updated on the client side. The function will be passed [features] as an argument.
A Function to be evaluated once the offline process has finished and all Buffer's instance variables have been updated on the client side. The function will be passed [features] as an argument.
@ -164,8 +167,8 @@ d.do({
e.postln;
e.postln;
//granulate only the frames that are in our buffer
//granulate only the frames that are in our buffer
// We need to convert our indices to frame start. Their position was (index * hopSize) - (windowSize) in FluidBufPitch
// We need to convert our indices to frame start. Their position was (index * hopSize) - (hopSize) in FluidBufPitch
related:: Classes/SomeRelatedClass, Reference/SomeRelatedStuff, etc.
related:: Classes/Buffer
DESCRIPTION::
DESCRIPTION::
(put long description here)
Performs either a forward or inverse Short-Time Fourier Transform (STFT) on a single channel source buffer~. In the forward case, resulting magnitudes and phases can be written to output buffers. In the inverse case, these buffers can be used to reconstruct the original source into a new buffer.
CLASSMETHODS::
The magntude and phase buffers are laid out as (number of hops, number of bins). The number of hops is a function of the source length and the hop size. The number of bins is (1 + (fft size / 2)).
METHOD:: processBlocking
(describe method here)
ARGUMENT:: server
(describe argument here)
ARGUMENT:: source
(describe argument here)
ARGUMENT:: startFrame
(describe argument here)
ARGUMENT:: numFrames
(describe argument here)
ARGUMENT:: startChan
(describe argument here)
ARGUMENT:: magnitudeBuffer
The object is restricted to analysing a single source channel, because the channel counts of the magntude and phase buffers would quickly get out of hand otherwise.
(describe argument here)
ARGUMENT:: phaseBuffer
CLASSMETHODS::
(describe argument here)
ARGUMENT:: resynthesisBuffer
(describe argument here)
ARGUMENT:: inverse
(describe argument here)
ARGUMENT:: freeWhenDone
(describe argument here)
ARGUMENT:: action
(describe argument here)
returns:: (describe returnvalue here)
private::new1
METHOD:: process
METHOD:: process, processBlocking
(describe method here)
Run the process on the given sever, and perfrom code::action:: when done
ARGUMENT:: server
ARGUMENT:: server
(describe argument here)
The link::Classes/Server:: on which to run
ARGUMENT:: source
ARGUMENT:: source
(describe argument here)
The link::Classes/Buffer:: to use for the forward STFT
ARGUMENT:: startFrame
ARGUMENT:: startFrame
(describe argument here)
The starting point for analysis in the source (in samples)
ARGUMENT:: numFrames
ARGUMENT:: numFrames
(describe argument here)
The duration (in samples) to analyse
ARGUMENT:: startChan
ARGUMENT:: startChan
(describe argument here)
The channel to analyse
ARGUMENT:: magnitudeBuffer
ARGUMENT:: magnitude
(describe argument here)
The link::Classes/Buffer:: to write magnitudes to in the forward case, or read from in the inverse case. This is optional for the forward transform, mandatory for the inverse.
ARGUMENT:: phaseBuffer
ARGUMENT:: phase
(describe argument here)
The link::Classes/Buffer:: to write phases to in the forward case, or read from in the inverse case. This is optional for the forward transform, mandatory for the inverse.
ARGUMENT:: resynthesisBuffer
ARGUMENT:: resynthesis
(describe argument here)
The link::Classes/Buffer:: to write re-synthesised data to in the inverse case. Ignored for the forward transform. Mandatory in the inverse case.
ARGUMENT:: inverse
ARGUMENT:: inverse
(describe argument here)
When set to 1, an inverse STFT is performed, and the resynthesised data is written to the resynthesis buffer using overlap-add.
ARGUMENT:: freeWhenDone
ARGUMENT:: windowSize
(describe argument here)
The number of source samples that are analysed at once.
ARGUMENT:: action
ARGUMENT:: hopSize
(describe argument here)
How many samples there are in-between analysis windows. The -1 default value will default to half of windowSize (overlap of 2).
returns:: (describe returnvalue here)
ARGUMENT:: fftSize
The FFT/IFFT size. It should be at least 4 samples long, at least the size of the window, and a power of 2. Making it larger allows an oversampling of the spectral precision. The -1 default value will use the next power of 2 equal or above the windowSize. For this object it is effectively capped at 65536.
METHOD:: kr
ARGUMENT:: padding
(describe method here)
Controls the zero-padding added to either end of the source buffer or segment. Possible values are 0 (no padding), 1 (default, half the window size), or 2 (window size - hop size). Padding ensures that all input samples are completely analysed: with no padding, the first analysis window starts at time 0, and the samples at either end will be tapered by the STFT windowing function. Mode 1 has the effect of centering the first sample in the analysis window and ensuring that the very start and end of the segment are accounted for in the analysis. Mode 2 can be useful when the overlap factor (window size / hop size) is greater than 2, to ensure that the input samples at either end of the segment are covered by the same number of analysis frames as the rest of the analysed material.
ARGUMENT:: source
ARGUMENT:: freeWhenDone
(describe argument here)
Free the server instance when processing complete. Default true
ARGUMENT:: startFrame
(describe argument here)
ARGUMENT:: numFrames
(describe argument here)
ARGUMENT:: startChan
(describe argument here)
ARGUMENT:: magnitudeBuffer
(describe argument here)
ARGUMENT:: phaseBuffer
(describe argument here)
ARGUMENT:: resynthesisBuffer
(describe argument here)
ARGUMENT:: inverse
(describe argument here)
ARGUMENT:: trig
(describe argument here)
ARGUMENT:: blocking
(describe argument here)
returns:: (describe returnvalue here)
ARGUMENT:: action
Runs when processing is complete
INSTANCEMETHODS::
INSTANCEMETHODS::
@ -128,27 +70,40 @@ EXAMPLES::
code::
code::
s.reboot
s.reboot
(
(
b = Buffer.read(s,File.realpath(FluidBufSTFT.class.filenameSymbol).dirname.withTrailingSlash ++ "../AudioFiles/Tremblay-AaS-AcousticStrums-M.wav");
b = Buffer.read(s,File.realpath(FluidBufSTFT.class.filenameSymbol).dirname.withTrailingSlash ++ "../AudioFiles/Nicol-LoopE-M.wav");
summary:: Extract every N samples / channels from a buffer
categories:: FluidCorpusManipulation
related:: Classes/FluidBufSelect
DESCRIPTION::
Pick every N frames and / or channels from a buffer, described in terms of independent hop sizes for frames and channels
CLASSMETHODS::
private::new1
METHOD:: process, processBlocking
Run the process on the given sever, and perfrom code::action:: when done
ARGUMENT:: server
The link::Classes/Server:: on which to run
ARGUMENT:: source
The link::Classes/Buffer:: to select values from
ARGUMENT:: startFrame
The starting point (in samples) from which to copy in the source buffer.
ARGUMENT:: numFrames
The duration (in samples) to copy from the source buffer. The default (-1) copies the full lenght of the buffer.
ARGUMENT:: startChan
The first channel from which to copy in the source buffer.
ARGUMENT:: numChans
The number of channels from which to copy in the source buffer. This parameter will wrap around the number of channels in the source buffer. The default (-1) copies all of the buffer's channel.
ARGUMENT:: destination
The link::Classes/Buffer:: to write the selected data to
ARGUMENT:: frameHop
Take every `framehop` frames. Default = 1 = all frames (where 2 would be every other frame, etc.)
ARGUMENT:: channelHop
Take every `channelhop` channels. Default = 1 = all channels (where 2 would be every other channel, etc.)
ARGUMENT:: freeWhenDone
Free the server instance when processing complete. Default true
ARGUMENT:: action
Runs when processing is complete
EXAMPLES::
code::
EXAMPLES::
Didactic
code::
//send a known collection where the value of each frame in each channel is encoded
//chan
b = Buffer.sendCollection(s,30.collect{|x| x.mod(6) + (x.div(6) * 0.1)},6)
//check the ranges (thus showing a plotter error...)
b.plot(separately: true).plotMode_(\points)
//you can also check the collection itself if in doubt
The inner FFT/IFFT size. It should be at least 4 samples long, at least the size of the window, and a power of 2. Making it larger allows an oversampling of the spectral precision. The -1 default value will use the next power of 2 equal or above the windowSize.
The inner FFT/IFFT size. It should be at least 4 samples long, at least the size of the window, and a power of 2. Making it larger allows an oversampling of the spectral precision. The -1 default value will use the next power of 2 equal or above the windowSize.
ARGUMENT:: padding
Controls the zero-padding added to either end of the source buffer or segment. Possible values are 0 (no padding), 1 (default, half the window size), or 2 (window size - hop size). Padding ensures that all input samples are completely analysed: with no padding, the first analysis window starts at time 0, and the samples at either end will be tapered by the STFT windowing function. Mode 1 has the effect of centering the first sample in the analysis window and ensuring that the very start and end of the segment are accounted for in the analysis. Mode 2 can be useful when the overlap factor (window size / hop size) is greater than 2, to ensure that the input samples at either end of the segment are covered by the same number of analysis frames as the rest of the analysed material.
ARGUMENT:: freeWhenDone
ARGUMENT:: freeWhenDone
Free the server instance when processing complete. Default true
Free the server instance when processing complete. Default true
ARGUMENT:: action
ARGUMENT:: action
A Function to be evaluated once the offline process has finished and all Buffer's instance variables have been updated on the client side. The function will be passed [features] as an argument.
A Function to be evaluated once the offline process has finished and all Buffer's instance variables have been updated on the client side. The function will be passed [features] as an argument.
"% % %\n".postf((start/512).asInteger,((end-start)/512).asInteger + 3, array[12]);//adding some of the overlap but not more to not capture too much of the next attack
}
nb = nb - 1;
).wait;
if (nb == 1, {"Done".postln;});//check if we've done all the pairs
});
})
"Done".postln;
}).wait;
});
}).play;
}).play;
)
)
//obtain the order of indices that would sort the stats
//play in loop the slice in order of pitch direction (the median of the slice's pitch variation) - mouse on the left should be descending, in the middle should be more stable, and it should be ascending on the right.
h = g.order;
//play in loop the slice in order of pitch direction (the median of the slice's pitch variation)
@ -41,10 +41,52 @@ Retrieve a point from the data set into a link::Classes/Buffer::. Will report an
METHOD:: deletePoint
METHOD:: deletePoint
Remove a point from the data set. Will report an error if the label doesn't exist.
Remove a point from the data set. Will report an error if the label doesn't exist.
METHOD:: setPoint
Set the point: if the label exists, this method behaves like updatePoint; if the label doesn't exist, behaves like addPoint.
METHOD:: clear
METHOD:: clear
Empty the data set.
Empty the data set.
METHOD:: toBuffer
Dump the content of the dataset to a link::Classes/Buffer::, with optional transposition, and a map of frames/channels to the original IDs as a link::Classes/FluidLabelSet::.
ARGUMENT:: buffer
The buffer to write to. It will be resized.
ARGUMENT:: transpose
If 0, each dataset point becomes a buffer frame, and each dataset dimension becomes a buffer channel. If 1, points become channels, and dimensions become frames.
ARGUMENT:: labelSet
The link::Classes/FluidLabelSet:: in which to dump the point's IDs associated with their reference frame number (or channel number if transposed).
ARGUMENT:: action
A function to run when the dump is done.
METHOD:: fromBuffer
Import to the dataset the content of a link::Classes/Buffer::, with optional transposition, and a map of frames/channels to the original IDs as a link::Classes/FluidLabelSet::.
ARGUMENT:: buffer
The buffer to read from. The dataset will be resized.
ARGUMENT:: transpose
If 0, each buffer frame becomes a dataset point, and each buffer channel becomes a dataset dimension. If 1, channels become points, and frames become dimensions.
ARGUMENT:: labelSet
The link::Classes/FluidLabelSet:: from which to retrieve the point's IDs associated with their reference frame number (or channel number if transposed).
ARGUMENT:: action
A function to run when the import is done.
METHOD:: getIds
Export to the dataset IDs to a link::Classes/FluidLabelSet::.
ARGUMENT:: labelSet
The link::Classes/FluidLabelSet:: to export to. Its content will be replaced.
ARGUMENT:: action
A function to run when the export is done.
METHOD:: merge
METHOD:: merge
Merge sourceDataSet in the current DataSet. It will update the value of points with the same label if overwrite is set to 1. To add columns instead, see the 'transformJoin' method of link::Classes/FluidDataSetQuery::
Merge sourceDataSet in the current DataSet. It will update the value of points with the same label if overwrite is set to 1. To add columns instead, see the 'transformJoin' method of link::Classes/FluidDataSetQuery::
As the content of the dataset has a similar structure to buffers, namely arrays of floats in parallel, it is possible to transfer the content between the two. Careful consideration of the rotation of the buffer, as well as the relation of points to channel numbers, are needed.
A UGen that adds labelled points to a link::Classes/FluidDataSet::
A UGen that adds labelled points to a link::Classes/FluidDataSet:: Internally, this calls code::setPoint::, so IDs that already exist will be overwritten, and new IDs will be added. The actual work is done on the server's command queue, rather than the real-thread.
By default the object generates a numerical index that gets used for the point labels. This index starts counting from link::#offset#labelOffset:: and increments each time the Ugen is retriggered with a zero to non-zero transition. The label is then concatenated with the code::labelPrefix:: symbol, which is fixed at instantiation. In this way, one can make custom, incrementing labels, e.g.
By default the object takes a control input (code::idNumber::) as a numerical index that gets used for the point labels. This index is used to write each time the Ugen is re-triggered with a zero to non-zero transition. The label is then concatenated with the code::idPrefix:: symbol, which is fixed at instantiation. In this way, one can make custom, incrementing labels, e.g.
would add points like code::my_data0, mydata1, mydata2...:: if successively retriggered.
would add points like code::my_data0, mydata1, mydata2...:: if successively retriggered.
Alternatively, for one shot use you may not want a numerical suffix at all. Setting code::indexLabel:: < 0 will bypass this and use only the labelPrefix. As such, any retriggering will result in a complaint from the link::Classes/FluidDataSet:: that the requested label is already present.
Alternatively, for one shot use you may not want a numerical suffix at all. Setting code::idNumber:: to code:: nil:: will bypass this and use only the code::idPrefix:: string.
CLASSMETHODS::
CLASSMETHODS::
@ -26,12 +26,12 @@ The equivalent of calling link::Classes/FluidDataSet#-addPoint::, but within a l
ARGUMENT:: dataset
ARGUMENT:: dataset
An instance of link::Classes/FluidDataSet:: or an instance's name.
An instance of link::Classes/FluidDataSet:: or an instance's name.
ARGUMENT:: labelPrefix
ARGUMENT:: idPrefix
A string or symbol with a prefix for generated labels
A string or symbol with a prefix for generated labels.
ARGUMENT:: labelOffset
ARGUMENT:: idNumber
ANCHOR::offset::
ANCHOR::offset::
An integer with the offset to start labeling from. If the UGen is run in a server-side loop (i.e. repeatedly retriggered), the generated labels will count upwards from this offset. If < 0, then no numerical index will be applied to the generated label (i.e. only the labelPrefix is used).
An integer with the offset to start labeling from. If the UGen is run in a server-side loop (i.e. repeatedly re-triggered), the generated labels will count upwards from this offset. If nil, then no numerical index will be applied to the generated label (i.e. only the labelPrefix is used).
ARGUMENT:: buf
ARGUMENT:: buf
The link::Classes/Buffer:: containing the data point.
The link::Classes/Buffer:: containing the data point.
@ -40,21 +40,110 @@ ARGUMENT:: trig
A kr trigger signal
A kr trigger signal
ARGUMENT:: blocking
If 0 then the job will run in its own thread (not reccomended for this object)
Identify code::k:: clusters in a link::Classes/FluidDataSet::
Identify code::numClusters:: clusters in a link::Classes/FluidDataSet::. It will optimise until no improvement is possible, or up to code::maxIter::, whichever comes first. Subsequent calls will continue training from the stopping point with the same conditions.
ARGUMENT:: dataSet
ARGUMENT:: dataSet
A link::Classes/FluidDataSet:: of data points.
A link::Classes/FluidDataSet:: of data points.
ARGUMENT:: action
ARGUMENT:: action
A function to run when fitting is complete, taking as its argument an array with the number of data points for each cluster.
A function to run when fitting is complete, taking as its argument an array with the number of data points for each cluster.
METHOD:: predict
METHOD:: predict
Given a trained object, return the cluster ID for each data point in a DataSet to a label set.
Given a trained object, return the cluster ID for each data point in a link::Classes/FluidDataSet:: to a link::Classes/FluidLabelSet::.
ARGUMENT:: dataSet
ARGUMENT:: dataSet
a link::Classes/FluidDataSet:: containing the data to predict.
A link::Classes/FluidDataSet:: containing the data to predict.
ARGUMENT:: labelSet
ARGUMENT:: labelSet
a link::Classes/FluidLabelSet:: to retrieve the predicted clusters.
A link::Classes/FluidLabelSet:: to retrieve the predicted clusters.
ARGUMENT:: action
ARGUMENT:: action
A function to run when the server responds.
A function to run when the server responds.
@ -52,19 +52,55 @@ A function to run when the server responds
METHOD:: predictPoint
METHOD:: predictPoint
Given a trained object, return the cluster ID for a data point in a link::Classes/Buffer::
Given a trained object, return the cluster ID for a data point in a link::Classes/Buffer::
ARGUMENT:: buffer
ARGUMENT:: buffer
a link::Classes/Buffer:: containing a data point.
A link::Classes/Buffer:: containing a data point.
ARGUMENT:: action
ARGUMENT:: action
A function to run when the server responds, taking the ID of the cluster as its argument.
A function to run when the server responds, taking the ID of the cluster as its argument.
METHOD:: predict
METHOD:: transform
Report cluster assignments for previously unseen data.
Given a trained object, return for each item of a provided link::Classes/FluidDataSet:: its distance to each cluster as an array, often reffered to as the cluster-distance space.
ARGUMENT:: srcDataSet
A link::Classes/FluidDataSet:: of data points to transform.
ARGUMENT:: dstDataSet
A link::Classes/FluidDataSet:: to contain the new cluster-distance space.
ARGUMENT:: action
A function to run when complete.
METHOD:: fitTransform
Run link::Classes/FluidKMeans#*fit:: and link::Classes/FluidKMeans#*transform:: in a single pass: i.e. train the model on the incoming link::Classes/FluidDataSet:: and then return its cluster-distance space in the destination link::Classes/FluidDataSet::
ARGUMENT:: srcDataSet
A link::Classes/FluidDataSet:: containing the data to fit and transform.
ARGUMENT:: dstDataSet
A link::Classes/FluidDataSet:: to contain the new cluster-distance space.
ARGUMENT:: action
A function to run when complete.
METHOD:: transformPoint
Given a trained object, return the distance of the provided point to each cluster. Both points are handled as link::Classes/Buffer::
ARGUMENT:: sourceBuffer
A link::Classes/Buffer:: containing a data point to query.
ARGUMENT:: targetBuffer
A link::Classes/Buffer:: containing a the distance of the source point to each cluster.
ARGUMENT:: action
A function to run when complete.
METHOD:: getMeans
Given a trained object, retrieve the means (centroids) of each cluster as a link::Classes/FluidDataSet::
ARGUMENT:: dataSet
ARGUMENT:: dataSet
A link::Classes/FluidDataSet:: of data points.
A link::Classes/FluidDataSet:: of clusers with a mean per column.
ARGUMENT:: labelSet
A link::Classes/FluidLabelSet:: to contain assignments.
ARGUMENT:: action
ARGUMENT:: action
A function to run when complete, taking an array of the counts for each category as its argument.
A function to run when complete.
METHOD:: setMeans
Overwrites the means (centroids) of each cluster, and declare the object trained.
ARGUMENT:: dataSet
A link::Classes/FluidDataSet:: of clusers with a mean per column.
ARGUMENT:: action
A function to run when complete.
METHOD:: clear
Reset the object status to not fitted and untrained.
ARGUMENT:: action
A function to run when complete.
EXAMPLES::
EXAMPLES::
code::
code::
@ -147,6 +183,47 @@ w.front;
~kmeans.predictPoint(~inbuf,{|x|x.postln;});
~kmeans.predictPoint(~inbuf,{|x|x.postln;});
::
::
subsection:: Accessing the means
We can get and set the means for each cluster, their centroid.
code::
// with the dataset and kmeans generated and trained in the code above
~centroids = FluidDataSet(s);
~kmeans.getMeans(~centroids, {~centroids.print});
// We can also set them to arbitrary values to seed the process
//subtle in this case but still.. each quadrant is where we seeded it.
::
subsection:: Cluster-distance Space
We can get the euclidian distance of a given point to each cluster. This is often referred to as the cluster-distance space as it creates new dimensions for each given point, one distance per cluster.
code::
// with the dataset and kmeans generated and trained in the code above
b = Buffer.sendCollection(s,[0.5,0.5])
c = Buffer(s)
// get the distance of our given point (b) to each cluster, thus giving us 4 dimensions in our cluster-distance space