-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLR_LS.m
More file actions
92 lines (81 loc) · 1.99 KB
/
LR_LS.m
File metadata and controls
92 lines (81 loc) · 1.99 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
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
function [ solGi, meGi , deGi,pcGi,posGi, time ] = LR_LS(X,Y,m,Q,I,pc,C)
%LR_LS Summary of this function goes here
% Detailed explanation goes here
% X: Data
% Y: Results
% m: puntos para entrenamiento
% Q: Cambio en el punto de corte
% pc: puntos de corte que definen la base
% I: Iteraciones
% C: Cantidad de validaciones cruzadas
fprintf('\n *Búsqueda Tabú.');
% M: Muestras
% N: Atributos
tic;
[M,N]=size(X);
m = round(M*m);
% sol: Vector solucion
% c: ¿?
% pos: ¿?
sol = 1:N;
c = sort(randperm(N,pc));
pos = zeros(1,N);
pos(c) = 1;
% meG: ¿?
% solG: ¿?
% pcG: ¿?
% posG: ¿?
meG = Inf;
solG = sol;
pcG = c;
posG = pos;
% meGi:
% deGi:
% solGi:
% pcGi:
% posGi:
meGi=zeros(1,Q);
deGi=zeros(1,Q);
solGi=cell(Q,1);
pcGi =cell(Q,1);
posGi=cell(Q,1);
fprintf('\n -Iteración: ');
for iq = 1:Q
fprintf(num2str(iq));
fprintf(',');
%fprintf('\n');
%iq
for it = 1:I
X = X(:,sol);
[me,de] = perform_cross_validation(X,Y,C,pc,m,c);
if(me<meG)
meG = me;
deG = de;
solG = sol;
pcG = c;
posG = pos;
end
p1 = randperm(N,1);
p2 = randperm(N,1);
sol([p2 p1]) = solG([p1 p2]);
end
meGi(iq) = meG;
deGi(iq) = deG;
solGi(iq)={solG};
pcGi(iq) ={pcG};
posGi(iq)={posG};
pos = posG;
p3 = randperm(N,1);
pos(p3) = ~pos(p3);
c = find(pos>0);
pc = length(c);
end
fprintf('\b');
%fig = figure;
%plot(meGi,'--*');
%title('Buqueda Tabú - Media del error');
%fig = figure;
%plot(deGi,'--*');
%title('Buqueda Tabú - desviación del error');
time=toc;
end