Create a gist now

Instantly share code, notes, and snippets.

An abstract Shogun example language
#include <shogun/kernel/GaussianKernel.h>
#include <shogun/features/DenseFeatures.h>
using namespace shogun;
int main(int argc, char** argv)
{
init_shogun_with_defaults();
// comment: strongly typed c++ kind of style here, but doesn't have to be
CCSVFile* file=new CCSVFile("filename", 'w');
SG_REF(file);
CDenseFeatures<float64_t>* features=CDenseFeatures<float64_t>(file);
SG_REF(features);
float64_t kernel_width=2;
CGaussianKernel* kernel=new CGaussianKernel(kernel_width);
SG_REF(kernel);
kernel->init(features, features);
SGMatrix<float64_t> K=kernel.get_kernel_matrix();
// some code to serialise all Shogun objects for integration testing
// ...
SG_UNREF(file);
SG_UNREF(features);
SG_UNREF(kernel);
exit_shogun();
return 0;
}
modshogun
% comment: strongly typed c++ kind of style here, but doesn't have to be
file=CSVFile('filename');
features=RealFeatures(file);
kernel_width=2;
kernel=GaussianKernel(kernel_width);
K=kernel.get_kernel_matrix();
% some code to serialise all Shogun objects for integration testing
% ...
def example ():
from modshogun import RealFeatures, GaussianKernel, CSVFile
# comment: strongly typed c++ kind of style here, but doesn't have to be
file=CSVFile("filename");
features=RealFeatures(file);
kernel_width=2;
kernel=GaussianKernel(kernel_width);
K=kernel.get_kernel_matrix();
# some code to serialise all Shogun objects for integration testing
# ...
// comment: strongly typed c++ kind of style here, but doesn't have to be
CCSVFile file=CCSVFile("filename");
RealFeatures features=RealFeatures(file);
float64 kernel_width=2;
GaussianKernel kernel=GaussianKernel(kernel_width);
SGMatrix<float64> K=kernel.get_kernel_matrix();
@iglesias

I would go for extension .sg.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment