JavaScript Predictor Object and Manhattandist: Difference between pages

From Eigenvector Research Documentation Wiki
(Difference between pages)
Jump to navigation Jump to search
imported>Jeremy
 
imported>Benjamin
No edit summary
 
Line 1: Line 1:
== Introduction ==
===Purpose===
Calculates Manhattan Distance between Samples (rows) of a Dataset Object (DSO) or a matrix.


The JavaScript Predictor Object is freely available to developers who wish to create JavaScript applications that interface with Solo_Predictor as does the [[Solo Predictor Field Monitor]].
===Synopsis===


The object provides basic methods to get a list of available models (from a specific folder on the server), then apply those models to data stored in a [[DataCache object]] in Solo_Predictor. Finally, it also provides access to raw data, and Q or Hotelling's T-squared contributions (if the underlying model type provides contributions).
:distances = manhattandist(x)
:distances = manhattandist(x,basis)
:distances = manhattandist(x,options)
:distances = manhattandist(x,basis,options)


== Available Models ==
===Description===


These properties and methods relate to the models that are available to Solo_Predictor and which of those should be applied to data when it is imported.
Calculates the Manhattan Distance, sum of the absolute value differences, from each row to every other row in the supplied matrix or, optionally, all rows of (x) to all rows in a second matrix (basis).


=== Properties ===
====Inputs====


{| border="1" cellspacing="0" cellpadding="5" style="margin-left:3em"
* '''x''' = A DSO or a matrix.
|-
|        <tt>.modelFolder</tt>      || Sets or retrieves the folder (on the server, that is the computer running Solo_Predictor) which should be searched for models to apply. When updated, the <tt>modelList</tt> property (see below) is automatically updated.
|-
|        <tt>.modelList</tt>      || '''[READ ONLY]''' An array of strings which define all valid files located in the modelFolder on the server. The contents of this list will be automatically updated when the <tt>modelFolder</tt> property is updated or when the <tt>updateModelList</tt> method is called.
|-
|        <tt>.modelListError</tt>      || '''[READ ONLY]''' The error (if any) returned after the last <tt>updateModelList</tt> call. If no error occurred, this property will be empty.
|-
|        <tt>.updateModelListCallback</tt>      || A function that should be executed when <tt>updateModelList</tt> is executed. The function should expect a single input consisting of the Predictor object itself. For example:[BR]
      obj.updateModelListCallback = function (myobj) {
        if (myobj.modelListError) throw new Error(myobj.modelListError);
        //Do something with myobj.modelList here...
      }
|}


=== Methods ===
====Optional Inputs====


* '''basis''' = A second DSO/matrix to compare the first DSO/matrix against when calculating Manhattan distance.
* '''options''' = Discussed below.


{| border="1" cellspacing="0" cellpadding="5" style="margin-left:3em"
====Outputs====
|-
|        <tt>.updateModelList</tt>      || Contacts the server and requests the current list of models (.MAT and .TXT files) in the specified <tt>modelFolder</tt>. When the server responds, the results are stored in the <tt>modelList</tt> and <tt>modelListError</tt> properties and finally a call is made to the function specified in <tt>updateModelListCallback</tt>. If any errors occurred, the modelList will be empty.
|}


* '''distances''' = A m-by-m matrix containing the comprehensive calculated Manhattan distances between samples.


== Applying Models to Data ==
====Options====


The following properties and methods relate to applying models to data and retrieving those results. They all relate to the singular method <tt>applyModels</tt>.
options = A structure array with the following fields:


=== Properties ===
* '''waitbar''': [{'auto'}| 'on' | 'off' ], display waitbar. 'Auto' setting will automatically display a waitbar if computation takes longer than 3 seconds.
* '''diag''': {default: 0} Defines the values to be used when comparing a sample to itself. Technically this distance is zero however in some instances, using an alternate value (e.g.: inf) is useful for flagging these self-calculated distances.


These properties control the behavior of the <tt>applyModels</tt> method:
===See Also===
 
{| border="1" cellspacing="0" cellpadding="5" style="margin-left:3em"
|-
|        <tt>.selectedModels</tt>      || An array of strings which indicate the names of models which should be applied. The model names can be taken from the <tt>modelList</tt> property defined above. If this array is empty, no models will be applied. If more than one model is listed, all models will be applied and Solo_Predictor will attempt to join all the results into a single results matrix. Changing the <tt>selectedModels</tt> list will generally cause the most recent results to be cleared.
|-
|        <tt>.datacacheblock</tt>      || Identifies which [[DataCache object]] block should be connected to the predictor as the source of data to which the models should be applied. Generally, this will be always be = 1, but some advanced applications might make use of additional DataCache blocks.
|-
|        <tt>.applyModelsCallback</tt>      || Provides a function that will be executed once the <tt>applyModels</tt> call has been completed. The supplied function should expect a single input consisting of the Predictor object itself.
|}
 
These properties are read-only and provide results from the most recent completed <tt>applyModels</tt> call:
 
 
{| border="1" cellspacing="0" cellpadding="5" style="margin-left:3em"
|-
|        <tt>.data</tt>      || '''[READ ONLY]''' The DataSet object-encoded contents that define the results of applying the model(s) to the specified data cache.
|-
|        <tt>.lastApplyUpdate</tt>      || '''[READ ONLY]''' The JavaScript timestamp of when the last call to <tt>applyModels</tt> was completed.
|-
|        <tt>.lastApplyError</tt>      || '''[READ ONLY]''' The text of any errors that occurred during the last call to <tt>applyModels</tt>. If no errors occurred in the last call, this property will be an empty string. Errors may be server-related errors (can not communicate) or model errors (e.g. data size does not match that expected by model)
|}
 
=== Methods ===
 
{| border="1" cellspacing="0" cellpadding="5" style="margin-left:3em"
|-
|        <tt>.applyModels</tt>      || Checks the server for new data in the indicated DataCache and applies any models listed in <tt>selectedModels</tt> to the data. When model application is done, the <tt>data</tt>, <tt>lastApplyUpdate</tt>, and <tt>lastApplyError</tt>.
|}

Revision as of 13:16, 15 August 2017

Purpose

Calculates Manhattan Distance between Samples (rows) of a Dataset Object (DSO) or a matrix.

Synopsis

distances = manhattandist(x)
distances = manhattandist(x,basis)
distances = manhattandist(x,options)
distances = manhattandist(x,basis,options)

Description

Calculates the Manhattan Distance, sum of the absolute value differences, from each row to every other row in the supplied matrix or, optionally, all rows of (x) to all rows in a second matrix (basis).

Inputs

  • x = A DSO or a matrix.

Optional Inputs

  • basis = A second DSO/matrix to compare the first DSO/matrix against when calculating Manhattan distance.
  • options = Discussed below.

Outputs

  • distances = A m-by-m matrix containing the comprehensive calculated Manhattan distances between samples.

Options

options = A structure array with the following fields:

  • waitbar: [{'auto'}| 'on' | 'off' ], display waitbar. 'Auto' setting will automatically display a waitbar if computation takes longer than 3 seconds.
  • diag: {default: 0} Defines the values to be used when comparing a sample to itself. Technically this distance is zero however in some instances, using an alternate value (e.g.: inf) is useful for flagging these self-calculated distances.

See Also