ValueError: 'balanced_accuracy' is not a valid scoring value in scikit-learn











up vote
1
down vote

favorite












I tried to pass to GridSearchCV other scoring metrics like balanced_accuracy for Binary Classification (instead of the default accuracy)



  scoring = ['balanced_accuracy','recall','roc_auc','f1','precision']
validator = GridSearchCV(estimator=clf, param_grid=param_grid, scoring=scoring, refit=refit_scorer, cv=cv)


and got this error




ValueError: 'balanced_accuracy' is not a valid scoring value. Valid
options are
['accuracy','adjusted_mutual_info_score','adjusted_rand_score','average_precision','completeness_score','explained_variance','f1','f1_macro','f1_micro','f1_samples','f1_weighted','fowlkes_mallows_score','homogeneity_score','mutual_info_score','neg_log_loss','neg_mean_absolute_error','neg_mean_squared_error','neg_mean_squared_log_error','neg_median_absolute_error','normalized_mutual_info_score','precision','precision_macro','precision_micro','precision_samples','precision_weighted','r2','recall','recall_macro','recall_micro','recall_samples','recall_weighted','roc_auc','v_measure_score']




This is strange because 'balanced_accuracy' should be valid
Without defining balanced_accuracy then the code works fine



    scoring = ['recall','roc_auc','f1','precision']


Also the scoring metrics in the error above seems to be different from the ones in the document



Any ideas why? Thank you so much



scikit-learn version is 0.19.2










share|improve this question




















  • 3




    Please post the relevant code - as it is, there are not enough details for the question to be answered meaningfully. Also post your scikit-learn version (you can get it with sklearn.__version__))
    – desertnaut
    Nov 17 at 8:58












  • Thank you I added the code and scikit-learn version
    – Long
    Nov 17 at 14:54















up vote
1
down vote

favorite












I tried to pass to GridSearchCV other scoring metrics like balanced_accuracy for Binary Classification (instead of the default accuracy)



  scoring = ['balanced_accuracy','recall','roc_auc','f1','precision']
validator = GridSearchCV(estimator=clf, param_grid=param_grid, scoring=scoring, refit=refit_scorer, cv=cv)


and got this error




ValueError: 'balanced_accuracy' is not a valid scoring value. Valid
options are
['accuracy','adjusted_mutual_info_score','adjusted_rand_score','average_precision','completeness_score','explained_variance','f1','f1_macro','f1_micro','f1_samples','f1_weighted','fowlkes_mallows_score','homogeneity_score','mutual_info_score','neg_log_loss','neg_mean_absolute_error','neg_mean_squared_error','neg_mean_squared_log_error','neg_median_absolute_error','normalized_mutual_info_score','precision','precision_macro','precision_micro','precision_samples','precision_weighted','r2','recall','recall_macro','recall_micro','recall_samples','recall_weighted','roc_auc','v_measure_score']




This is strange because 'balanced_accuracy' should be valid
Without defining balanced_accuracy then the code works fine



    scoring = ['recall','roc_auc','f1','precision']


Also the scoring metrics in the error above seems to be different from the ones in the document



Any ideas why? Thank you so much



scikit-learn version is 0.19.2










share|improve this question




















  • 3




    Please post the relevant code - as it is, there are not enough details for the question to be answered meaningfully. Also post your scikit-learn version (you can get it with sklearn.__version__))
    – desertnaut
    Nov 17 at 8:58












  • Thank you I added the code and scikit-learn version
    – Long
    Nov 17 at 14:54













up vote
1
down vote

favorite









up vote
1
down vote

favorite











I tried to pass to GridSearchCV other scoring metrics like balanced_accuracy for Binary Classification (instead of the default accuracy)



  scoring = ['balanced_accuracy','recall','roc_auc','f1','precision']
validator = GridSearchCV(estimator=clf, param_grid=param_grid, scoring=scoring, refit=refit_scorer, cv=cv)


and got this error




ValueError: 'balanced_accuracy' is not a valid scoring value. Valid
options are
['accuracy','adjusted_mutual_info_score','adjusted_rand_score','average_precision','completeness_score','explained_variance','f1','f1_macro','f1_micro','f1_samples','f1_weighted','fowlkes_mallows_score','homogeneity_score','mutual_info_score','neg_log_loss','neg_mean_absolute_error','neg_mean_squared_error','neg_mean_squared_log_error','neg_median_absolute_error','normalized_mutual_info_score','precision','precision_macro','precision_micro','precision_samples','precision_weighted','r2','recall','recall_macro','recall_micro','recall_samples','recall_weighted','roc_auc','v_measure_score']




