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

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!

主站蜘蛛池模板: 陆良县| 黄梅县| 盐津县| 临沂市| 获嘉县| 潍坊市| 云霄县| 安图县| 盖州市| 昌平区| 个旧市| 大冶市| 新巴尔虎右旗| 儋州市| 南昌市| 宕昌县| 米易县| 兰西县| 浪卡子县| 苍山县| 内江市| 乌鲁木齐市| 绍兴市| 广州市| 新竹市| 临湘市| 永寿县| 河西区| 汾阳市| 灌南县| 高阳县| 临武县| 商城县| 安陆市| 十堰市| 渑池县| 舞钢市| 郴州市| 新余市| 凤山县| 犍为县|