I am using cross_val_score function with LeaveOneOut function as my data has 60 samples.
I am confused on how cross_val_score computes the results for each estimation in Leave One Out cross validation (LOOCV).
In the LOOCV, for one instance, it fits, let's say Decision Trees Classifier (DTC), model using 59 samples for training and predicts the single remaining one.
Then the main question is this: Does it fit a new model at each instance (namely 60 different fits) inside cross_val_score?
If so, things get confusing.
Then I can have an average accuracy (out of 60) score for performance evaluation. But I need to come up with a best DTC model in general not just for my own data, though it is based my data.
If I use the entire data, the it fits perfectly but that model simply over-fits.
I want to have a single DTC model that works best in general based on my data.
Here is my code if that make sense:
model = DecisionTreeClassifier(random_state=27, criterion='gini', max_depth=4, max_features='auto' )
loocv = LeaveOneOut()
results = cross_val_score(model, X, y, cv=loocv)