You need to do:
min_f_scorer = make_scorer(f1_score, pos_label=1)

See the example here:
http://scikit-learn.org/dev/modules/generated/sklearn.metrics.make_scorer.html#sklearn.metrics.make_scorer
and
http://scikit-learn.org/dev/modules/model_evaluation.html#defining-your-scoring-strategy-from-metric-functions

Hth,
Andy


On 05/17/2015 11:54 AM, Adam Goodkind wrote:
Hi Andy,

I'm following up on this from a while ago, because I finally got around to trying to implement it.

To get the minority f1 score from my grid search, I have:
min_f_scorer = make_scorer(f1_score(pos_label=1))
grid_search = GridSearchCV(pipeline, parameters, verbose=1, cv=3, scoring=min_f1_scorer)

But the f1_score() constructor needs the y_true and y_pred arrays, right? I'm not sure what I'm doing wrong, since it would only have y_pred after the classifier was run.

Thanks again,
Adam

On Fri, May 8, 2015 at 12:39 PM, Andreas Mueller <t3k...@gmail.com <mailto:t3k...@gmail.com>> wrote:

    Hi Adam.
    You can get the f_score by setting ``GridSearchCV(...,
    scoring='f1_score')``.
    By default, the "positive" class if the one labeled "1":
    
http://scikit-learn.org/dev/modules/generated/sklearn.metrics.f1_score.html#sklearn.metrics.f1_score

    If you want more control, you can do
    my_f_scoring = make_scorer(f1_score, pos_label="minority_label",
    other_arguments=that_you_want)
    GridSearchCV(..., scoring=my_f_scoring)

    You can not compute accuracy and f1 score at the same time,
    though, which is a known limitation, which we will fix soon.

    Cheers,
    Andy



    On 05/08/2015 11:57 AM, Adam Goodkind wrote:
    In performing a grid search, I know we can get overall accuracy,
    but I'm also interested in the minority F score. Is there a way
    to get that for each parameter setting combination?

    Thanks,
    Adam

-- *Adam Goodkind *
    adamgoodkind.com <http://www.adamgoodkind.com>
    @adamgreatkind <https://twitter.com/#%21/adamgreatkind>


    
------------------------------------------------------------------------------
    One dashboard for servers and applications across Physical-Virtual-Cloud
    Widest out-of-the-box monitoring support with 50+ applications
    Performance metrics, stats and reports that give you Actionable Insights
    Deep dive visibility with transaction tracing using APM Insight.
    http://ad.doubleclick.net/ddm/clk/290420510;117567292;y


    _______________________________________________
    Scikit-learn-general mailing list
    Scikit-learn-general@lists.sourceforge.net  
<mailto:Scikit-learn-general@lists.sourceforge.net>
    https://lists.sourceforge.net/lists/listinfo/scikit-learn-general


    
------------------------------------------------------------------------------
    One dashboard for servers and applications across
    Physical-Virtual-Cloud
    Widest out-of-the-box monitoring support with 50+ applications
    Performance metrics, stats and reports that give you Actionable
    Insights
    Deep dive visibility with transaction tracing using APM Insight.
    http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
    _______________________________________________
    Scikit-learn-general mailing list
    Scikit-learn-general@lists.sourceforge.net
    <mailto:Scikit-learn-general@lists.sourceforge.net>
    https://lists.sourceforge.net/lists/listinfo/scikit-learn-general




--
*Adam Goodkind *
adamgoodkind.com <http://www.adamgoodkind.com>
@adamgreatkind <https://twitter.com/#%21/adamgreatkind>


------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y


_______________________________________________
Scikit-learn-general mailing list
Scikit-learn-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general

------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Scikit-learn-general mailing list
Scikit-learn-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general

Reply via email to