Last change
on this file since 39 was
36,
checked in by dtax, 13 years ago
|
Also mixture of gaussians mapping...
|
-
Property svn:executable set to
*
|
File size:
1.0 KB
|
Rev | Line | |
---|
[36] | 1 | function [lab, w] = mogm(a, k, share) |
---|
| 2 | %MOGM Mixture-of-Gaussians clustering mapping |
---|
| 3 | % |
---|
| 4 | % [LAB, W] = mogm(A, K, SHARE) |
---|
| 5 | % |
---|
| 6 | % INPUT |
---|
| 7 | % A Dataset |
---|
| 8 | % K Number of mixture components |
---|
| 9 | % SHARE Use the same covariance for every component (true of false) |
---|
| 10 | % |
---|
| 11 | % OUTPUT |
---|
| 12 | % LAB Cluster labels for training data |
---|
| 13 | % W Clustering mapping |
---|
| 14 | |
---|
| 15 | |
---|
| 16 | if isa(a,'double') |
---|
| 17 | a = dataset(a,1); |
---|
| 18 | end |
---|
| 19 | |
---|
| 20 | % Fitting of the model |
---|
| 21 | if isdataset(a) && ~ismapping(k) |
---|
| 22 | if nargin < 2 |
---|
| 23 | error('Please input a dataset and the number of mixture components.'); |
---|
| 24 | end |
---|
| 25 | if ~exist('share', 'var') || isempty(share) |
---|
| 26 | share = false; |
---|
| 27 | end |
---|
| 28 | tol = 1e-6; |
---|
| 29 | if share |
---|
| 30 | [lab, w] = emclust(a, ldc([], tol, tol), k, 'soft'); |
---|
| 31 | else |
---|
| 32 | [lab, w] = emclust(a, qdc([], tol, tol), k, 'soft'); |
---|
| 33 | end |
---|
| 34 | %[~, lab] = max(lab, [], 2); |
---|
| 35 | |
---|
| 36 | % Out-of-sample extension |
---|
| 37 | elseif isdataset(a) && ~ismapping(k) |
---|
| 38 | lab = a * k; |
---|
| 39 | else |
---|
| 40 | error('Erroneous call to MOGM.'); |
---|
| 41 | end |
---|
Note: See
TracBrowser
for help on using the repository browser.