% DEMO	The example of ML^2 algorithm.
%
%	Description  
%   The algorithm ML^2 includes three main steps. First, it estimates the 
%   topological strucutre from the feature space. Then it transfers the 
%   topological structure to the label space and constructs the label manifold. 
%   Finally, it adapts MSVR to learn the mapping from the feature manifold to 
%   the label manifold. Here is an example of ML^2 algorithm.
%
%
% Copyright: Peng Hou (hpeng@seu.edu.cn), Xin Geng (xgeng@seu.edu.cn),
%   Min-Ling Zhang (mlzhang@seu.edu.cn)
%   School of Computer Science and Engineering, Southeast University
%   Nanjing 211189, P.R.China
%

% load data file
load emotions

% initialize the model parameters.
para.tol  = 1e-10; %tolerance during the iteration
para.epsi = 0.1; %instances whose distance computed is more than epsi should be penalized
para.C1    = 1; %penalty parameter
para.C2    = 1; %penalty parameter
para.ker  = 'rbf'; %type of kernel function ('lin', 'poly', 'rbf', 'sam')
para.par  = 1*mean(pdist(trainX)); %parameter of kernel function
K = 10;
lambda = 1;

% train ML^2 algorithm
W = estimate_top_struct(trainX, K);
MU = build_label_manifold(trainY, W, lambda);
model = amsvr(trainX, trainY, para);

% predict
[label, degree] = predict(testX, trainX, model);
