Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

scikit learn - What's the default score function in validation_curve in sklearn?

I'm running the following line of code:

validation_curve(PolynomialRegression(),X,y,
                 param_name='polynomialfeatures__degree',
                 param_range=degree,cv=7)

And, when I draw the validation_curve I get very negative scores for higher degrees. When I checked the documentation, it stated

scoring:str or callable, default=None A str (see model evaluation documentation) or a scorer callable object / function with signature scorer(estimator, X, y).

I'm just wondering what is the default score function in validation_curve in sklearn? If it's None, then how can they compute a score?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

It defaults to the score method of the estimator, which in turn is often either accuracy (classification) or R2 (regression).

In the source for validation_curve, it calls check_scorer, which in part contains:

    elif scoring is None:
        if hasattr(estimator, 'score'):
            return _passthrough_scorer

where _passthrough_scorer just wraps the estimator's score:

def _passthrough_scorer(estimator, *args, **kwargs):
    """Function that wraps estimator.score"""
    return estimator.score(*args, **kwargs)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...