2、根据身高、体重、鞋子尺码预测性别现有如下数据前三列为对应的特征数据最后一列为对应的性别标签。1706541‘男’1665538‘女’1778039‘女’1798043‘男’1706040‘女’1706038‘女’现有特征数据1767138‘?’试利用KNN计算改组数据对应的性别。要求:绘制示意图和流程图
示意图:
+-----------+
+---->| Train |
| | Data |
| +-----------+
| ▲
| |
| +-----------+
| | Test |
+-----| Data |
+-----------+
▲
|
+-----------+
| KNN |
+-----------+
▲
|
+-----------+
| Result |
+-----------+
流程图:
start
load train data
load test data
for each test data do:
calculate distance to all train data
sort distances in ascending order
select k nearest neighbors
predict label based on majority vote of neighbors
display results
end
``
原文地址: https://www.cveoy.top/t/topic/fHlG 著作权归作者所有。请勿转载和采集!