From 518b92355da60db136aa57ed8878c3ef159febd2 Mon Sep 17 00:00:00 2001 From: Harshit Syal Date: Thu, 5 Apr 2012 18:24:03 +0530 Subject: [PATCH 1/2] Added brief intro to NewtonSVM and added octave_modular example --- .../classifier_newtonsvm_modular.m | 34 +++++++++++++++++++ src/shogun/classifier/svm/NewtonSVM.h | 8 +++-- 2 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 examples/undocumented/octave_modular/classifier_newtonsvm_modular.m diff --git a/examples/undocumented/octave_modular/classifier_newtonsvm_modular.m b/examples/undocumented/octave_modular/classifier_newtonsvm_modular.m new file mode 100644 index 00000000000..85f1abca66a --- /dev/null +++ b/examples/undocumented/octave_modular/classifier_newtonsvm_modular.m @@ -0,0 +1,34 @@ +init_shogun + +addpath('tools'); +label=load_matrix('../data/label_train_dna.dat'); +data=load_matrix('../data/fm_train_dna.dat'); +fm_test_real=load_matrix('../data/fm_test_dna.dat'); + +% Newton SVM + +disp('NewtonSVM') +data=double(data); +%fm_test_real=double(fm_test_real); +realfeat=RealFeatures(data); +feats_train=SparseRealFeatures(); +feats_train.obtain_from_simple(realfeat); +%realfeat=RealFeatures(fm_test_real); +%feats_test=SparseRealFeatures(); +%feats_test.obtain_from_simple(realfeat); + +C=1.0; +epsilon=1e-5; +num_threads=1; +label=double(label); +labels=Labels(label); + +svm=NewtonSVM(C, feats_train, labels); +svm.set_epsilon(epsilon); +svm.parallel.set_num_threads(num_threads); +svm.set_bias_enabled(true); +svm.train(); +%svm.set_features(feats_test); +svm.get_bias(); +svm.get_w(); +%svm.apply().get_labels(); diff --git a/src/shogun/classifier/svm/NewtonSVM.h b/src/shogun/classifier/svm/NewtonSVM.h index 5b3708a42c5..ee6390a37fd 100644 --- a/src/shogun/classifier/svm/NewtonSVM.h +++ b/src/shogun/classifier/svm/NewtonSVM.h @@ -19,7 +19,11 @@ namespace shogun { #ifdef HAVE_LAPACK -/** @brief class NewtonSVM */ +/** @brief NewtonSVM, + * In this Implementation linear SVM is trained in its primal form using Newton-like iterations. + * This Implementation is ported from the Olivier Chapelles fast newton based SVM solver, Which could be found here :http://mloss.org/software/view/30/ + * For further information on this implementation of SVM refer to this paper: http://www.kyb.mpg.de/publications/attachments/neco_%5B0%5D.pdf +*/ class CNewtonSVM : public CLinearMachine { public: @@ -38,7 +42,7 @@ class CNewtonSVM : public CLinearMachine /** get classifier type * - * @return classifier type NewtonSVM +il * @return classifier type NewtonSVM */ virtual inline EClassifierType get_classifier_type() { return CT_NEWTONSVM; } From df76789fb50db931b6e8b5bfeef1591fdbf4af02 Mon Sep 17 00:00:00 2001 From: Harshit Syal Date: Thu, 5 Apr 2012 18:58:16 +0530 Subject: [PATCH 2/2] Removed some typo --- src/shogun/classifier/svm/NewtonSVM.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/shogun/classifier/svm/NewtonSVM.h b/src/shogun/classifier/svm/NewtonSVM.h index ee6390a37fd..961ccb9d61f 100644 --- a/src/shogun/classifier/svm/NewtonSVM.h +++ b/src/shogun/classifier/svm/NewtonSVM.h @@ -42,7 +42,7 @@ class CNewtonSVM : public CLinearMachine /** get classifier type * -il * @return classifier type NewtonSVM + * @return classifier type NewtonSVM */ virtual inline EClassifierType get_classifier_type() { return CT_NEWTONSVM; }