but as we learned in the previous we will not do it just oncebut apply cross-validation here using the ready-made kfold class from sklearn cross_ validation finallywe will average the scores on the test set of each fold and see how much it varies using standard deviation refer to the following codefrom sklearn cross_validation import kfold scores [cv kfold( =len( ) = indices=truefor traintest in cvx_trainy_train [train] [trainx_testy_test [test] [testclf neighbors kneighborsclassifier(clf fit(xyscores append(clf score(x_testy_test)print("mean(scores)= \tstddev(scores)= "%(np mean(scoresnp std(scores))the output is as followsmean(scores)= stddev(scores)= this is far from being usable with only percent accuracyit is even worse than tossing coin apparentlythe number of links in post are not very good indicator of the quality of the post we say that this feature does not have much discriminative power--at leastnot for knn with designing more features in addition to using number of hyperlinks as proxies for post' qualityusing number of code lines is possibly another good option too at least it is good indicator that the post' author is interested in answering the question we can find the code embedded in the tag once we have extracted itwe should count the number of words in the post while ignoring the code linesdef extract_features_from_body( )num_code_lines link_count_in_code code_free_s remove source code and count how many lines for match_str in code_match findall( )num_code_lines +match_str count('\ 'code_free_s code_match sub(""code_free_ssometimes source code contain links