scikit-learn/scikit-learn — Issue #441: SGDClassifier can't be cloned due to rho parameter fiddling
Author: larsmans
Created: 2011-11-14 15:04:25+00:00
State: open

This is part of a traceback I got today:

File "/scratch/lars/apps/src/scikit-learn/sklearn/grid_search.py", line 346, in fit
best_estimator = clone(best_estimator)
File "/scratch/lars/apps/src/scikit-learn/sklearn/base.py", line 73, in clone
'seem to set parameter %s' % (estimator, name)
AssertionError: Cannot clone object SGDClassifier(alpha=0.001, class_weight=None, eta0=0.0, fit_intercept=True,
learning_rate=optimal, loss=hinge, n_iter=20, n_jobs=1, penalty=l2,
power_t=0.5, rho=0.85, seed=0, shuffle=False, verbose=0), as the constructor does not seem to set parameter rho

This seems to be caused by `BaseSGD._set_penalty_type`, which resets `self.rho`, when L1 or L2 (as opposed to e-net) penalties are used. I'm not sure what would be the proper fix. My workaround is to always use an e-net penalty.