Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merged mutating_versions into master #29

Closed
wants to merge 1 commit into from

Conversation

milanflach
Copy link

Replaces #17
The version allocates memory for prediction already during training. In addition it provides a svmpredict! version by writing the output into a preallocated svmtmp type.
The gain in performance of the new svmpredict! can best be seen, when using large matrices, e.g. computing the kernel matrix for the svm model explicitly in julia:

Example

using LIBSVM
using Distances
train = randn(3,5000);
D = pairwise(Euclidean(), train);
K = exp(-0.5.*D); #transform to simple kernel matrix

test = randn(3, 300);
Dtest = pairwise(Euclidean(), train, test);
Ktest = exp(-0.5.*Dtest);

@time model = svmtrain(K, svmtype = OneClassSVM, nu = 0.1, kernel = Kernel.Precomputed);

0.5s 440 mb new; 0.4 s, 400 Mb old version

gc()
@time (class, decvalues) = svmpredict(model, Ktest)

22 mb 0.01 s new; 0.04 s, 61 mb old version

@time svmtmp = LIBSVM.init_svmpredict(Ktest, model) # 22mb, 0.005s

@time LIBSVM.svmpredict!(svmtmp, model, Ktest) # 20kb, 0.004 s --> about 10 time speedup

@coveralls
Copy link

coveralls commented Jun 30, 2017

Coverage Status

Coverage increased (+0.1%) to 82.511% when pulling f90f907 on milanflach:mut_merge into 726d20d on mpastell:master.

@milanflach
Copy link
Author

@mpastell did you have time to look into this version? Would be nice to merge it... Milan

@milanflach milanflach closed this Apr 14, 2020
@milanflach milanflach deleted the mut_merge branch April 14, 2020 13:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants