diff --git a/data b/data index 7854e3b08ab..4eebd86a52a 160000 --- a/data +++ b/data @@ -1 +1 @@ -Subproject commit 7854e3b08ab99594dcba4c6e94d7cd48eb2d0556 +Subproject commit 4eebd86a52a1bdb9bf15974565d606c17d08211b diff --git a/doc/cookbook/source/examples/converter/ica_fast.rst b/doc/cookbook/source/examples/converter/ica_fast.rst new file mode 100644 index 00000000000..3683c5e4043 --- /dev/null +++ b/doc/cookbook/source/examples/converter/ica_fast.rst @@ -0,0 +1,38 @@ +============================== +Independent Component Analysis +============================== + +Independent component analysis (ICA) separates a multivariate signal into additive subcomponents that are maximally independent. +It is typically used for separating superimposed signals. + +The ICA algorithm presented here is fastICA, see :cite:`hyvarinen2000independent` for details. +There are many other ICA implementations, all based on :sgclass:`CICAConverter` + +------- +Example +------- + +Given a dataset which we assume consists of linearly mixed signals, we create CDenseFeatures +(RealFeatures, here 64 bit float values). + +.. sgexample:: ica_fast.sg:create_features + +We create the :sgclass:`CFastICA` instance, and set its parameter for the iterative optimization. + +.. sgexample:: ica_fast.sg:set_parameters + +Then we apply ICA, which gives the unmixed signals. + +.. sgexample:: ica_fast.sg:apply_convert + +We can also extract the estimated mixing matrix. + +.. sgexample:: ica_fast.sg:extract + +---------- +References +---------- +:wiki:`Independent_component_analysis` + +.. bibliography:: ../../references.bib + :filter: docname in docnames diff --git a/doc/cookbook/source/index.rst b/doc/cookbook/source/index.rst index 1b979cb0399..c6398824f0c 100644 --- a/doc/cookbook/source/index.rst +++ b/doc/cookbook/source/index.rst @@ -56,15 +56,15 @@ Statistical Testing examples/statistical_testing/** -Kernels -------- +Converter +--------- .. toctree:: :maxdepth: 1 :glob: - :caption: Kernels + :caption: Converter - examples/kernel/** + examples/converter/** Gaussian Processes ------------------ diff --git a/doc/cookbook/source/references.bib b/doc/cookbook/source/references.bib index b32bec37852..073d5a70290 100644 --- a/doc/cookbook/source/references.bib +++ b/doc/cookbook/source/references.bib @@ -153,3 +153,13 @@ @article{Quinonero-Candela2005 year = {2005}, pages = {1939--1959}, } + +@article{hyvarinen2000independent, + title={Independent component analysis: algorithms and applications}, + author={Hyv{\"a}rinen, A. and Oja, E.}, + journal={Neural networks}, + volume={13}, + number={4}, + pages={411--430}, + year={2000} +} diff --git a/examples/meta/src/converter/ica_fast.sg b/examples/meta/src/converter/ica_fast.sg new file mode 100644 index 00000000000..616f6767275 --- /dev/null +++ b/examples/meta/src/converter/ica_fast.sg @@ -0,0 +1,24 @@ +CSVFile f_feats("../../data/ica_2_sources.dat") + +Math:init_random(1) + +#![create_features] +RealFeatures features(f_feats) +#![create_features] + +#![set_parameters] +FastICA ica() +ica.set_max_iter(200) +ica.set_tol(0.00001) +#![set_parameters] + +#![apply_convert] +Features converted = ica.apply(features) +#![apply_convert] + +#![extract] +RealMatrix mixing_matrix = ica.get_mixing_matrix() +RealFeatures casted = RealFeatures:obtain_from_generic(converted) +RealMatrix unmixed_signal = casted.get_feature_matrix() +#![extract] + diff --git a/examples/meta/src/converter/ica_ff_sep.sg b/examples/meta/src/converter/ica_ff_sep.sg new file mode 100644 index 00000000000..c8d6b47af0d --- /dev/null +++ b/examples/meta/src/converter/ica_ff_sep.sg @@ -0,0 +1,24 @@ +CSVFile f_feats("../../data/ica_2_sources.dat") + +Math:init_random(1) + +#![create_features] +RealFeatures features(f_feats) +#![create_features] + +#![set_parameters] +FFSep ica() +ica.set_max_iter(200) +ica.set_tol(0.00001) +#![set_parameters] + +#![apply_convert] +Features converted = ica.apply(features) +#![apply_convert] + +#![extract] +RealMatrix mixing_matrix = ica.get_mixing_matrix() +RealFeatures casted = RealFeatures:obtain_from_generic(converted) +RealMatrix unmixed_signal = casted.get_feature_matrix() +#![extract] + diff --git a/examples/meta/src/converter/ica_jade.sg b/examples/meta/src/converter/ica_jade.sg new file mode 100644 index 00000000000..633e0eedf45 --- /dev/null +++ b/examples/meta/src/converter/ica_jade.sg @@ -0,0 +1,24 @@ +CSVFile f_feats("../../data/ica_2_sources.dat") + +Math:init_random(1) + +#![create_features] +RealFeatures features(f_feats) +#![create_features] + +#![set_parameters] +Jade ica() +ica.set_max_iter(200) +ica.set_tol(0.00001) +#![set_parameters] + +#![apply_convert] +Features converted = ica.apply(features) +#![apply_convert] + +#![extract] +RealMatrix mixing_matrix = ica.get_mixing_matrix() +RealFeatures casted = RealFeatures:obtain_from_generic(converted) +RealMatrix unmixed_signal = casted.get_feature_matrix() +#![extract] + diff --git a/examples/meta/src/converter/ica_jedi_sep.sg b/examples/meta/src/converter/ica_jedi_sep.sg new file mode 100644 index 00000000000..68501bc9ab5 --- /dev/null +++ b/examples/meta/src/converter/ica_jedi_sep.sg @@ -0,0 +1,24 @@ +CSVFile f_feats("../../data/ica_2_sources.dat") + +Math:init_random(1) + +#![create_features] +RealFeatures features(f_feats) +#![create_features] + +#![set_parameters] +JediSep ica() +ica.set_max_iter(200) +ica.set_tol(0.00001) +#![set_parameters] + +#![apply_convert] +Features converted = ica.apply(features) +#![apply_convert] + +#![extract] +RealMatrix mixing_matrix = ica.get_mixing_matrix() +RealFeatures casted = RealFeatures:obtain_from_generic(converted) +RealMatrix unmixed_signal = casted.get_feature_matrix() +#![extract] + diff --git a/examples/meta/src/converter/ica_sobi.sg b/examples/meta/src/converter/ica_sobi.sg new file mode 100644 index 00000000000..51ddd07c713 --- /dev/null +++ b/examples/meta/src/converter/ica_sobi.sg @@ -0,0 +1,24 @@ +CSVFile f_feats("../../data/ica_2_sources.dat") + +Math:init_random(1) + +#![create_features] +RealFeatures features(f_feats) +#![create_features] + +#![set_parameters] +SOBI ica() +ica.set_max_iter(200) +ica.set_tol(0.00001) +#![set_parameters] + +#![apply_convert] +Features converted = ica.apply(features) +#![apply_convert] + +#![extract] +RealMatrix mixing_matrix = ica.get_mixing_matrix() +RealFeatures casted = RealFeatures:obtain_from_generic(converted) +RealMatrix unmixed_signal = casted.get_feature_matrix() +#![extract] + diff --git a/src/shogun/mathematics/ajd/UWedge.cpp b/src/shogun/mathematics/ajd/UWedge.cpp index e7911c80ee0..8cec2dd4dd0 100644 --- a/src/shogun/mathematics/ajd/UWedge.cpp +++ b/src/shogun/mathematics/ajd/UWedge.cpp @@ -113,7 +113,12 @@ SGMatrix CUWedge::diagonalize(SGNDArray C, SGMatrix