
%% Mnist dataset
W = load ('../data/mldata/mnist-original.mat');
X = W.data';
L = W.label;
X = single(X);


%% 20NG dataset
W = load ('../data/20news-bydate-matlab/train.data');
N = max(W(:,1))
XS = spconvert(W);
X = full(XS);
L = load ('../data/20news-bydate-matlab/train.label');
W = load ('../../data/20news-bydate-matlab/test.data');
TS = spconvert(W);
TS(:,53976:end) = [];
T = full(TS);
LT = load ('../../data/20news-bydate-matlab/test.label');
%%%%% weight features by IDF
DF = sum (X~=0,1);
IDF = log2(11269 ./ DF);
IDF(find(IDF<3)) =0;
X = bsxfun(@times, X, IDF) ;
%T = bsxfun(@times, T, IDF) 
whos; pause;



numGroups = length(unique(L));
clr = hsv(numGroups)


Y2 = tsne(X,'Algorithm','barneshut','NumPCAComponents',50);
figure(3);clf;
gscatter(Y2(:,1),Y2(:,2),L,clr)

% % Y3 = tsne(X,'Algorithm','barneshut','NumPCAComponents',50,'numdimensions',3, 'perplexity', 20);
% Y3 = tsne(X,'Algorithm','barneshut','NumPCAComponents',300,'numdimensions',3,'distance','cosine','perplexity',50);
% figure(4);clf;
% %scatter3 ( Y3(:,1),Y3(:,2),Y3(:,3), 10 ,L)
% scatter3(Y3(:,1),Y3(:,2),Y3(:,3),15,clr(L,:),'filled');
