Commit 84c96812 authored by ideepblue's avatar ideepblue

Initial commit

parents

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.
classdef GenerateData
%GENERATEDATA 此处显示有关此类的摘要
% 此处显示详细说明
properties
end
methods(Static)
[datas, labels, labels_no_noise, decision] = SEA(blockSize, noiseLevel)
[datas, labels, labels_no_noise, decision] = SEA_sp(nWin, noiseLevel)
[datas, labels, labels_no_noise, decision] = SEA_sp_2d(nWin, noiseLevel)
[datas, labels, labels_no_noise, decision] = hyperplane(varargin)
[datas, labels, labels_no_noise, decision] = hyperplane_sp(varargin)
[datas, labels, labels_no_noise, decision] = hyperplane_bound(varargin)
[datas, labels, labels_no_noise, decision] = hyperplane_bound_seq(varargin)
[datas, labels, labels_no_noise, decision] = hyperplane_hulten(varargin)
end
end
\ No newline at end of file
function [datas, labels, labels_no_noise, decision] = SEA(blockSize, noiseLevel)
[datas, labels, labels_no_noise] = generate(blockSize, noiseLevel);
decisionBoundary = @(X,A) sum(X{:}.*[1 1 0]) < A;
A = [8 9 7 9.5];
decision.func = decisionBoundary;
decision.A = A;
end
function [I, L, L_no_noise] = generate(blockSize, noiseLevel)
condition = [8 9 7 9.5];
block = 4;
I = zeros(block * blockSize, 3);
L = zeros(block * blockSize, 1);
L_no_noise = zeros(block * blockSize, 1);
for i = 1:block
idx = (i-1)*blockSize+1:i*blockSize;
ins = unifrnd(0,10, blockSize, 3);
I(idx, :) = ins;
% noise = makeBoundaryNoise(blockSize, noiseLevel);
% c = condition(i) + noise;
c = condition(i);
label = (ins(:,1) + ins(:,2)) < c;
label_noise = makeNoise(label, noiseLevel);
L(idx, :) = label_noise;
L_no_noise(idx, :) = label;
end
end
function label = makeNoise(label, noiseLevel)
blockSize = size(label,1);
idx = randperm(blockSize, floor(blockSize * noiseLevel));
C1 = (label(idx) == 1);
C0 = (label(idx) == 0);
label(idx(C1)) = 0;
label(idx(C0)) = 1;
end
function [datas, labels, labels_no_noise, decision] = SEA_2d_px_change(nWin, noiseLevel)
decisionBoundary = @(X,A) sum(X{:}.*[1 1]) < A;
% A = [7 7 7.1 7.2 7.5 8 8.5 9 9.5 10];
A = [7 8 8 8 8 8 8 8 8 8 8];
decision.func = decisionBoundary;
decision.A = A;
dataA = unifrnd(0, 10, nWin, 2);
dataAcell = mat2cell(dataA, ones(1,nWin), 2);
datas = zeros(nWin * length(A), 2);
labels = zeros(nWin * length(A), 1);
labels_no_noise = zeros(nWin * length(A), 1);
datas(1:nWin,:) = dataA;
labels_no_noise(1:nWin) = arrayfun(decision.func, dataAcell, repmat(decision.A(1), nWin, 1));
labels(1:nWin) = makeNoise(labels_no_noise(1:nWin), noiseLevel);
for i = 2:length(A)
idxs = ( i - 1 ) * nWin + 1:i * nWin;
dataB = unifrnd(0, 10, nWin, 2);
dataBcell = mat2cell(dataB, ones(1,nWin), 2);
datas(idxs,:) = dataB;
labels_no_noise(idxs) = arrayfun(decision.func, dataBcell, repmat(decision.A(i), nWin, 1));
labels(idxs) = makeNoise(labels_no_noise(idxs), noiseLevel);
end
filename = 'SEA_2d_px_change.mat';
path = [Utility.cdToMatlabHome(false) filesep 'datasets' filesep 'CDDE' filesep] ;
save([path filename], 'decision', 'datas', 'labels', 'labels_no_noise', 'noiseLevel', 'nWin');
end
function label = makeNoise(label, noiseLevel)
blockSize = size(label,1);
idx = randperm(blockSize, floor(blockSize * noiseLevel));
label(idx) = ~label(idx);
end
function [datas, labels, labels_no_noise, decision] = SEA_px_change(nWin, noiseLevel)
decisionBoundary = @(X,A) sum(X{:}.*[1 1 0]) < A;
A = [8 9 7 9.5];
Offset = [2 -2 0; 0 0 0; 2 -2 0];
decision.func = decisionBoundary;