-
Notifications
You must be signed in to change notification settings - Fork 3
/
readData.m
54 lines (49 loc) · 1.46 KB
/
readData.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
% x - training data input
% y - training data output
% N - size of training data set
% d - dimension of data set
% inputVal - testing data input
% givenOut - testing data output
function [NC, data, file_path, x, y, N, d, inputVal, givenOut] = readData(data, file_path, givenFileName, givenFilePath)
%%%%%%%%% Training Data %%%%%%%%%%%%%%%%%%
data_type = '%g';
data_separator = ',';
file_type = '*.data';
if(isempty(data) || isempty(file_path)) %For first instance
[data file_path] = get_data(data_type,data_separator,'Raw Data File',file_type, givenFileName, givenFilePath);
end
% [~,file_used,~] = fileparts(file_path); %get only file name. Remove extension.
rawData = data(:,1:size(data,2)-1);
[N,d] = size(rawData);
for i = 1:d
rawData(:,i) = norm_variance(rawData(:,i));
rawData(:,i) = norm_scale01(rawData(:,i));
end
order = randperm(N);
tr = order(1:N*0.6);
ts = order(N*0.6+1:N);
x = rawData(tr,:);
newX0 = ones(size(x,1),1);
x = [newX0 x];
x = x';
[d, N] = size(x);
rawOut = data(:,size(data,2));
% % clear data;
y = rawOut(tr,:);
y = y';
NC = max(size(unique(y)));
% >>
%%%%%%%%%%%%%%% Training Data %%%%%%%%%%%%%%%%%%%%
%% Testing Data
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%<<
inputVal = rawData(ts,:);
newX0 = ones(size(inputVal,1),1);
inputVal = [newX0 inputVal];
inputVal = inputVal';
[dt, Nt] = size(inputVal);
givenOut = rawOut(ts,:);
givenOut = givenOut';
%>>
%%%%%%%%%% test data %%%%%%%%%%%%%%%%%%%%%%
end