Class2logical: Difference between revisions

From Eigenvector Research Documentation Wiki
Jump to navigation Jump to search
imported>Jeremy
(Importing text file)
imported>Neal
No edit summary
Line 1: Line 1:
===Purpose===
===Purpose===


Line 6: Line 5:
===Synopsis===
===Synopsis===


:[y,nonzero] = class2logical(class,groups)
:[y,nonzero] = class2logical(class,''groups'')


===Description===
===Description===


Given a list of sample classes or a DataSet object with class assignments for samples (mode 1), CLASS2LOGICAL creates a logical array in which each column of y contains the logical class membership (i.e. 1 or 0) for each class. This logical block can be used as the input y in PLS or PCR to perform discriminate analysis. Similarly, the output can be used with crossval to perform PLSDA cross-validation. Classes can optionally be grouped together by providing class groupings.
Given a list of sample classes or a DataSet object with class assignments for samples (mode 1), CLASS2LOGICAL creates a logical array in which each column of (y) contains the logical class membership (i.e. 1 or 0) for each class. This logical block can be used as the input (y) in PLS or PCR to perform discriminate analysis. Similarly, the output can be used with CROSSVAL to perform PLSDA cross-validation. Classes can optionally be grouped together by providing class groupings.


Inputs are class a list of class assignments, or a dataset with classes for first mode, and groups an optional input containing either:
The input (class) is a list of class assignments for each sample/row, or a dataset with classes for first mode.
* [1 2 3 ...] a vector of classes to model OR
Optional input (groups) contains either:
* {[1 2] [3 4] ...} a cell array containing groups of classes to consider as one class. Each cell element will be one class (see e.g. below)
:[1 2 3 ...] a vector of classes to model OR
:{[1 2] [3 4] ...} a cell array containing groups of classes to consider as one class. Each cell element will be one class (e.g., see below)


Any classes in class which are not listed in groups are considered part of no group and will be assigned zero for all columns in the output.
Any classes in (class) which are not listed in (groups) are considered part of no group and will be assigned zero for all columns in the output.


Outputs are y a logical array in which each column represents one of the classes in the input class list or one of the groups in groups and nonzero the indices of samples with non-zero class assignment.
Outputs are (y) a logical array in which each column represents one of the classes in the input class list or one of the groups in groups and nonzero the indices of samples with non-zero class assignment.


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


(A) Given DataSet "arch" with classes 0-5, the following creates a logical block with two columns consisting of "true" only for class 3 in the first column and "true" only for class 2 in the second column.
Given DataSet "arch" with classes 0-5, the following creates a logical block with two columns consisting of "true" only for class 3 in the first column and "true" only for class 2 in the second column.
 
:y = class2logical(arch,[3 2])


y = class2logical(arch,[3 2])
Given DataSet "arch" with classes 0-5, the following creates a logical block with two columns consisting of "true" only for classes 0 and 1 in the first column and "true" only for classes 2 and 4 in the second column.


(B) Given DataSet "arch" with classes 0-5, the following creates a logical block with two columns consisting of "true" only for classes 0 and 1 in the first column and "true" only for classes 2 and 4 in the second column.
:y = class2logical(arch,{[1 0] [2 4]})


y = class2logical(arch,{[1 0] [2 4]})


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


[[crossval]], [[plsda]], [[plsdthres]]
[[crossval]], [[plsda]], [[plsdthres]]

Revision as of 16:39, 25 September 2008

Purpose

Create a PLSDA logical block from class assignments.

Synopsis

[y,nonzero] = class2logical(class,groups)

Description

Given a list of sample classes or a DataSet object with class assignments for samples (mode 1), CLASS2LOGICAL creates a logical array in which each column of (y) contains the logical class membership (i.e. 1 or 0) for each class. This logical block can be used as the input (y) in PLS or PCR to perform discriminate analysis. Similarly, the output can be used with CROSSVAL to perform PLSDA cross-validation. Classes can optionally be grouped together by providing class groupings.

The input (class) is a list of class assignments for each sample/row, or a dataset with classes for first mode. Optional input (groups) contains either:

[1 2 3 ...] a vector of classes to model OR
{[1 2] [3 4] ...} a cell array containing groups of classes to consider as one class. Each cell element will be one class (e.g., see below)

Any classes in (class) which are not listed in (groups) are considered part of no group and will be assigned zero for all columns in the output.

Outputs are (y) a logical array in which each column represents one of the classes in the input class list or one of the groups in groups and nonzero the indices of samples with non-zero class assignment.

Examples

Given DataSet "arch" with classes 0-5, the following creates a logical block with two columns consisting of "true" only for class 3 in the first column and "true" only for class 2 in the second column.

y = class2logical(arch,[3 2])

Given DataSet "arch" with classes 0-5, the following creates a logical block with two columns consisting of "true" only for classes 0 and 1 in the first column and "true" only for classes 2 and 4 in the second column.

y = class2logical(arch,{[1 0] [2 4]})


See Also

crossval, plsda, plsdthres