[scikit-learn] Issue regarding Feature Union
Guillaume Lemaître
g.lemaitre58 at gmail.com
Thu May 6 07:55:03 EDT 2021
you can get the pipeline (with optimized hyperparameters) using
grid_search.best_estimator_. Applying the code of Chris on this estimator
will work.
On Thu, 6 May 2021 at 13:45, mitali katoch <mitalikatoch at gmail.com> wrote:
> 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
>>
> _______________________________________________
> scikit-learn mailing list
> scikit-learn at python.org
> https://mail.python.org/mailman/listinfo/scikit-learn
>
--
Guillaume Lemaitre
Scikit-learn @ Inria Foundation
https://glemaitre.github.io/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.python.org/pipermail/scikit-learn/attachments/20210506/c45f7e72/attachment-0001.html>
More information about the scikit-learn
mailing list