37#ifndef VIGRA_UNSUPERVISED_DECOMPOSITION_HXX
38#define VIGRA_UNSUPERVISED_DECOMPOSITION_HXX
41#include "mathutil.hxx"
43#include "singular_value_decomposition.hxx"
118template <
class T,
class C1,
class C2,
class C3>
124 using namespace linalg;
130 "principalComponents(): The number of samples has to be larger than the number of features.");
132 "principalComponents(): The number of features has to be larger or equal to the number of components in which the feature matrix is decomposed.");
134 "principalComponents(): The output matrix fz has to be of dimension numFeatures*numComponents.");
136 "principalComponents(): The output matrix zv has to be of dimension numComponents*numSamples.");
139 singularValueDecomposition(features.transpose(),
U,
S, V);
143 rowVector(
zv,
k) = columnVector(
U,
k).transpose() *
S(
k, 0);
144 columnVector(fz,
k) = columnVector(V,
k);
164 : min_rel_gain(1e-4),
166 normalized_component_weights(
true)
175 vigra_precondition(n >= 1,
176 "PLSAOptions::maximumNumberOfIterations(): number must be a positive integer.");
187 vigra_precondition(g >= 0.0,
188 "PLSAOptions::minimumRelativeGain(): number must be positive or zero.");
202 normalized_component_weights = v;
208 bool normalized_component_weights;
291template <
class U,
class C1,
class C2,
class C3,
class Random>
299 using namespace linalg;
305 "pLSA(): The number of features has to be larger or equal to the number of components in which the feature matrix is decomposed.");
307 "pLSA(): The output matrix fz has to be of dimension numFeatures*numComponents.");
309 "pLSA(): The output matrix zv has to be of dimension numComponents*numSamples.");
315 prepareColumns(fz, fz, UnitSum);
316 prepareColumns(
zv,
zv, UnitSum);
319 double eps = 1.0/NumericTraits<U>::max();
343 prepareColumns(fz, fz, UnitSum);
344 prepareColumns(
zv,
zv, UnitSum);
359 if(!options.normalized_component_weights)
367template <
class U,
class C1,
class C2,
class C3>
369pLSA(MultiArrayView<2, U, C1>
const & features,
370 MultiArrayView<2, U, C2> & fz,
371 MultiArrayView<2, U, C3> & zv,
372 PLSAOptions
const & options = PLSAOptions())
374 RandomNumberGenerator<> generator(RandomSeed);
375 pLSA(features, fz, zv, generator, options);
Option object for the pLSA algorithm.
Definition unsupervised_decomposition.hxx:159
PLSAOptions & minimumRelativeGain(double g)
Definition unsupervised_decomposition.hxx:185
PLSAOptions & normalizedComponentWeights(bool v=true)
Definition unsupervised_decomposition.hxx:200
PLSAOptions()
Definition unsupervised_decomposition.hxx:163
PLSAOptions & maximumNumberOfIterations(unsigned int n)
Definition unsupervised_decomposition.hxx:173
Class for a single RGB value.
Definition rgbvalue.hxx:128
void principalComponents(MultiArrayView< 2, T, C1 > const &features, MultiArrayView< 2, T, C2 > fz, MultiArrayView< 2, T, C3 > zv)
Decompose a matrix according to the PCA algorithm.
Definition unsupervised_decomposition.hxx:120
void initMultiArray(...)
Write a value to every element in a multi-dimensional array.
void pLSA(...)
Decompose a matrix according to the pLSA algorithm.
FFTWComplex< R >::SquaredNormType squaredNorm(const FFTWComplex< R > &a)
squared norm (= squared magnitude)
Definition fftw3.hxx:1044