the class Multidimensionalscaling is used to perform multidimensional scaling (capable of landmark approximation if requested).
Description of classical embedding is given on p.261 (Section 12.1) of Borg, I., & Groenen, P. J. F. (2005). Modern multidimensional scaling: Theory and applications. Springer.
Description of landmark MDS approximation is given in
Sparse multidimensional scaling using landmark points V De Silva, J B Tenenbaum (2004) Technology, p. 1-4
In this preprocessor the LAPACK routine DSYEVR is used for solving an eigenproblem. If ARPACK library is available, its routines DSAUPD/DSEUPD are used instead.
Note that target dimension should be set with reasonable value (using set_target_dim). In case it is higher than intrinsic dimensionality of the dataset 'extra' features of the output might be inconsistent (essentially, according to zero or negative eigenvalues). In this case a warning is showed.
It is possible to apply multidimensional scaling to any given distance using apply_to_distance_matrix method. By default euclidean distance is used (with parallel instance replaced by preprocessor's one).
Faster landmark approximation is parallel using pthreads. As for choice of landmark number it should be at least 3 for proper triangulation. For reasonable embedding accuracy greater values (30-50% of total examples number) is pretty good for the most tasks.
Definition at line 59 of file MultidimensionalScaling.h.
Public Member Functions | |
CMultidimensionalScaling () | |
virtual | ~CMultidimensionalScaling () |
virtual CSimpleFeatures < float64_t > * | embed_distance (CDistance *distance) |
virtual CFeatures * | apply (CFeatures *features) |
const char * | get_name () const |
SGVector< float64_t > | get_eigenvalues () const |
void | set_landmark_number (int32_t num) |
int32_t | get_landmark_number () const |
void | set_landmark (bool landmark) |
bool | get_landmark () const |
Protected Member Functions | |
virtual void | init () |
HELPERS. | |
SGMatrix< float64_t > | classic_embedding (SGMatrix< float64_t > distance_matrix) |
SGMatrix< float64_t > | landmark_embedding (SGMatrix< float64_t > distance_matrix) |
virtual SGMatrix< float64_t > | process_distance_matrix (SGMatrix< float64_t > distance_matrix) |
Static Protected Member Functions | |
static void * | run_triangulation_thread (void *p) |
STATIC. | |
static SGVector< int32_t > | shuffle (int32_t count, int32_t total_count) |
Protected Attributes | |
SGVector< float64_t > | m_eigenvalues |
FIELDS. | |
bool | m_landmark |
int32_t | m_landmark_number |
Definition at line 60 of file MultidimensionalScaling.cpp.
~CMultidimensionalScaling | ( | ) | [virtual] |
Definition at line 76 of file MultidimensionalScaling.cpp.
apply preprocessor to feature matrix, changes feature matrix to the one having target dimensionality
features | features which feature matrix should be processed |
Implements CEmbeddingConverter.
Definition at line 136 of file MultidimensionalScaling.cpp.
classical embedding
distance_matrix | distance matrix to be used for embedding |
Definition at line 149 of file MultidimensionalScaling.cpp.
CSimpleFeatures< float64_t > * embed_distance | ( | CDistance * | distance | ) | [virtual] |
apply preprocessor to CDistance
distance | (should be approximate euclidean for consistent result) |
Definition at line 114 of file MultidimensionalScaling.cpp.
get last embedding eigenvectors
Definition at line 81 of file MultidimensionalScaling.cpp.
bool get_landmark | ( | ) | const |
getter for landmark parameter
Definition at line 104 of file MultidimensionalScaling.cpp.
int32_t get_landmark_number | ( | ) | const |
get number of landmarks
Definition at line 94 of file MultidimensionalScaling.cpp.
const char * get_name | ( | ) | const [virtual] |
get name
Reimplemented from CEmbeddingConverter.
Reimplemented in CIsomap.
Definition at line 109 of file MultidimensionalScaling.cpp.
void init | ( | ) | [protected, virtual] |
HELPERS.
default initialization
Reimplemented from CEmbeddingConverter.
Reimplemented in CIsomap.
Definition at line 69 of file MultidimensionalScaling.cpp.
landmark embedding (approximate, accuracy varies with m_landmark_num parameter)
distance_matrix | distance matrix to be used for embedding |
Definition at line 270 of file MultidimensionalScaling.cpp.
SGMatrix< float64_t > process_distance_matrix | ( | SGMatrix< float64_t > | distance_matrix | ) | [protected, virtual] |
process distance matrix (redefined in isomap, for mds does nothing)
distance_matrix | distance matrix |
Reimplemented in CIsomap.
Definition at line 131 of file MultidimensionalScaling.cpp.
void * run_triangulation_thread | ( | void * | p | ) | [static, protected] |
STATIC.
run triangulation thread for landmark embedding
p | thread parameters |
Definition at line 406 of file MultidimensionalScaling.cpp.
void set_landmark | ( | bool | landmark | ) |
setter for landmark parameter
landmark | true if landmark embedding should be used |
Definition at line 99 of file MultidimensionalScaling.cpp.
void set_landmark_number | ( | int32_t | num | ) |
set number of landmarks should be lesser than number of examples and greater than 3 for consistent embedding as triangulation is used
num | number of landmark to be set |
Definition at line 86 of file MultidimensionalScaling.cpp.
SGVector< int32_t > shuffle | ( | int32_t | count, | |
int32_t | total_count | |||
) | [static, protected] |
subroutine used to shuffle count indexes among of total_count ones with Fisher-Yates (known as Knuth too) shuffle algorithm
count | number of indexes to be shuffled and returned | |
total_count | total number of indexes |
Definition at line 448 of file MultidimensionalScaling.cpp.
SGVector<float64_t> m_eigenvalues [protected] |
bool m_landmark [protected] |
use landmark approximation?
Definition at line 143 of file MultidimensionalScaling.h.
int32_t m_landmark_number [protected] |
number of landmarks
Definition at line 146 of file MultidimensionalScaling.h.