没有合适的资源?快使用搜索试试~ 我知道了~
鸢尾花最近邻NN代码.doc
需积分: 0 2 下载量 187 浏览量
2023-06-23
19:44:08
上传
评论 1
收藏 19KB DOC 举报
温馨提示
![preview](https://dl-preview.csdnimg.cn/87942117/0001-6436efb31793428f51c413774761df78_thumbnail-wide.jpeg)
![preview-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/scale.ab9e0183.png)
试读
2页
鸢尾花最近邻NN代码.doc 数据集基于鸢尾花,使用最近邻NN实现
资源推荐
资源详情
资源评论
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![thumb](https://img-home.csdnimg.cn/images/20210720083646.png)
![thumb](https://img-home.csdnimg.cn/images/20210720083646.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/release/download_crawler_static/87942117/bg1.jpg)
load fisheriris %载入 Matlab 自带的鸢尾属植物数据集
% 每类的前 40 个样本用于生成代表该类的模板,后 10 个作为独立的测试样本
X= meas(1:40, :) ;
Y= meas(51:90, :) ;
Z= meas(101:140, :);
m1 = mean( meas(1:40, :) );
m2 = mean( meas(51:90, :) );
m3 = mean( meas(101:140, :) );
%训练集两两特征根组合的散点图
data = ["SepalLength", "SepalWidth", "petalLength", "petalWidth"];
ans= 1:4;
com = combntns(ans, 2); %四个数据选两个排列组合,相当于 C(2,4) = 6;
for i=1:6
subplot(2, 3, i) %2*3 的图标
scatter(X(:, com(i, 1)), X(:, com(i, 2)), 'fill', 'r');
hold on
scatter(Y(:, com(i, 1)), Y(:, com(i, 2)), 'fill', 'g');
hold on
scatter(Z(:, com(i, 1)), Z(:, com(i, 2)), 'fill', 'b');
title([data(com(i,1)) + ' and ' + data(com(i, 2))]);
%标题
legend('iris-setosa', 'iris-versicolor', 'iris-virginica', 'location', 'best');
%图标
end
% 测试样本集
Test = [meas(41:50, :); meas(91:100, :); meas(141:150, :)];
% 测试样本集对应的类别标签
classLabel(1:10) = 1;
classLabel(11:20) = 2;
classLabel(21:30) = 3;
% 利用最小距离分类器分类测试样本
class = zeros(1, 30); %类标签
for ii = 1:size(Test, 1)
d(1) = norm(Test(ii, :) - m1); %与第1类的距离
d(2) = norm(Test(ii, :) - m2); %与第2类的距离
d(3) = norm(Test(ii, :) - m3); %与第3类的距离
[minVal class(ii)] = min(d); %计算最小距离并将距离样本最短的类赋给类标签数组 class
end
% 测试最小距离分类器的识别率
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/233a595e083f462ab32c33f1b2c5f0d7_qq_62033311.jpg!1)
甲予
- 粉丝: 1
- 资源: 4
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)