-
Notifications
You must be signed in to change notification settings - Fork 1
/
inputdatasetXD.m
338 lines (288 loc) · 11.4 KB
/
inputdatasetXD.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
% 编号 数据集名称 类别数 样本数 特征数
% 1 breast 2 683 10
% 2 sonar 2 208 60
% 3 musk1 2 476 166
% 4 musk2 2 6598 166
% 5 image 2 6500 18
% 6 HVwithnoise 2 1212 100 Hill_Valley_with_noise_full
% 7 titanic 2 750 3
% 8 Spectf 2 267 44
% 9 splice 2 5000 60
% 10 dna 2 3186 180
% 11 magic 2 19020 10
% 12 Ionosphere 2 351 34
% 13 german 2 1000 24
% 14 svmguide3 2 1243 22
% 15 protein 2 17766 357
% 16 madelon_train 2 2000 500
% 17 banana 2 5300 2
% 18 ecoli1 2 336 7
% 19 ecoli2 2 336 7
% 20 ecoli3 2 336 7
% 21 magic 2 19020 10
% 22 spambase 2 4601 57
% 23 vehicle1 2 846 18
% 24 vehicle2 2 846 18
% 25 vehicle3 2 846 18
% 26 wisconsin 2 683 9
% 27 wine 3 178 13
% 28 wdbc 2 569 30
% 29 australian 2 690 14
% 30 hepatitis 2 155 19
% 31 Arrhythmia 13 452 279
% 32 Colon 2 62 2000
% 33 glass 6 214 9
% 34 LSVT 2 120 309
% 35 HillValley 606 100
% 36 SCADI 70 206
% 37 Dermatology 366 34
% 38 Urban 9 168 148
% 39 Isolet5 26 1559 617
function [dataset,whether,datasetName]=inputdatasetXD(i)
%说明:函数根据输入的序号来读取相应的数据集,序号与数据集对应如上
%输入:i:所需要读取的数据集的序号
%输出:dataset: 读取的数据(样本数*属性)
% whether: 读取出的数据标签(样本数*标签)
% datasetName: 数据集的名称
switch i
case 1 % breast 683*10
load('E:\dataset\breast.mat');
dataset = full(Xtr') ;
whether = Ytr';
datasetName='breast';
case 2 % sonar 208*60
load('E:\dataset\sonar.mat');
dataset = A(:,1:end-1)' ;
whether = A(:,end)';
datasetName = 'sonar';
case 3 % musk1 476*166
fid = fopen('E:\dataset\musk1\clean1\clean1.data','r');
juzhen=textscan(fid,'%*s%*s%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f','delimiter', ',');
dataset=cell2mat(juzhen);
whether=dataset(:,size(dataset,2));
whether=whether';
dataset=dataset(:,1:size(dataset,2)-1);
dataset=dataset';
fclose(fid);
datasetName = 'musk1';
case 4 % musk2 6598*166
fid = fopen('E:\dataset\musk1\clean2\clean2.data','r');
juzhen=textscan(fid,'%*s%*s%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f','delimiter', ',');
dataset=cell2mat(juzhen);
whether=dataset(:,size(dataset,2));
whether=whether';
dataset=dataset(:,1:size(dataset,2)-1);
dataset=dataset';
fclose(fid);
datasetName = 'musk2';
case 5 % image 6500*18
load('E:\dataset\image.mat');
dataset = X' ;
whether = Y';
datasetName = 'image';
case 6 % Hill_Valley_with_noise_full 1212*100
fid = fopen('E:\dataset\hillvalley\Hill_Valley_with_noise_full.data','r');
juzhen=textscan(fid,'%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f','delimiter', ',');
dataset=cell2mat(juzhen);
whether=dataset(:,size(dataset,2):size(dataset,2));
dataset=dataset(:,1:size(dataset,2)-1);
dataset=dataset';
whether=whether';
fclose(fid);
datasetName = 'Hill_Valley_with_noise_full';
case 7 % titanic 750*3
load('E:\dataset\titanic.mat');
dataset = X' ;
whether = Y';
datasetName = 'titanic';
case 8 % Spectf 267*44
fid = fopen('E:\dataset\xxs\V6 Spectf.txt','r');
juzhen=textscan(fid,'%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f%f','delimiter', ',');
dataset=cell2mat(juzhen);
whether=dataset(:,size(dataset,2));
whether=whether';
dataset=dataset(:,1:size(dataset,2)-1);
dataset=dataset';
fclose(fid);
datasetName = 'Spectf';
case 9 % splice 5000*60
load('E:\dataset\splice.mat');
dataset = X' ;
whether = Y';
datasetName = 'splice';
case 10 % dna 3186*180
load('E:\dataset\dna.mat');
dataset = instance' ;
whether = label';
datasetName = 'dna';
case 11 % magic 19020*10
% function [dataset,whether]=inputdataset()
[A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,whethertemp] =textread('E:\dataset\magic.txt','%f%f%f%f%f%f%f%f%f%f%s','delimiter', ',');
whethertemp=whethertemp';
whether=zeros(1,size(whethertemp,2));
for i=1:size(whethertemp,2)
if whethertemp{i}=='g'
whether(i)=1;
else
whether(i)=0;
end
end
dataset=[A1,A2,A3,A4,A5,A6,A7,A8,A9,A10];
dataset=dataset';
datasetName = 'magic';
% end
case 12 % Ionosphere 351*34
load('E:\dataset\ionosphere.mat');
dataset = instance' ;
whether = label';
datasetName = 'ionosphere';
case 13 % german 1000*24
load('E:\dataset\german.mat');
dataset= instance' ;
whether = label';
datasetName = 'german';
case 14 % svmguide3 1243*22
load('E:\dataset\svmguide3.mat');
dataset = instance' ;
whether = label';
datasetName = 'svmguide3';
case 15 % protein 17766*357
load('E:\dataset\protein.mat');
dataset = instance' ;
whether = label';
datasetName = 'protein';
case 16 % madelon_train 2000*500
load('E:\dataset\madelon.mat');
dataset = A(:,1:end-1)' ;
whether = A(:,end)';
datasetName = 'madelon_train';
case 17 % banana 5300*2
load('E:\dataset\banana.mat');
dataset = A(:,1:2)' ;
whether = A(:,end)';
datasetName='banana';
case 18 % ecoli1 336*7
load('E:\dataset\ecoli1.mat');
dataset = A(:,1:end-1)' ;
whether = A(:,end)';
datasetName='ecoli1';
case 19 % ecoli2 336*7
load('E:\dataset\ecoli2.mat');
dataset = A(:,1:end-1)' ;
whether = A(:,end)';
datasetName='ecoli2';
case 20 % ecoli3 336*7
load('E:\dataset\ecoli3.mat');
dataset = A(:,1:end-1)' ;
whether = A(:,end)';
datasetName='ecoli3';
case 21 % magic 19020*10
load('E:\dataset\magic1.mat');
dataset = A(:,1:end-1)' ; %于magic有区别,但名字没有区别
whether = A(:,end)';
datasetName='magic';
case 22 % spambase 4601*57
load('E:\dataset\spambase.mat');
dataset = A(:,1:end-1)' ;
whether = A(:,end)'; %spambase.old样本数为4597
datasetName='spambase';
case 23 % vehicle1 846*18
load('E:\dataset\vehicle1.mat');
dataset = A(:,1:end-1)' ;
whether = A(:,end)';
datasetName='vehicle1';
case 24 % vehicle2 846*18
load('E:\dataset\vehicle2.mat');
dataset = A(:,1:end-1)' ;
whether = A(:,end)';
datasetName='vehicle2';
case 25 % vehicle3 846*18
load('E:\dataset\vehicle3.mat');
dataset = A(:,1:end-1)' ;
whether = A(:,end)';
datasetName='vehicle3';
case 26 % wisconsin 683*9
load('E:\dataset\wisconsin.mat');
dataset = A(:,1:end-1)' ;
whether = A(:,end)';
whether((whether==2))=0;%%负样本标签为0
whether((whether==4))=1;%%正样本标签为1
datasetName='wisconsin';
case 27 % wine 178*13
load('E:\dataset\wine.mat');
dataset = A(:,1:end-1)' ;
whether = A(:,end)';
datasetName='wine';
case 28 % wdbc 569*30
load('E:\dataset\wdbc.mat');
dataset = A(:,1:end-1)' ;
whether = A(:,end)';
datasetName='wdbc';
case 29 % australian 690*14
load('E:\dataset\australian.mat');
dataset = A(:,1:end-1)' ;
whether = A(:,end)';
datasetName='australian';
case 30 % hepatitis 155*19
load('E:\dataset\hepatitis.mat');
dataset = A(:,1:end-1)' ;
whether = A(:,end)';
datasetName='hepatitis';
case 31 % Arrhythmia 452*279
load('E:\dataset\arrhythmia.mat');
dataset = A(:,1:end-1)' ;
whether = A(:,end)';
datasetName='arrhythmia';
case 32 % Colon 62*2000
load('E:\dataset\colon.mat');
dataset = A(:,1:end-1)' ;
whether = A(:,end)';
datasetName='colon';
case 33 % glass 217*9
load('E:\dataset\glass.mat');
dataset = A(:,1:end-1)' ;
whether = A(:,end)';
datasetName='glass';
case 34 % LSVT 126*309
load('E:\dataset\LSVT.mat');
dataset = A(:,1:end-1)' ;
whether = A(:,end)';
datasetName='LSVT';
case 35 % HillValley 606*100
load('E:\dataset\hillvalley.mat');
dataset = A(:,1:end-1)' ;
whether = A(:,end)';
datasetName='HillValley';
case 36 % SCADI 70*206
load('E:\dataset\SCADI.mat');
dataset = A(:,1:end-1)' ;
whether = A(:,end)';
datasetName='SCADI';
case 37 % Dermatology 366*34
load('E:\dataset\SCADI.mat');
dataset = A(:,1:end-1)' ;
whether = A(:,end)';
datasetName='Dermatology';
case 38 % Urban 168*148
load('E:\dataset\Urban.mat');
dataset = A(:,1:end-1)' ;
whether = A(:,end)';
datasetName='Urban';
case 39 % Isolet5 1559*617
load('E:\dataset\isolet.mat');
dataset = A(:,1:end-1)' ;
whether = A(:,end)';
datasetName='Isolet5';
otherwise
error('没有与 编号%d 对应的数据集.',i);
end % switch
if size(whether, 2)~=1
dataset = dataset';
whether = whether';
end
if size(dataset,1)~= size(whether,1)
error('Error. 数据集和标签维度不一致.')
end
whether(whether==-1)=0; %对whether进行处理,把-1变为0
datasetName = cat(2,upper(datasetName(1)), lower(datasetName(2:end)));
end