A clinic wants the best neighbour settings for a tumour classifier, chosen honestly: by cross-validation on the training rows, with the test rows opened only once at the end.
Task: write search_neighbours(neighbour_counts, weightings).
load_breast_cancer(return_X_y=True, as_frame=True).train_test_split(X, y, test_size=0.25, random_state=0, stratify=y).GridSearchCV over make_pipeline(StandardScaler(), KNeighborsClassifier()) with cv=5. Search every combination of neighbour_counts for the neighbour count and weightings for the weights setting.Return a dict:
"best": the search's best_params_, exactly as scikit-learn gives it,"cv": the best cross-validated score, rounded to 4 decimal places,"test": the refitted winner's accuracy on the test rows, rounded to 4 decimal places,"fits": how many models the search trained during cross-validation (combinations × folds), as a whole number.