svc.score is giving the result 1.0 while cross val score is giving mein 44 % accuracy. What is the difference between the two?
Difference between svc.score and cross_val_score
Hey @raunaqsingh10, svc.score() computes the score, by taking both input parameters and output as input. So when you pass xtrain, ytrain than svc.score will give you trainine accuracy, which comes out to be 1.0. You may also pass xtest and ytest after splitting training data using sklearn’s train_test_split. Than the score would be validation score. Cross validation score is nearly same as validation score. Its test your model on the points on which it is not trained. Scuh a huge difference between training and validation accuracy suggests that model is overfitted.
Hope this cleared your doubt.
Ok that means svc.fit(x,y) overfits the data completely and therefore we get 1 by svc.score(x,y)
Yes you have passes x_train and Y_train which gives training accuracy to be 100%. (or 1) which is way much different from validation accuracy and hence it is overfitted.
Ok. But now when i do svc.fit(x_train,y_train) and svc.score(x_test,y_test) the model will overfit on x_train and y_train and then obviously the score will always come less.
The score is a function that just gives the accuracy, it has nothing to do with training. When you pass xtrain and ytrain it just predicts accuracy, which we know that is training accuracy. Say its comes out to be x%. Now we pass xtest and ytest which are not part on which svc object was trained. It makes its predictions and than calculate the accuracy which comes out to be y%. Now if difference between x and y is less than the model is goog. If difference is quite large like 100 and 48 in this case. Than we conclude that model has overfitted.
Understood completely sir. Thank you.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.