return coefficients from Pipeline object in sklearn
I think this should work:
sgd_randomized_pipe.named_steps['clf'].coef_
I've found one way to do this is by chained indexing with the steps
attribute...
sgd_randomized_pipe.best_estimator_.steps[1][1].coef_
Is this best practice, or is there another way?
You can always use the names you assigned to them while making the pipeline by using the named_steps
dict.
scaler = sgd_randomized_pipe.best_estimator_.named_steps['scl']
classifier = sgd_randomized_pipe.best_estimator_.named_steps['clf']
and then access all the attributes like coef_
, intercept_
etc. which are available to corresponding fitted estimator.
This is the formal attribute exposed by the Pipeline as specified in the documentation:
named_steps : dict
Read-only attribute to access any step parameter by user given name. Keys are step names and values are steps parameters.