-
-
Save deepakkandasamy/536ad36a02fa7cb9960a38d411ee6424 to your computer and use it in GitHub Desktop.
The command I used was g++ minimal1.cpp -L/home/deepak/anaconda2/lib -lhdf5 -lshogun
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <shogun/labels/Labels.h> | |
#include <shogun/features/DenseFeatures.h> | |
#include <shogun/kernel/GaussianKernel.h> | |
#include <shogun/classifier/svm/LibSVM.h> | |
#include <shogun/base/init.h> | |
#include <shogun/lib/common.h> | |
#include <shogun/io/SGIO.h> | |
using namespace shogun; | |
void print_message(FILE* target, const char* str) | |
{ | |
fprintf(target, "%s", str); | |
} | |
int main(int argc, char** argv) | |
{ | |
init_shogun(&print_message); | |
// create some data | |
SGMatrix<float64_t> matrix(2,3); | |
for (int32_t i=0; i<6; i++) | |
matrix.matrix[i]=i; | |
// create three 2-dimensional vectors | |
// shogun will now own the matrix created | |
CDenseFeatures<float64_t>* features= new CDenseFeatures<float64_t>(); | |
features->set_feature_matrix(matrix); | |
// create three labels | |
CBinaryLabels* labels=new CBinaryLabels(3); | |
labels->set_label(0, -1); | |
labels->set_label(1, +1); | |
labels->set_label(2, -1); | |
// create gaussian kernel with cache 10MB, width 0.5 | |
CGaussianKernel* kernel = new CGaussianKernel(10, 0.5); | |
kernel->init(features, features); | |
// create libsvm with C=10 and train | |
CLibSVM* svm = new CLibSVM(10, kernel, labels); | |
svm->train(); | |
// classify on training examples | |
for (int32_t i=0; i<3; i++) | |
SG_SPRINT("output[%d]=%f\n", i, svm->apply_one(i)); | |
// free up memory | |
SG_UNREF(svm); | |
exit_shogun(); | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In file included from /usr/local/include/shogun/mathematics/Math.h:30:0, | |
from /usr/local/include/shogun/features/SubsetStack.h:16, | |
from /usr/local/include/shogun/labels/Labels.h:22, | |
from minimal1.cpp:1: | |
/usr/local/include/shogun/lib/SGVector.h:69:26: error: expected unqualified-id before ‘using’ | |
template <typename ST> using container_type = SGVector<ST>; | |
^ | |
In file included from /usr/local/include/shogun/features/DotFeatures.h:19:0, | |
from /usr/local/include/shogun/features/DenseFeatures.h:22, | |
from minimal1.cpp:2: | |
/usr/local/include/shogun/lib/SGMatrix.h:64:26: error: expected unqualified-id before ‘using’ | |
template <typename ST> using container_type = SGMatrix<ST>; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment