<div dir="ltr">you can get the pipeline (with optimized hyperparameters) using grid_search.best_estimator_. Applying the code of Chris on this estimator will work.<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, 6 May 2021 at 13:45, mitali katoch <<a href="mailto:mitalikatoch@gmail.com">mitalikatoch@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto"><div>Hi <span style="font-family:sans-serif">Chris, </span></div><div dir="auto"><font face="sans-serif">I forgot to mention that this pipeline I have used within the GridSearchCV.</font></div><div dir="auto"><span style="font-family:sans-serif">I have done what you suggested early but didn't work, it said: 'GridSearchCV' object has no attribute 'named_steps'.</span></div><div dir="auto"><span style="font-family:sans-serif"><br></span></div><div dir="auto"><span style="font-family:sans-serif">I somehow figured out now</span><br></div><div dir="auto"><font face="sans-serif">Thanks for your help though.</font></div><div dir="auto"><font face="sans-serif"><br></font></div><div dir="auto"><font face="sans-serif">Best regards,</font></div><div dir="auto"><font face="sans-serif">Mitali Katoch</font></div><div dir="auto"><br><div class="gmail_quote" dir="auto"><div dir="ltr" class="gmail_attr">On Thu, May 6, 2021, 12:47 Chris Aridas <<a href="mailto:chris@aridas.eu" target="_blank">chris@aridas.eu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><pre style="margin:0px;line-height:125%">Hi,<br><br>Assuming that you have trained your pipeline, the following piece of code should work.<br></pre><pre style="margin:0px;line-height:125%"><br>pipeline.named_steps[<span style="color:rgb(163,21,21)">"feature_sel"</span>].transform(X)<br><br></pre>Best,</div><div>Chris<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, May 6, 2021 at 12:52 PM mitali katoch <<a href="mailto:mitalikatoch@gmail.com" rel="noreferrer" target="_blank">mitalikatoch@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">  Dear Scikit team,<div><br></div><div>I am working with FeatureUnion in the pipeline and best parameters are as follows:</div><div>Pipeline(steps=[('feature_sel',<br>                 FeatureUnion(transformer_list= [ ('selectk', SelectKBest(k=500)),<br>                                                ('sel_fromModel',<br>                                                 SelectFromModel(estimator=LogisticRegression(C=1,<br>                                                                                              penalty='l1',<br>                                                                                              solver='liblinear'),<br>                                                                 max_features=100))]</div><div>)),<br>                ('sampler', SMOTE(k_neighbors=2, random_state=10)),<br>                ('model', SVC(random_state=10))]</div><div>)<br></div><div><br></div><div>I would like to extract those SelectKBest(k=500) and max_features=100 from the pipeline.</div><div><br></div><div>Could you please confirm whether it is possible to do it, If yes, could you share the solution, I would highly appreciate that.</div><div><br></div><div>Thanks in advance.</div><div><br></div><div>Best Regards,</div><div>Mitali Katoch</div><div></div><div><br></div></div>
_______________________________________________<br>
scikit-learn mailing list<br>
<a href="mailto:scikit-learn@python.org" rel="noreferrer" target="_blank">scikit-learn@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/scikit-learn" rel="noreferrer noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/scikit-learn</a><br>
</blockquote></div></div>
_______________________________________________<br>
scikit-learn mailing list<br>
<a href="mailto:scikit-learn@python.org" rel="noreferrer" target="_blank">scikit-learn@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/scikit-learn" rel="noreferrer noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/scikit-learn</a><br>
</blockquote></div></div></div>
_______________________________________________<br>
scikit-learn mailing list<br>
<a href="mailto:scikit-learn@python.org" target="_blank">scikit-learn@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/scikit-learn" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/scikit-learn</a><br>
</blockquote></div><br clear="all"><br>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><span><div><div>Guillaume Lemaitre<br></div></div><div><span>Scikit-learn @ Inria Foundation</span><br><a href="https://glemaitre.github.io/" target="_blank">https://glemaitre.github.io/</a></div></span></div></div></div></div></div></div></div></div></div></div></div>