This is strange because 'balanced_accuracy' should be valid
Without defining balanced_accuracy then the code works fine



    scoring = ['recall','roc_auc','f1','precision']


Also the scoring metrics in the error above seems to be different from the ones in the document



Any ideas why? Thank you so much



scikit-learn version is 0.19.2










share|improve this question















I tried to pass to GridSearchCV other scoring metrics like balanced_accuracy for Binary Classification (instead of the default accuracy)



  scoring = ['balanced_accuracy','recall','roc_auc','f1','precision']
validator = GridSearchCV(estimator=clf, param_grid=param_grid, scoring=scoring, refit=refit_scorer, cv=cv)


and got this error




ValueError: 'balanced_accuracy' is not a valid scoring value. Valid
options are
['accuracy','adjusted_mutual_info_score','adjusted_rand_score','average_precision','completeness_score','explained_variance','f1','f1_macro','f1_micro','f1_samples','f1_weighted','fowlkes_mallows_score','homogeneity_score','mutual_info_score','neg_log_loss','neg_mean_absolute_error','neg_mean_squared_error','neg_mean_squared_log_error','neg_median_absolute_error','normalized_mutual_info_score','precision','precision_macro','precision_micro','precision_samples','precision_weighted','r2','recall','recall_macro','recall_micro','recall_samples','recall_weighted','roc_auc','v_measure_score']




This is strange because 'balanced_accuracy' should be valid
Without defining balanced_accuracy then the code works fine



    scoring = ['recall','roc_auc','f1','precision']


Also the scoring metrics in the error above seems to be different from the ones in the document



Any ideas why? Thank you so much



scikit-learn version is 0.19.2







python machine-learning scikit-learn metrics






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 17 at 14:53

























asked Nov 17 at 7:54









Long

4418




4418








  • 3




    Please post the relevant code - as it is, there are not enough details for the question to be answered meaningfully. Also post your scikit-learn version (you can get it with sklearn.__version__))
    – desertnaut
    Nov 17 at 8:58












  • Thank you I added the code and scikit-learn version
    – Long
    Nov 17 at 14:54














  • 3




    Please post the relevant code - as it is, there are not enough details for the question to be answered meaningfully. Also post your scikit-learn version (you can get it with sklearn.__version__))
    – desertnaut
    Nov 17 at 8:58












  • Thank you I added the code and scikit-learn version
    – Long
    Nov 17 at 14:54








3




3




Please post the relevant code - as it is, there are not enough details for the question to be answered meaningfully. Also post your scikit-learn version (you can get it with sklearn.__version__))
– desertnaut
Nov 17 at 8:58






Please post the relevant code - as it is, there are not enough details for the question to be answered meaningfully. Also post your scikit-learn version (you can get it with sklearn.__version__))
– desertnaut
Nov 17 at 8:58














Thank you I added the code and scikit-learn version
– Long
Nov 17 at 14:54




Thank you I added the code and scikit-learn version
– Long
Nov 17 at 14:54












1 Answer
1






active

oldest

votes

















up vote
2
down vote



accepted










Update your sklearn to the latest version if you want to use balanced_accuracy. As you can see from the 0.19 documentation balanced_accuracy is not a valid scoring metric. It was added in 0.20.






share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














     

    draft saved


    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53349331%2fvalueerror-balanced-accuracy-is-not-a-valid-scoring-value-in-scikit-learn%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    2
    down vote



    accepted










    Update your sklearn to the latest version if you want to use balanced_accuracy. As you can see from the 0.19 documentation balanced_accuracy is not a valid scoring metric. It was added in 0.20.






    share|improve this answer

























      up vote
      2
      down vote



      accepted










      Update your sklearn to the latest version if you want to use balanced_accuracy. As you can see from the 0.19 documentation balanced_accuracy is not a valid scoring metric. It was added in 0.20.






      share|improve this answer























        up vote
        2
        down vote



        accepted







        up vote
        2
        down vote



        accepted






        Update your sklearn to the latest version if you want to use balanced_accuracy. As you can see from the 0.19 documentation balanced_accuracy is not a valid scoring metric. It was added in 0.20.






        share|improve this answer












        Update your sklearn to the latest version if you want to use balanced_accuracy. As you can see from the 0.19 documentation balanced_accuracy is not a valid scoring metric. It was added in 0.20.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 17 at 15:03









        Mihai Chelaru

        2,0177820




        2,0177820






























             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53349331%2fvalueerror-balanced-accuracy-is-not-a-valid-scoring-value-in-scikit-learn%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            If I really need a card on my start hand, how many mulligans make sense? [duplicate]

            Alcedinidae

            Can an atomic nucleus contain both particles and antiparticles? [duplicate]