I'd normally just post this to Stack Overflow, but I thought about it and realised it's not actually a coding question - it's an ML question.
Any other feedback on code or anything else is thoroughly appreciated and welcomed!
So I'm doing the titanic problem on Kaggle. I have my four datasets ready to go:
- features_train
- features_test
- target_train
- target_test
With this in mind, I have two questions, though the second one is the important one.
Question 1: Is my understanding of the next step correct?
We fit our model on the training data, then we create a prediction (pred) which tries to predict based off our features_test data. This means that our pred and target_test datasets should in theory be the same (if the model worked perfectly).
This means that to attest to the accuracy of the model, we can simply compare the results between pred and target_test, which is what the accuracy_score function does from Sklearn.
Question 2: What's the difference between using the score method of the model, vs the accuracy_score function?
This is what's confusing me. You can see in cell 97, the first cell under the "Model 1" header, that I use:
clf.score(features_test, target_test)
This comes out with a result of
0.8609865470852018
However, later, I also use:
from sklearn.metrics import accuracy_score
print(accuracy_score(target_test, pred))
And this also results in
0.8609865470852018
How are both of these scores the same? Have I done something wrong? Or are both of these steps basically doing the same thing? How..? Is the score() property effectively creating a pred Dataframe and checking against that in the background?