mkturkcan / cvx-svm Goto Github PK
View Code? Open in Web Editor NEWSVM, kernel trick, CVX.
License: MIT License
SVM, kernel trick, CVX.
License: MIT License
Hello, bro. I'm a master student major in machine learning. I am now learning about cvx and tried to use it to solve svm. During experiments, I found it seemed that your code didn't work with poly kernel. Finally, I found it is caused by your wrong code in the computation of svm_bias. Here is my correct code, which has been tested for many times.
function [model] = cvx_svm_train(X,Y,varargin)
if isempty(varargin)
model = cvx_svm_init();
else
model = varargin{1};
end
K = cvx_svm_kernel(X,X,model);
M = size(X,1);
cvx_begin
cvx_solver SeDuMi
cvx_precision best
variable svm_beta(M);
minimize (0.5.*quad_form(Y.*svm_beta,K) - ones(M,1)'*(svm_beta));
subject to
svm_beta >= 0;
svm_beta <= model.C;
Y'*(svm_beta) == 0;
cvx_end
%svm_beta(svm_beta<10^-5)=0;
model.X = X(svm_beta>10^-5,:);
model.Y = Y(svm_beta>10^-5);
svm_beta = svm_beta(svm_beta>10^-5);
model.svm_beta = svm_beta;
K = cvx_svm_kernel(model.X,model.X,model);
disp(size(K*(model.svm_beta.*model.Y)))
model.svm_bias = mean(model.Y-K*(model.svm_beta.*model.Y));
K = cvx_svm_kernel(X,model.X,model);
model.training_accuracy = mean((double(K*(model.svm_beta.*model.Y)+model.svm_bias>0)*2-1)==Y);
end
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.