Skip to content

Instantly share code, notes, and snippets.

@MechCoder
Last active August 29, 2015 14:03
Show Gist options
  • Save MechCoder/ca1cd4bd032f1f0394af to your computer and use it in GitHub Desktop.
Save MechCoder/ca1cd4bd032f1f0394af to your computer and use it in GitHub Desktop.
Random vs non_random
from sklearn.linear_model import *
from sklearn.datasets import *
X, y = load_svmlight_file("/home/manoj/Downloads/duke")
# Get the best alpha, l1_ratio combination first
clf = ElasticNetCV(max_iter=10000, n_jobs=-1)
clf.fit(X, y)
clf_random = ElasticNet(alpha=clf.alpha_, l1_ratio=clf.l1_ratio_, max_iter=50000, tol=0, random_state=42)
clf_random.fit(X.toarray(), y)
clf_random = ElasticNet(alpha=clf.alpha_, l1_ratio=clf.l1_ratio_, max_iter=50000, tol=0)
clf_random.fit(X.toarray(), y)
clf_random = ElasticNet(alpha=clf.alpha_, l1_ratio=clf.l1_ratio_, max_iter=10000, tol=0, random_state=42)
clf_random.fit(X.toarray(), y)
clf_random = ElasticNet(alpha=clf.alpha_, l1_ratio=clf.l1_ratio_, max_iter=10000, tol=0)
clf_random.fit(X.toarray(), y)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment