-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmat2UCI.m
66 lines (58 loc) · 1.69 KB
/
mat2UCI.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
function mat2UCI
clc;
dataSetName = {
% 'autos';
% 'contraceptive';
% 'balance';
% 'ecoli';
% 'dermatology';
% 'glass';
% 'new-thyroid';
% 'pageblocks';
% 'penbased';
% 'shuttle';
% 'thyroid';
% 'wine';
% 'yeast';
% 'ColonCancer'
% 'mappedPCA';
% 'mappedLPP';
% 'mappedLLE';
% 'mappedNPE';
% 'USPSmat';
% 'a1_s1';
% '20NewsgroupsMat';
'PIE_20Mat';
} ;
% dirctory = './matData/ColonCancer/' ;
% dirctory = './matData/MultiClassMatData/' ;
% dirctory = './matData/jixieData/' ;
dirctory = './matData/' ;
for dataId = 1:size(dataSetName)
fileName = dataSetName{dataId};
dataDir = strcat(dirctory,fileName);
structData = load(dataDir);
% structData = load('.\matData\a1.mat');
matData = cell2mat(struct2cell(structData));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% matData(:,end) = matData(:,end)+1;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
class = unique(matData(:,end));
numClass = length(class);
cellData = cell(1,numClass);
for i = 1:numClass
cellData{i} = matData(find(matData(:,end)==class(i)),:);
end
saveDirctiry = './formatUCI/';
% fieldName = fieldnames(structData);
name = strcat(fileName, '.mat');
fileDir = strcat(saveDirctiry, name);
%
fromName = strcat('=cellData', ';');
toName = 'data';
eval([toName fromName]);
save(fileDir,'data');
% strSave = strcat('save(',fileDir,',''',fileName,''')',';');
% eval(strSave);
end
end