FluidManipulation data classes help files, pass 0

nix
Owen Green 6 years ago
parent f61c7db147
commit 0af28a18ba

@ -0,0 +1,141 @@
TITLE:: FluidDataSet
summary:: Container for labelled, multidimensional data
categories:: UGens>FluidManipulation
related:: Classes/FluidLabelSet, Classes/FluidKDTree, Classes/FluidKNN, Classes/FluidKMeans
DESCRIPTION::
A server-side container associating labels with multi-dimensional data. FluidDataSet is identified by its name, and multiple instances of the object with the same name point to the same instance on the server.
CLASSMETHODS::
PRIVATE::kr
METHOD:: new
Create a new instance of the dataset, with the given name and dimensionality. If an instance already exists on the server, then the existing dimensionality takes precedence.
ARGUMENT:: server
The link::Classes/Server:: on which to create the data set
ARGUMENT:: name
A symbol or string with the name of the dataset.
ARGUMENT:: dims
An integer number of dimensions
returns:: The new instance
INSTANCEMETHODS::
PRIVATE::init,id
METHOD:: synth
The internal synth the object uses to communicate with the server
returns:: A link::Classes/Synth::
METHOD:: server
The server instance the object uses
returns:: A link::Classes/Server::
METHOD:: updatePoint
Update an existing label's data. Will report an error if the label doesn't exist, or if the size of the data does not match the given dimensionality of the dataset.
ARGUMENT:: label
symbol or string with the label
ARGUMENT:: buffer
A link::Classes/Buffer:: containing the updated data
ARGUMENT:: action
A function to run when the server has updated
METHOD:: size
Report the number of items currently in the data set
ARGUMENT:: action
A function to run when the server responds, whose argument is the data set size
METHOD:: addPoint
Add a new point to the data set. Will report an error if the label already exists, or if the size of the data does not match the given dimensionality of the dataset.
ARGUMENT:: label
A symbol or string with the label for the new point
ARGUMENT:: buffer
A link::Classes/Buffer:: with the new data point
ARGUMENT:: action
A function to run when the point has been added
METHOD:: write
Write the data set to disk as a JSON file. Will not overwrite existing files
ARGUMENT:: filename
Absolute path for the new file
ARGUMENT:: action
A function to run when the file has been written
METHOD:: asString
returns:: The name of the data set as a string
METHOD:: deletePoint
Remove a point from the data set. Will report an error if the label doesn't exist.
ARGUMENT:: label
symbol or string with the label to remove
ARGUMENT:: action
Function to run when the point has been deleted
METHOD:: clear
Empty the data set
ARGUMENT:: action
Function to run when the data set has been emptied
METHOD:: getPoint
Retreive a point from the data set into a link::Classes/Buffer::. Will report an error if the label or buffer doesn't exist
ARGUMENT:: label
symbol or string with the label to retreive
ARGUMENT:: buffer
link::Classes/Buffer:: to fill
ARGUMENT:: action
function to run when the point has been retreived
METHOD:: read
Read a data set from a JSON file on disk
ARGUMENT:: filename
The absolute path of the JSON file to read
ARGUMENT:: action
A function to run when the file has been read
METHOD:: cols
Report the dimensionality of the data set
EXAMPLES::
CODE::
// Make a one-dimensional data set called 'simple1data'
~ds = FluidDataSet.new(s,\simple1data,1)
// Make a buffer to use for adding points
~point = Buffer.alloc(s,1,1)
//Add 10 points, using the index as a label.
(
Routine{
10.do{|i|
~point.set(0,i);
s.sync;
~ds.addPoint(i.asString,~point,{("addPoint"+i).postln})
}
}.play
)
::

@ -0,0 +1,78 @@
TITLE:: FluidKDTree
summary:: KD Tree on the server
categories:: FluidManipulation
related:: Classes/FluidDataSet
DESCRIPTION::
A server-side K-Dimensional tree for efficient neighbourhood searches of multi-dimensional data. See https://scikit-learn.org/stable/modules/neighbors.html#nearest-neighbor-algorithms for more on KD Trees
CLASSMETHODS::
INSTANCEMETHODS::
METHOD:: read
Set the object's state from a JSON file
ARGUMENT:: filename
The location of a JSON file on disk
ARGUMENT:: action
function to run when the data is loaded
METHOD:: kNearestDist
Get the distances of the K nearest neighbours to a point
ARGUMENT:: buffer
A LINK::Classes/Buffer:: containing a data point to match against. The number of frames in the buffer must match the dimensionality of the LINK::Classes/FluidDataSet:: the tree was fitted to.
ARGUMENT:: k
The number of neighbours to search
ARGUMENT:: action
A function that will run when the query returns, whose argument is an array of distances
returns:: nothing, but could return an array if you like
METHOD:: fit
Build the tree by scanning the points of a LINK::Classes/FluidDataSet::
ARGUMENT:: dataset
The LINK::Classes/FluidDataSet:: of interest. This can either be a data set object itself, or the name of one.
ARGUMENT:: action
A function to run when indexing is complete
METHOD:: write
Write the index of the tree to disk. Currently this will not overwrite extant files.
ARGUMENT:: filename
The path of a JSON file to write
ARGUMENT:: action
A function to run when writing is complete
METHOD:: kNearest
Returns the IDs of the CODE::k:: points nearest to the one passed
ARGUMENT:: buffer
A LINK::Classes/Buffer:: containing a data point to match against. The number of frames in the buffer must match the dimensionality of the LINK::Classes/FluidDataSet:: the tree was fitted to.
ARGUMENT:: k
The number of neighbours to return
ARGUMENT:: action
A function that will run when the query returns, whose argument is an array of point IDs from the tree's LINK::Classes/FluidDataSet::
returns:: Nothing, but could return an array of IDs if you like
METHOD:: cols
Get the dimensionality of the data that the tree is indexed against
ARGUMENT:: action
A function that runs when the query returns, whose argument is the dimensionality
EXAMPLES::
code::
(some example code)
::

