matlab 向量分类,matlab – 向量的尽力分类算法

找到每个“类”的测试向量的

SSD (sum of squared differences),并使用SSD最少的那个.

这里有一些代码:我在你提供的测试向量的末尾加了一个0,因为它只有9位,而类有10位.

CLASSES = [1,0,0,0,0,0,0,0,0,0

0,0,0,0,0,0,0,0,0,1

0,1,1,1,1,1,1,1,1,0

0,1,0,0,0,0,0,0,0,0];

TEST = [0.8,0,0,0,0.6,0,0.1,0,0,0];

% Find the difference between the TEST vector and each row in CLASSES

difference = bsxfun(@minus,CLASSES,TEST);

% Class differences

class_diff = sum(difference.^2,2);

% Store the row index of the vector with the minimum difference from TEST

[val CLASS_ID] = min(class_diff);

% Display

disp(CLASSES(CLASS_ID,:))

为了便于说明,差异如下所示:

0.2 0 0 0 -0.6 0 -0.1 0 0 0

-0.8 0 0 0 -0.6 0 -0.1 0 0 1

-0.8 1 1 1 0.4 1 0.9 1 1 0

-0.8 1 0 0 -0.6 0 -0.1 0 0 0

并且每个类与TEST的距离如下所示,class_diff:

0.41

2.01

7.61

2.01

显然,第一个是最佳匹配,因为它具有最小的差异.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值