function data = make_data(filename, label_percent)
% creates a struct containing x, t, train, and test fields
% train and test are logical arrays indicating different trials' data

[Y,X] = read_sparse(filename);
  
data = struct('x', X, 't', Y);

[n,d] = size(X);

trials = 100;

train = zeros(trials,n);
test = zeros(trials,n);

lab_size = floor(label_percent * n);

for t = 1:trials,
    randidx = randperm(n);
        
    train(t,randidx(1:lab_size)) = true;
    train(t,randidx(lab_size+1:end)) = false;    

    test(t,randidx(1:lab_size)) = false;
    test(t,randidx(lab_size+1:end)) = true;
end

train = logical(train);
test = logical(test);

data.train = train;
data.test = test;
