% Evaluate performance of unsupervised POS tagging algorithm % Many-to-1, 1-to-1, NVI metrics. % If you use this code, please cite: % Michael Lamar*, Yariv Maron*, Mark Johnson, Elie Bienenstock. % SVD and clustering for unsupervised POS tagging. (ACL 2010) % For more information, see the above reference. function [MTO_score, OTO_score, NVI_score] = eval_labels( labels, tags ) % MTO_score - Many-to-One score % OTO_score - One-to-One score % NVI_score - Normalized Variation of Information score conf_matrix = sparse(tags, labels, 1); % gold tags are rows, induced labels are columns conf_matrix = full(conf_matrix/sum(conf_matrix(:))); [MTO_score, MTO_tag] = max(conf_matrix); MTO_score = sum(MTO_score); % many-to-one score [OTO_score, OTO_tag] = one2one_map_all(conf_matrix); % one-to-one [H1, H2, VI] = var_information(conf_matrix); NVI_score = VI/H1; % Normalized VI display(['Many-to-1: ' num2str(MTO_score) ... ' Greedy 1-to-1: ' num2str(OTO_score) ... ' NVI: ' num2str(NVI_score)]);