示例#1
0

##########################  Parameters #################################
loss = 'squarederror'
delta = 0.9
grouplist = [(0,3), (3,5), (5, 8), (8,10)]
groupweight = None
regu = 'grouplasso'
reargs = {'lam':0.5}
########################################################################
if loss in ['squarederror', 'huberloss']:
	fname = 'dataset/regudata'
	calmod = 'mse'
else:
	fname = 'dataset/clasdata'
	calmod = 'acc'
########################################################################

# load data set
data, target = loadata(fname)
# learning and predict ...
#args --> (loss, delta, regu, reargs, grouplist, groupweight)
LS = GSLM(loss=loss, delta=delta, regu=regu, reargs=reargs, grouplist=grouplist, groupweight=groupweight)
LS.fit(data, target)
pred = LS.predict(data)
res = accmse(target, pred, calmod=calmod)


print LS.coeff_
print res 
示例#2
0
from splearn import lars, lars_path
from splearn import cwd_lasso, cwd_elasticnet
from splearn import plotpath, loadata
from numpy.random import uniform, randn
from numpy import dot

X, y = loadata('dataset/regudata')

caltype = 'lar'
path = lars_path(X, y, method=caltype)
beta1 = lars(X, y, lam=100)
print beta1
beta2 = cwd_lasso(X, y, lam=100)
print beta2
beta3 = cwd_elasticnet(X, y, lam1=100, lam2=3.0)
print beta3

plotpath(path, pathtype=caltype.upper())
示例#3
0
delta = 0.9
grouplist = [(0, 3), (3, 5), (5, 8), (8, 10)]
groupweight = None
regu = 'grouplasso'
reargs = {'lam': 0.5}
########################################################################
if loss in ['squarederror', 'huberloss']:
    fname = 'dataset/regudata'
    calmod = 'mse'
else:
    fname = 'dataset/clasdata'
    calmod = 'acc'
########################################################################

# load data set
data, target = loadata(fname)
# learning and predict ...
#args --> (loss, delta, regu, reargs, grouplist, groupweight)
LS = GSLM(loss=loss,
          delta=delta,
          regu=regu,
          reargs=reargs,
          grouplist=grouplist,
          groupweight=groupweight)
LS.fit(data, target)
pred = LS.predict(data)
res = accmse(target, pred, calmod=calmod)

print LS.coeff_
print res
示例#4
0
from splearn import lars, lars_path
from splearn import cwd_lasso, cwd_elasticnet
from splearn import plotpath, loadata
from numpy.random import uniform, randn
from numpy import dot

X, y = loadata("dataset/regudata")

caltype = "lar"
path = lars_path(X, y, method=caltype)
beta1 = lars(X, y, lam=100)
print beta1
beta2 = cwd_lasso(X, y, lam=100)
print beta2
beta3 = cwd_elasticnet(X, y, lam1=100, lam2=3.0)
print beta3


plotpath(path, pathtype=caltype.upper())