官术网_书友最值得收藏!

Putting it all together

We can now create a workflow by combining the code from the previous sections, using the broken dataset previously calculated:

X_transformed = MinMaxScaler().fit_transform(X_broken) 
estimator = KNeighborsClassifier()
transformed_scores = cross_val_score(estimator, X_transformed, y, scoring='accuracy')
print("The average accuracy for is {0:.1f}%".format(np.mean(transformed_scores) * 100))

We now recover our original score of 82.3 percent accuracy. The MinMaxScaler resulted in features of the same scale, meaning that no features overpowered others by simply being bigger values. While the Nearest Neighbor algorithm can be confused with larger features, some algorithms handle scale differences better. In contrast, some are much worse!

主站蜘蛛池模板: 濉溪县| 清河县| 昌江| 岐山县| 晋江市| 河源市| 绥滨县| 巴塘县| 满洲里市| 文山县| 乌审旗| 福建省| 邹城市| 凤翔县| 务川| 洞口县| 浪卡子县| 东至县| 静乐县| 南木林县| 耒阳市| 齐河县| 洛隆县| 阜康市| 柘荣县| 保亭| 仪陇县| 海南省| 望城县| 佛冈县| 吴桥县| 鹿泉市| 平泉县| 屯昌县| 闸北区| 海林市| 河北区| 隆子县| 大丰市| 临洮县| 邳州市|