function detector = PLENL_train( train_data, train_p_target,options_osvm)

% PLENL [1] deals with partial label learning with emerging new labels
%
% Syntax
%
%       detector = PLENL_train( train_data, train_p_target,options_osvm)
%
% Description
%
%       PLENL takes,
%           train_data          - An MxN array, the ith instance of training instance is stored in train_data(i,:)
%           train_p_target      - A QxM array, if the jth class label is one of the partial labels for the ith training instance, then train_p_target(j,i) equals +1, otherwise train_p_target(j,i) equals 0
%           options_osvm       - The parameter string required by Libsvm [2] for one-class svm
%      
%       and returns,
%           detector  - A ensemble detector and classifier based on known labels
  
%
%  [1] X. Yu, M.-L. Zhang. Partial label learning with emerging new labels. In Proceedings of the 31st International Joint Conference on Artificial Intelligence (IJCAI'18), Stockholm, Sweden, 2018, in press.
%
%  [2] C. C. Chang, C. J. Lin. LIBSVM: A library for support vector machines. ACM Transactions on Intelligent Systems and Technology, 2011, 2(3): Article 27.

detector ={};
n_seq = 1:size(train_data,1);
[q,~] = size(train_p_target);

for k = 1:q
    cur_klb = k;
    idx_klb = n_seq(1,train_p_target(k,:)==1);
    data_klb = train_data(idx_klb,:);
    TP_lbs = ones(1,length(idx_klb));
    cur_osvm = libsvmtrain(TP_lbs',data_klb,options_osvm);
    detector{k,1} = cur_osvm;
end

end

