Skip to content
Snippets Groups Projects
Commit 90eb5b71 authored by Olivier Grisel's avatar Olivier Grisel
Browse files

add some print statements to monitor lasso/enet progress and tweaks parameters...

add some print statements to monitor lasso/enet progress and tweaks parameters to make it faster to run

git-svn-id: https://scikit-learn.svn.sourceforge.net/svnroot/scikit-learn/trunk@688 22fbfee3-77ab-4535-9bad-27d1bd3bc7d8
parent b1c363a2
No related branches found
No related tags found
No related merge requests found
......@@ -35,6 +35,8 @@ X = np.random.randn(n_samples, n_features)
alpha = 1
lasso_objective_callback = IterationCallbackFunc(lasso_objective)
lasso = Lasso(alpha=alpha, callbacks=[lasso_objective_callback])
print "Fitting lasso model to random data..."
lasso.fit(X, y, maxit=maxit)
print "Duality gap Lasso (should be small): %f" % \
......@@ -46,6 +48,8 @@ lasso_objective = lasso_objective_callback.values
alpha, beta = 1, 1
enet_objective_callback = IterationCallbackFunc(enet_objective)
enet = ElasticNet(alpha=alpha, beta=beta, callbacks=[enet_objective_callback])
print "Fitting elastic net model to random data..."
enet.fit(X, y, maxit=maxit)
print "Duality gap (should be small): %f" % \
......@@ -68,9 +72,12 @@ pl.title('Convergence')
# Demo path functions
################################################################################
alphas_lasso, weights_lasso = lasso_path(X, y, factor=0.97, n_alphas = 100)
alphas_enet, weights_enet = enet_path(X, y, factor=0.97, n_alphas = 100,
beta=0.1)
print "Computing regularization path using the lasso..."
alphas_lasso, weights_lasso = lasso_path(X, y, factor=0.93, n_alphas = 50)
print "Computing regularization path using the elastic net..."
alphas_enet, weights_enet = enet_path(X, y, factor=0.93, n_alphas = 50,
beta=0.5)
# Display results
pl.subplot(1, 2, 2)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment