Preview:
# GOOD!
scores = []
select = SelectPercentile(percentile=5)
for train, test in KFold().split(X, y):
    select.fit(X[train], y[train])
    X_sel_train = select.transform(X[train])
    knn = KNeighborsClassifier().fit(X_sel_train, y[train])
    X_sel_test = select.transform(X[test])
    score = knn.score(X_sel_test, y[test])
    scores.append(score)
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter