-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fcee590
commit b47112e
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
%%% | ||
% NGPCA: Clustering high-dimensional and non-stationary data streams | ||
% Please cite this code using the following DOI: https://doi.org/10.1016/j.patcog.2023.110030 | ||
%%% | ||
|
||
%% | ||
clear variables | ||
close all | ||
addpath('ngpca', 'data'); | ||
% Reproducability | ||
rng(0) | ||
|
||
%% Load the ring-line-square and vortex data sets | ||
load rls.mat -ASCII; | ||
vortex = vortex(6*pi, 120, 20, 4000); | ||
|
||
%% | ||
% Create an NGPCA object with hard-clustering. Set the data vector to the | ||
% rls data initialize the units. Start the training processes and swap the | ||
% distribution towards the vortex mid training | ||
ngpca = NGPCA('softhard', 1); | ||
figure; | ||
data = rls; | ||
scatter(data(:,1), data(:,2),5,'o','MarkerFaceAlpha',.2,'MarkerEdgeAlpha',.2); | ||
hold on; | ||
axis equal; | ||
axis manual; | ||
ngpca = init_units(ngpca, data, 19, 'iterations', 40000, 'PCADimensionality', 2); | ||
for i = 1:ngpca.iterations | ||
% Sample a random data point in each iteration | ||
ngpca = fit_single(ngpca, data(ceil(size(data,1) .* rand), :)); | ||
% Needed to overwrite the ngpca object if plotted in a loop to delete | ||
% units from previous plot | ||
if mod(i,100) == 0 | ||
ngpca = ngpca.draw(); | ||
end | ||
if i == 20000 | ||
data = vortex; | ||
scatter(data(:,1), data(:,2),5,'o','MarkerFaceAlpha',.2,'MarkerEdgeAlpha',.2); | ||
end | ||
end |
Binary file not shown.