From d83e911fe228571171f9ddc379708dc37c4bfddf Mon Sep 17 00:00:00 2001 From: Gertjan van den Burg Date: Tue, 27 Mar 2018 19:24:03 +0100 Subject: Major bugfix for nonlinear GenSVM Nonlinear GenSVM depends on the eigendecomposition of the kernel matrix. Mathematically, the Sigma vector in the code should contain the square root of the eigenvalues. Taking the square root was however neglected, which resulted in poor performance of nonlinear GenSVM. This is now fixed, which means that the performance of nonlinear GenSVM will be much better. --- tests/aux/test_train_kernel.m | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'tests/aux/test_train_kernel.m') diff --git a/tests/aux/test_train_kernel.m b/tests/aux/test_train_kernel.m index 7bf14b8..b561bd4 100644 --- a/tests/aux/test_train_kernel.m +++ b/tests/aux/test_train_kernel.m @@ -1,21 +1,21 @@ function [V] = test_train_kernel() - + clear; more off; rand('state', 654321); - + n = 10; m = 5; classes = 4; cutoff = 5e-3; - + X = rand(n, m); Z = [ones(n, 1), X]; set_matrix(Z, "data->Z", "data->m+1"); - + y = [2 1 3 2 3 2 4 1 3 4]; set_matrix(y, "data->y", "1"); - + p = 1.2143; kappa = 0.90298; lambda = 0.00219038; @@ -36,24 +36,24 @@ function [V] = test_train_kernel() eigenvalues = diag(Sigma); ratios = eigenvalues ./ eigenvalues(end, end); - + realP = fliplr(P(:, ratios > cutoff)); - realSigma = flipud(eigenvalues(ratios > cutoff)); - + realSigma = sqrt(flipud(eigenvalues(ratios > cutoff))); + assert_matrix(realSigma, "data->Sigma", "1"); - + r = sum(ratios > cutoff); fprintf("mu_assert(data->r == %i);\n", r); - + M = realP * diag(realSigma); size(M) - + assert_matrix(Z, "data->RAW", "data->m+1"); - - seedV = zeros(size(M, 2) + 1, classes - 1); + + seedV = zeros(size(M, 2) + 1, classes - 1); [W, t] = msvmmaj(M, y, rho, p, kappa, lambda, epsilon, 'show', 0, seedV); V = [t'; W]; - + fprintf('\n'); assert_matrix_abs(V, "model->V", "model->K-1"); @@ -89,4 +89,4 @@ function assert_matrix_abs(A, name, cols) end end fprintf("\n"); -end \ No newline at end of file +end -- cgit v1.2.3