Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the parameters for sklearn's score function?

I recently looked at a bunch of sklearn tutorials, which were all similar in that they scored the goodness of fit by:

clf.fit(X_train, y_train) clf.score(X_test, y_test) 

And it'll spit out:

0.92345... 

or some other score.

I am curious as to the parameters of the clf.score function or how it scores the model. I looked all over the internet, but can't seem to find documentation for it. Does anyone know?

like image 877
tooty44 Avatar asked Jun 27 '14 17:06

tooty44


People also ask

What is a scoring parameter?

Scoring parameters are used when referencing scoring configurations to generate scores. The dataset parameter. The dataset parameter specifies the location of a SQL definition that will be used for batch scoring.

What does score function do in sklearn?

In multilabel classification, this function computes subset accuracy: the set of labels predicted for a sample must exactly match the corresponding set of labels in y_true. Parameters: y_true : 1d array-like, or label indicator array / sparse matrix Ground truth (correct) labels.

How does model scoring work?

A model scoring is an AI Studio operator that stores the value predicted by a supervised learning model for the objective field, i.e., the field you want to predict. When you make a prediction in AI Studio, the model returns the predicted value along with a performance measure.

What is score method in linear regression?

Linear Regression Scoring: This type of scoring is performed by implementing linear regression algorithm on the random sample of data. The process includes scoring techniques on variables that have linear dependencies.


1 Answers

It takes a feature matrix X_test and the expected target values y_test. Predictions for X_test are compared with y_test and either accuracy (for classifiers) or R² score (for regression estimators is returned.

This is stated very explicitly in the docstrings for score methods. The one for classification reads

Returns the mean accuracy on the given test data and labels.  Parameters ---------- X : array-like, shape = (n_samples, n_features)     Test samples.  y : array-like, shape = (n_samples,)     True labels for X.  sample_weight : array-like, shape = [n_samples], optional     Sample weights.  Returns ------- score : float     Mean accuracy of self.predict(X) wrt. y. 

and the one for regression is similar.

like image 174
Fred Foo Avatar answered Sep 27 '22 01:09

Fred Foo