Skip to content

Instantly share code, notes, and snippets.

103 Blocks are allocated:
Memory block at 0x880d9b8 of size 1472 bytes (allocated in modshogun_wrap.cxx line 191453)
SGObject 'SimpleFeatures' at 0x880d3f0 of size 120 bytes with 2 ref's
Object at 0x878f488 of size 28 bytes
Memory block at 0x880d470 of size 4 bytes (allocated in ../shogun/base/DynArray.h line 49)
Object at 0x8789d38 of size 28 bytes
Memory block at 0x880d678 of size 4 bytes (allocated in ../shogun/base/DynArray.h line 49)
Object at 0x878a030 of size 32 bytes
Object at 0x880d898 of size 32 bytes
Object at 0x880d8f0 of size 32 bytes
@lisitsyn
lisitsyn / gist:1325045
Created October 29, 2011 20:26 — forked from hdclark/gist:1325029
Shogun tutorial example #3
// Compiling with g++ Shogun.cpp -lshogun -o shoguntest
#include <shogun/features/Labels.h>
#include <shogun/features/SimpleFeatures.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>
import numpy
def calcroc(out, lab):
"""
Computes the ROC curve.
Expects labels to be +/-1 and real-valued predictions
"""
idx = numpy.argsort(out)
tp=numpy.concatenate( ([1], 1-numpy.cumsum(lab[idx]>0)/float(numpy.sum(lab > 0))) )
fp=numpy.concatenate( ([1], 1-numpy.cumsum(lab[idx]<0)/float(numpy.sum(lab < 0))) )
score = 0.5*numpy.sum((fp[:-1]-fp[1:])*(tp[:-1]+tp[1:]))
call pathogen#infect()
syntax on
filetype plugin indent on
let g:load_doxygen_syntax=1
set ruler
set smartindent
set ai
set showmatch
set rulerformat=%(%l,%c\ %p%%%)
from modshogun import *
from numpy import *
import random
tree_adj = genfromtxt('tree.tsv', skiprows=1)[:,1:]
features = genfromtxt('features.tsv',skiprows=1)[:,1:]
labels = genfromtxt('labels.tsv',dtype=float)[:,1:].flatten()
n_dims, n_vecs = features.shape
norm = NormOne()
#include <eigen3/Eigen/Dense>
#include <cblas.h>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
using namespace Eigen;
static double loop_dot(double* a, double* b, int d)
{
from pylab import *
from numpy import *
from scipy.optimize import fmin_l_bfgs_b,check_grad
import time
random.seed(7)
N=25
X=hstack([random.randn(2,N)-1.5,random.randn(2,N)+1.5])
mean = X.mean(1)
for i in xrange(N*2):
import csv
import numpy
import time
class operation():
def __init__(self, msg):
self.msg = msg
def __enter__(self):
print 'Starting %s' % self.msg
self.start = time.time()
import csv
import numpy
import time
import modshogun
vars = {}
class operation():
def __init__(self, msg, *args):
self.msg = msg
import csv
import numpy
import time,datetime
import modshogun
import cPickle
vars = {}
# operational context
class operation(object):