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

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!

主站蜘蛛池模板: 高州市| 苍梧县| 当雄县| 上杭县| 建德市| 海阳市| 镇赉县| 襄樊市| 阿巴嘎旗| 吴江市| 满洲里市| 伽师县| 怀化市| 徐州市| 青河县| 改则县| 钟祥市| 连山| 永兴县| 盘锦市| 鹤峰县| 通河县| 托里县| 漠河县| 华安县| 武宣县| 靖州| 体育| 杭锦旗| 八宿县| 德钦县| 柳河县| 大方县| 广州市| 永川市| 台安县| 凤凰县| 渑池县| 正阳县| 江陵县| 安达市|