function Metric = MDML_metric(y_predict_prob, y_ground_truth, y_predict_bin, numLabel)
%MDML_metric computes the evaluation metric value w.r.t. each dimension 
%Type 'help MDML_metric' under Matlab prompt for more detailed information about MDML_metric
%
%	Syntax
%
%       Metric = MDML_metric(y_predict_prob, y_ground_truth, y_predict_bin, numLabel)
%
%	Description
%
%   MDML_metric takes,
%       y_predict_prob	- A mxq array, the probability-style (real-valued) prediction, each row corresponds to the label vector of one instance
%       y_ground_truth	- A mxq array, the ground-truth (binary-valued) label matrix,each row corresponds to the label vector of one instance
%       y_predict_bin   - A mxq array, the binary-style (i.e., 0/1) prediction, each row corresponds to the label vector of one instance
%       numLabel        - A dx1 vector, the ith element denotes the number of labels in ith dimension
%   and returns,
%       Metric          - A 7xd array, 
%                       (a) Each column corresponds the metric values w.r.t one dimension
%						(b) The seven rows correspond to ranking loss, coverage, one error, 
%						average precision, hamming loss, macro-F1, micro-F1, in turn.

    num_metric = 7;
    num_dim = length(numLabel);
    Metric = zeros(num_metric, num_dim);
    for dd=1:num_dim
        idx_dim_b = sum(numLabel(1:dd-1))+1;
        idx_dim_e = sum(numLabel(1:dd));
        y_predict_prob_dd = y_predict_prob(:,idx_dim_b:idx_dim_e);
        y_ground_truth_dd = y_ground_truth(:,idx_dim_b:idx_dim_e);
        y_predict_bin_dd = y_predict_bin(:,idx_dim_b:idx_dim_e);
        %ranking-based evaluation metrics
        Metric(1,dd) = Ranking_loss(y_predict_prob_dd',y_ground_truth_dd');
        Metric(2,dd) = coverage(y_predict_prob_dd',y_ground_truth_dd');
        Metric(3,dd) = One_error(y_predict_prob_dd',y_ground_truth_dd');
        Metric(4,dd) = Average_precision(y_predict_prob_dd',y_ground_truth_dd');
        %classification-based evaluation metrics
        
        Metric(5,dd) = Hamming_loss(y_predict_bin_dd',y_ground_truth_dd');
        Metric(6,dd) = Macro_F1(y_predict_bin_dd,y_ground_truth_dd);
        Metric(7,dd) = Micro_F1(y_predict_bin_dd,y_ground_truth_dd);
    end
end