Skip to content

Instantly share code, notes, and snippets.

@pranet
Created February 15, 2014 13:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pranet/9019380 to your computer and use it in GitHub Desktop.
Save pranet/9019380 to your computer and use it in GitHub Desktop.
from numpy.random import randn,randint
from numpy.ma.core import reshape, mean
from shogun.Features import RegressionLabels, RealFeatures
from shogun.Regression import LeastAngleRegression, LinearRidgeRegression, LeastSquaresRegression
from shogun.Evaluation import CrossValidation, CrossValidationResult, \
CrossValidationSplitting, MeanSquaredError
import time
n=250
n_class=6
dim=274 * 100 * 12
feats=randn(dim, n)
lab=randint(0,n_class, n)
# normalise
lab_mean=mean(lab)
lab=lab-lab_mean
feats=(feats.T-mean(feats,1)).T
features = RealFeatures(feats)
labels = RegressionLabels(lab)
lars = LeastAngleRegression()
lars.set_labels(labels)
time_start=time.time()
lars.train(RealFeatures(features))
time_end=time.time()
print "time", time_end-time_start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment