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

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!

主站蜘蛛池模板: 吐鲁番市| 沙田区| 本溪市| 宜君县| 东海县| 潜江市| 荣昌县| 茂名市| 荥阳市| 岑巩县| 龙里县| 中超| 东兰县| 凯里市| 信宜市| 綦江县| 宁陵县| 修武县| 南康市| 溧水县| 遂昌县| 庆安县| 志丹县| 武胜县| 龙南县| 山西省| 富民县| 青田县| 朝阳区| 遵义县| 陈巴尔虎旗| 浦江县| 维西| 衡南县| 康保县| 泌阳县| 邯郸县| 邯郸县| 普兰店市| 隆昌县| 井陉县|