-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetYpredict.m
More file actions
executable file
·65 lines (43 loc) · 1.38 KB
/
getYpredict.m
File metadata and controls
executable file
·65 lines (43 loc) · 1.38 KB
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 y_predict = getYpredict( x_train,y_train,x_predict,lambda );
[n d] = size(x_train);
[xp_h xp_w] = size(x_predict);
if(d == 1)
k = 2;
else
k = ceil(d/2);
end
T = theta (k,d);
L = setL(d,k);
% defining the unique values of x_train and their occurrences
occurrences = getOccurrences( x_train);
z_i = occurrences.value;
n_i = occurrences.count;
[N z_w] = size(z_i);
% to be fix to correct entries
% function result = MonomialMatrix(vec,k,l,N)
monoMatrix = MonomialMatrix(x_train,k,L,N,d);
correctK = zeros(N,N);
for i=1:N
for j=1:N
if(i == j)
correctK(i,j) = lambda;
else
diff = z_i(i) - z_i(j); % K(z1 - z2) .... K(z1 -zn)
correctK(i,j) = occurrences.count(i)/n * bigK(diff,k,d);
end
end
end
A = megaMatix(correctK,n_i,monoMatrix,N,L,lambda);
X = rightHandSideVersion3(x_train,y_train,z_i,L);
X = X';
coefficientVector = linsolve(A,X);
% v=zeros(size(x_predict),L);
v=MonomialMatrix(x_predict,L,k,xp_h,xp_w);
for i=1:xp_h
% result = gStar(coefficientVector,z_i,x,N,L,k,v_row);
% y_predict(i) = gStar(coefficientVector,z_i,x_predict(i),N,L,k,monoMatrix,d);
% gStar(coefficientVector,z_i,x,N,L,k,v_row,d);
y_predict(i) = gStar(coefficientVector,z_i,x_predict(i),N,L,k,v(i,:),d);
end
y_predict = y_predict';
end