%Team members

%David Dobor
%Lakesh Kansakar
%Tiffany Nguyen

function [z_UU]=ssl(PLL, PLU, PUL, PUU, True_LL)

    number_examples = 1400;
    number_labels = 70;

    %Create the transition matrix
    P = [PLL PLU; PUL PUU];

    %Create the clamped Y
    Y = zeros(number_examples, number_labels);
    idx = sub2ind(size(Y), 1:number_labels, True_LL');
    Y(idx) = 1;
    %for i=1:size(PLL,1) 
    %    Y(i, True_LL(i,1)) = 1;
    %end
    Y_clamped = Y(1:number_labels,:);

    %Make all the class labels equally likely for the unlabelled data
    Y(number_labels+1:number_examples,:) = 1/number_labels;
    Y_predicted = Y;

    iteration = 800;
    for i=1:iteration
        Y_predicted = P*Y_predicted;
        Y_predicted(1:number_labels,:) = Y_clamped;
    end

    %Find the highly likely labels
    [~, z_UU] = max(Y_predicted,[],2);
    z_UU = z_UU(number_labels+1:number_examples);

    %Calculate the accuracy
    %accuracy=sum(z_UU==True_UU)/length(True_UU)
