Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what's the use of transformer_weights in scikit-learn pipeline?

It's just a little question of scikit-learn's pipeline.

In the class sklearn.pipeline.FeatureUnion , there is a transformer_weights option .

transformer_weights: dict, optional
: Multiplicative weights for features per transformer. Keys are transformer names, values the weights.

I saw the use in an example that give different weight to different feature.

    transformer_weights={
        'subject': 0.8,
        'body_bow': 0.5,
        'body_stats': 1.0,
    },

It's nonsense to me, because the classifier will learn the weighting for you later. Why bother using it at all?

like image 745
WeiChing 林煒清 Avatar asked Apr 08 '15 01:04

WeiChing 林煒清


1 Answers

If you use a linear classifier with penalty, this will change the amount of penalty applied to each block of features. Scaling features up will mean they will be less penalized relative to the other features.

like image 61
Andreas Mueller Avatar answered Nov 01 '22 05:11

Andreas Mueller