%%The demo
clear all

load('yeast_train');
load('yeast_test');

%M solving
disp('metric learning:');
%initialization parameters
alpha=0.4;
threshold=0.6;
C=10;
tic;
M=COMMU(train_data,train_target,alpha,C,threshold);
toc;
%base classifier:knn
disp('metric learning over and knn predicts:');
tic;
[Outputs,Pre_Labels]=COMMU_test_knn(train_data,train_target,test_data,M);
toc;
disp('knn_based results:');
[RankingLoss_knn,OneError_knn,coverage_knn,Average_Precision_knn,exampleF1_knn,MacroF1_knn]=MLEvaluate(Outputs,Pre_Labels,test_target');
res=[RankingLoss_knn,OneError_knn,coverage_knn,Average_Precision_knn,exampleF1_knn,MacroF1_knn];
disp(res);
%base classifier:mlknn
Num=10;
Smooth=1.0;
disp(' mlknn predicts:');
tic;
[Prior,PriorN,Cond,CondN]=mlknn_train(train_data,train_target',Num,Smooth,M);
[RankingLoss_mlknn,OneError_mlknn,Coverage_mlknn,Average_Precision_mlknn,exampleF1_mlknn,MacroF1_mlknn,Outputs_mlknn,Pre_Labels_mlknn]=mlknn_test(train_data,train_target',test_data,test_target',Num,Prior,PriorN,Cond,CondN,M);
toc;
disp('mlknn_based results:');
res=[RankingLoss_mlknn,OneError_mlknn,Coverage_mlknn,Average_Precision_mlknn,exampleF1_mlknn,MacroF1_mlknn];
disp(res);

