[scikit-learn] Issue regarding Feature Union

mitali katoch mitalikatoch at gmail.com
Thu May 6 07:42:59 EDT 2021


Hi Chris,
I forgot to mention that this pipeline I have used within the GridSearchCV.
I have done what you suggested early but didn't work, it said:
'GridSearchCV' object has no attribute 'named_steps'.

I somehow figured out now
Thanks for your help though.

Best regards,
Mitali Katoch

On Thu, May 6, 2021, 12:47 Chris Aridas <chris at aridas.eu> wrote:

> Hi,
>
> Assuming that you have trained your pipeline, the following piece of code should work.
>
>
> pipeline.named_steps["feature_sel"].transform(X)
>
> Best,
> Chris
>
> On Thu, May 6, 2021 at 12:52 PM mitali katoch <mitalikatoch at gmail.com>
> wrote:
>
>>   Dear Scikit team,
>>
>> I am working with FeatureUnion in the pipeline and best parameters are as
>> follows:
>> Pipeline(steps=[('feature_sel',
>>                  FeatureUnion(transformer_list= [ ('selectk',
>> SelectKBest(k=500)),
>>                                                 ('sel_fromModel',
>>
>>  SelectFromModel(estimator=LogisticRegression(C=1,
>>
>>                     penalty='l1',
>>
>>                     solver='liblinear'),
>>
>>  max_features=100))]
>> )),
>>                 ('sampler', SMOTE(k_neighbors=2, random_state=10)),
>>                 ('model', SVC(random_state=10))]
>> )
>>
>> I would like to extract those SelectKBest(k=500) and max_features=100
>> from the pipeline.
>>
>> Could you please confirm whether it is possible to do it, If yes, could
>> you share the solution, I would highly appreciate that.
>>
>> Thanks in advance.
>>
>> Best Regards,
>> Mitali Katoch
>>
>> _______________________________________________
>> scikit-learn mailing list
>> scikit-learn at python.org
>> https://mail.python.org/mailman/listinfo/scikit-learn
>>
> _______________________________________________
> scikit-learn mailing list
> scikit-learn at python.org
> https://mail.python.org/mailman/listinfo/scikit-learn
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.python.org/pipermail/scikit-learn/attachments/20210506/77dc3d91/attachment.html>


More information about the scikit-learn mailing list