⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 determine_alpha2.m

📁 核方法&svm是模式识别是很重要的方法
💻 M
字号:
function [ alpha2,alpha2_index,alpha2_new ] = determine_alpha2( mat_kernel,E,alpha,Y,littleValue,C,alpha1,alpha1_index)%UNTITLED1 Summary of this function goes here%  Detailed explanation goes here%determine alpha2 by minimizing E1-E2E1 = E(alpha1_index);E1_E2 = max(abs(E-E1));alpha2_index_s = find(abs(E-E1)==E1_E2);alpha2_s = alpha(alpha2_index_s);for i=1:length(alpha2_s)    alpha2_index =alpha2_index_s(i);    alpha2 = alpha2_s(i);    if(Y(alpha1_index,1) ~= Y(alpha2_index,1))        U = max(0,alpha2-alpha1);        V = min(C,C-alpha1+alpha2);    else        U = max(0,alpha1+alpha2-C);        V = min(C,alpha1+alpha2);    end    k = mat_kernel(alpha1_index,alpha1_index)+mat_kernel(alpha2_index,alpha2_index)-2*mat_kernel(alpha1_index,alpha2_index);    if abs(k)<littleValue        continue;    end    alpha2_new = alpha2+Y(alpha2_index,1)*(E1-E(alpha2_index,1))/k;    if alpha2_new > V        alpha2_new = V;    elseif alpha2_new < U        alpha2_new = U;    end    if abs(alpha2_new-alpha2) < littleValue        continue    else        break    endend%determine alpha2 from support vectorif abs(alpha2_new-alpha2) < littleValue    sup_index = find(alpha>littleValue & alpha<C-littleValue);    if ~isempty(sup_index)        for j = 1:length(sup_index)            alpha2_index = sup_index(j);            alpha2 = alpha(alpha2_index);            if(Y(alpha1_index,1) ~= Y(alpha2_index,1))                U = max(0,alpha2-alpha1);                V = min(C,C-alpha1+alpha2);            else                U = max(0,alpha1+alpha2-C);                V = min(C,alpha1+alpha2);            end            k = mat_kernel(alpha1_index,alpha1_index)+mat_kernel(alpha2_index,alpha2_index)-2*mat_kernel(alpha1_index,alpha2_index);            if abs(k)<littleValue                continue;            end            alpha2_new = alpha2_new+Y(alpha2_index,1)*(E(alpha2_index,1)-E1)/k;            if alpha2_new > V                alpha2_new = V;            elseif alpha2_new < U                alpha2_new = U;            end            if abs(alpha2_new-alpha2) < littleValue                continue            else                break            end        end    endend%determine alpha2 from all training samplesif abs(alpha2_new-alpha2) < littleValue    clear i;    for i = 1:length(alpha)        alpha2_index = i;        alpha2 = alpha(alpha2_index);        if(Y(alpha1_index,1) ~= Y(alpha2_index,1))            U = max(0,alpha2-alpha1);            V = min(C,C-alpha1+alpha2);        else            U = max(0,alpha1+alpha2-C);            V = min(C,alpha1+alpha2);        end        k = mat_kernel(alpha1_index,alpha1_index)+mat_kernel(alpha2_index,alpha2_index)-2*mat_kernel(alpha1_index,alpha2_index);        if abs(k)<littleValue            continue;        end        alpha2_new = alpha2_new+Y(alpha2_index,1)*(E(alpha2_index,1)-E1)/k;        if alpha2_new > V            alpha2_new = V;        elseif alpha2_new < U            alpha2_new = U;        end        if abs(alpha2_new-alpha2) < littleValue            continue        else            break        end    endend    

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -