Polytransform: Difference between revisions

From Eigenvector Research Documentation Wiki
Jump to navigation Jump to search
imported>Donal
imported>Jeremy
 
(9 intermediate revisions by one other user not shown)
Line 5: Line 5:
===Synopsis===
===Synopsis===


:[DSOout, model] = polytransform(x, options);
:[xout, model] = polytransform(x, options);
:xout = polytransform(x, model);


===Description===
===Description===
Line 13: Line 14:
preprocessingtype option specifies the type of preprocessing to apply,  'none', 'mncn', 'auto', or 'custom'. If 'custom' is specified then the  'preprocessing' option must be a valid preprocessing structure.  If pca = 'on' the data are converted to PCA scores after preprocessing,  but before the transformed variables are calculated.
preprocessingtype option specifies the type of preprocessing to apply,  'none', 'mncn', 'auto', or 'custom'. If 'custom' is specified then the  'preprocessing' option must be a valid preprocessing structure.  If pca = 'on' the data are converted to PCA scores after preprocessing,  but before the transformed variables are calculated.


====Inputs====
===Inputs===


* '''x''' =  Dataset or matrix to be augmented by the addition of transformed variables.
* '''x''' =  Dataset or matrix to be augmented by the addition of transformed variables.
===Outputs===
* '''xout''' =  The augmented dataset or matrix.
* '''model''' =  A standard model structure with ''modeltype = polytransform''. This model can be used to augment new data in the same way as the original data was augmented, using the same options, including preprocessing.


===Options===
===Options===


'''''options''''' is a structure array with the following fields:
'''''options''''' is a structure array with the following fields:
* '''display''': [ {'on'} | 'off' ], governs level of display,
* '''squares''': [ 'on' | {'off'} ], governs level of display,
* '''plots''': ['none' | 'final' | {'auto'} |], governs plotting behavior
* '''cubes''': [ 'on' | {'off'} ], governs level of display,
** 'auto' makes plots if no output is requested {default}
* '''quadratics''': [ 'on' | {'off'} ], governs level of display,
* '''cost'''''':''' [], vector of logarithmic cost biases for each class in y, cost is used to bias against misclassification of a particular class or classes {default = [] uses all zeros i.e. equal cost}.
* '''crossterms''': [ 'on' | {'off'} ], governs level of display,
* '''prior'''''':''' [], vector of prior probabilities of observing each class. If any class prior is Inf, the frequency of observation of that class in the calibration is used as its prior probability. If all priors are Inf, this has the effect of providing the fewest incorrect predictions assuming that the probability of observing a given class in future samples is similar to the frequency that class in the calibration set. {default = [] uses all ones i.e. equal priors.}
* '''preprocessingtype''': ['none' | 'mncn' | {'auto'} | 'pcrtile' | 'custom'], governs data preprocessing behavior. Note that autoscaling is the default preprocessing.
* '''preprocessing''': A preprocessing structure which is used if ''preprocessingtype = custom'',
* '''pca''': [ 'on' | {'off'} ], governs whether PCA is applied to the preprocessed data before transformed terms are calculated,
* '''maxpcs''': Integer indicating how many PCs to use if ''pca = on'',
* '''preprocessoriginalvars''': [ 0| {1} ], governs whether the original variables are returned preprocessed or raw.


===Examples===
===Examples===


If y is a 5 by 100 matrix, x is a 1 by 100 vector, and xi is a 1 by 91 vector then:
If x is a 10 by 4 matrix or dataset and options are default, except for the squares option:
<pre>polyinterp(x,y,xi,11,3,1)</pre>  
<pre>
gives the 5 by 91 matrix of first-derivative row vectors resulting from an 11-point cubic interpolation to the 91 points in xi.
m = 10; n = 4;
x = rand(m,n);
popts = polytransform('options');
popts.squares = 'on';
[xout, model] = polytransform(x,popts);
</pre>  
returns the 10 by 8 dataset ''xout'' where the columns 5 to 8 are the squares of the first four columns.
So, xout.data(:,1:4).^2 equals xout.data(:,5:8).
Note that xout.data(:,1:4) is the preprocessed form of the input x.


===See Also===
===See Also===

Latest revision as of 14:50, 22 February 2013

Purpose

Add new variables to a dataset object or matrix formed as power transforms and cross terms of the original variables.

Synopsis

[xout, model] = polytransform(x, options);
xout = polytransform(x, model);

Description

Add polynomial and cross terms to data matrix or dataset. Input dataset x has new transformed variables added. These can include existing variables raised to second, third, fourth power, or second order product of variables. The data can be preprocessed before transformed variables are calculated. preprocessingtype option specifies the type of preprocessing to apply, 'none', 'mncn', 'auto', or 'custom'. If 'custom' is specified then the 'preprocessing' option must be a valid preprocessing structure. If pca = 'on' the data are converted to PCA scores after preprocessing, but before the transformed variables are calculated.

Inputs

  • x = Dataset or matrix to be augmented by the addition of transformed variables.

Outputs

  • xout = The augmented dataset or matrix.
  • model = A standard model structure with modeltype = polytransform. This model can be used to augment new data in the same way as the original data was augmented, using the same options, including preprocessing.

Options

options is a structure array with the following fields:

  • squares: [ 'on' | {'off'} ], governs level of display,
  • cubes: [ 'on' | {'off'} ], governs level of display,
  • quadratics: [ 'on' | {'off'} ], governs level of display,
  • crossterms: [ 'on' | {'off'} ], governs level of display,
  • preprocessingtype: ['none' | 'mncn' | {'auto'} | 'pcrtile' | 'custom'], governs data preprocessing behavior. Note that autoscaling is the default preprocessing.
  • preprocessing: A preprocessing structure which is used if preprocessingtype = custom,
  • pca: [ 'on' | {'off'} ], governs whether PCA is applied to the preprocessed data before transformed terms are calculated,
  • maxpcs: Integer indicating how many PCs to use if pca = on,
  • preprocessoriginalvars: [ 0| {1} ], governs whether the original variables are returned preprocessed or raw.

Examples

If x is a 10 by 4 matrix or dataset and options are default, except for the squares option:

m = 10; n = 4;
x = rand(m,n);
popts = polytransform('options');
popts.squares = 'on';
[xout, model] = polytransform(x,popts);

returns the 10 by 8 dataset xout where the columns 5 to 8 are the squares of the first four columns. So, xout.data(:,1:4).^2 equals xout.data(:,5:8). Note that xout.data(:,1:4) is the preprocessed form of the input x.

See Also