📝个人主页:研学社的博客
💥💥💞💞欢迎来到本博客❤️❤️💥💥
🏆博主优势:🌞🌞🌞博客内容尽量做到思维缜密,逻辑清晰,为了方便读者。
⛳️座右铭:行百里者,半于九十。
目录
💥1 概述
聚类属于无监督学习算法,依据某个或者多个相似度准则,使处于同一类的数据具有更高相似性,处于不同类的数据具有更大的差异性.聚类算法在大数据'数据挖掘.、社交网络、离群值检测[、计算机视觉[5]、模式识别[6]、图像处理[78]以及生物信息学[]等领域应用广泛.近年来,学者们提出了大量聚类算法.均值漂移[10]( Meanshift)算法作为一种爬山算法,算法核心为顺着密度增加的方向找到聚簇点.DBSCAN[ ]算法是一种基于密度的聚类算法,善于处理多种形状分布的数据集.APl 1聚类算法的核心思想是将所有的目标数据作为潜在聚类中心,通过计算所有数据点之间的相似度关系来构建矩阵,进而获得各样本的聚类中心.
📚2 运行结果
部分代码:
% A plot of decision boundaries from two features of the dataset
%%
clear; clc; close all; addpath(genpath('utils'));
%% experiment setup
n_repetition = 1; % quantidade de realiza莽玫es
dataset_names = {'iris'}; % conjuntos de dados
%% dataset loop
for i=1:length(dataset_names)
dataset_name = dataset_names{i};
load(sprintf('../dataset/classification/%s.mat', dataset_name))
%% experiment loop
for j=1:n_repetition
%% load/shuffle/divide/normalize dataset
data = dataset(i);
combinations = combnk(1:size(data.x_train,2),2);
for k=1:size(combinations,1)
% get patterns with two attributes
x_train = data.x_train(:,combinations(k,:));
%% train
model = dmc_train(data.x_train, data.y_train);
%% plot decision surface
x_min = min(x_train);
x_max = max(x_train);
[x, y] = meshgrid(linspace(x_min(1), x_max(1)), linspace(x_min(2),x_max(2)));
image_size = size(x);
xy = [x(:) y(:)];
y_hat = dmc_predict(model(:,combinations(k,:)), xy);
decisionmap = reshape(y_hat, image_size);
figure,
img = imagesc([x_min(1) x_max(1)],[x_min(2) x_max(2)],decisionmap);
hold on;
set(gca,'ydir','normal');
cmap = [1 0.8 0.8; 0.95 1 0.95; 0.9 0.9 1];
colormap(cmap);
[~,y_test_n] = max(data.y_train,[],2);
plot(x_train(y_test_n == 1, 1),x_train(y_test_n == 1, 2),'r*');
plot(x_train(y_test_n == 2, 1),x_train(y_test_n == 2, 2),'g*');
plot(x_train(y_test_n == 3, 1),x_train(y_test_n == 3, 2),'b*');
legend({'class 1', 'class 2', 'class 3'});
title(upper(dataset_names{i}));
xlabel(sprintf('feature %d', combinations(k,1)));
ylabel(sprintf('feature %d', combinations(k,2)));
hold off;
end
end
end
🎉3 参考文献
部分理论来源于网络,如有侵权请联系删除。