@ -0,0 +1,68 @@
TITLE:: FluidKNN
summary:: K Nearest Neighbours machine learning
categories:: FluidManipulation
related:: Classes/FluidKDTree
DESCRIPTION::
Simple machine learning tasks (classification and regression) using K Nearest Neighbours.
See
https://scikit-learn.org/stable/modules/neighbors.html#nearest-neighbors-classification
https://scikit-learn.org/stable/modules/neighbors.html#nearest-neighbors-regression
CLASSMETHODS::
INSTANCEMETHODS::
METHOD:: fit
'Train' the KNN on a source link::Classes/FluidDataSet::
ARGUMENT:: dataset
source link::Classes/FluidDataSet::
ARGUMENT:: action
A function to run when fitting is complete
METHOD:: regress
Map a point between a source link::Classes/FluidDataSet:: used when link::Classes/FluidKNN#index::ing this KNN, and a target data set passed as an argument.
For this to work, the target data set must have labels in common with the source data set. The code::k:: nearest neighbours to the supplied data point are retrrived from the source tree, and then a mapping is obtained through the average of the equivalently labelled points in the target data set.
WARNING:: For now the target data set can only be 1D::
ARGUMENT:: buffer
The data point to map, in a link::Classes/Buffer::
ARGUMENT:: dataset
The target link::Classes/FluidDataSet::
ARGUMENT:: k
The number of neighbours to use in the estimation
ARGUMENT:: action
A function to run when the server responds, taking the value of the regressed point as its argument
METHOD:: classify
Classify a point, using categories from the supplied label set, which maps labels from the source data set to category IDs. This works by getting the labels of the code::k:: nearest points to the passed data point from the source data set, and looking up their IDs in the passed label set. The most frequently ocurring ID is designated as the class for the point.
ARGUMENT:: buffer
The data point to classify, in a link::Classes/Buffer::
ARGUMENT:: labelset
A link::Classes/FluidLabelSet:: of categories mapped to labels in source data set
ARGUMENT:: k
The number of neighbours to use in the classificaton
ARGUMENT:: action
A function to run when the server responds, taking the assigned label as its argument
EXAMPLES::
code::
(some example code)
::

@ -0,0 +1,97 @@
TITLE:: FluidLabelSet
summary:: A set of labels associated with IDs
categories:: FluidManipulation
related:: Classes/FluidDataSet, Classes/FluidKMeans
DESCRIPTION::
FluidLabelSet is a server-side container of associations between labels (from a link::Classes/FluidDataSet::) and IDs, for instance from some clustering or classification of the points in a data set.
CLASSMETHODS::
PRIVATE:: kr
METHOD:: new
Make a new instance of a label set, uniquely identified by its name. Multiple instances to of this class with the same name refer to the same server-side entity.
ARGUMENT:: server
The link::Classes/Server:: on which to create the label set
ARGUMENT:: name
symbol or string with the label set's name
INSTANCEMETHODS::
PRIVATE:: init, id, server, synth
METHOD:: getLabel
Retreive the label associated with an ID. Will report an error if the ID isn't present in the set
ARGUMENT:: id
symbol or string with the ID to retreive.
ARGUMENT:: action
A function to run when the server responds, with the label as its argument
METHOD:: cols
Returns the dimensionality of the link::Classes/FluidDataSet:: associated with this label set
ARGUMENT:: action
A function to run when the server responds, with the dimensionality as its argument
METHOD:: write
Write this label set to disk as a JSON file. Will not overwrite existing files.
ARGUMENT:: filename
Absolute path of file to write
ARGUMENT:: action
A function to run when the file is written
METHOD:: read
Read a label set from a JSON file on disk
ARGUMENT:: filename
Absolute path of the file to read
ARGUMENT:: action
A function to run when the file is read
METHOD:: deleteLabel
Remove a id-label pair from the label set
ARGUMENT:: id
symbol or string with the ID to remove
ARGUMENT:: action
A function to run when the label has been removed
METHOD:: size
Report the num er of items in the label set
ARGUMENT:: action
A function to run when the server responds, taking the size as its argument
METHOD:: addLabel
Add a label to the label set
ARGUMENT:: id
symbol or string with the ID for this label
ARGUMENT:: label
symbol or string with the label to add
ARGUMENT:: action
function to run when the operation completes
METHOD:: clear
Empty the label set
ARGUMENT:: action
Function to run whrn the action completes
EXAMPLES::
code::
(some example code)
::
Loading…
Cancel
Save