• 大小: 3KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-04-19
  • 语言: Matlab
  • 标签: 不平衡  kernel  ELM  

资源简介

基于极限学习机的不平衡数据集分类,性能极好,且速度较快

资源截图

代码片段和文件信息

function [TestingAccuracytest_gmean] = Simplified_LSSVM(TrainingData_File TestingData_Filesigma2C)
%%%%%%%%%%% Load training file
TrainDataArray = load (TrainingData_File);
T = TrainDataArray(:size(TrainDataArray2));
Y = TrainDataArray(:1:size(TrainDataArray2) - 1);

train_data = [T Y];
clear TrainDataArray;   
%%%%%%%%%%% Load testing file
TestDataArray = load (TestingData_File);
T = TestDataArray(:size(TestDataArray2));
Y = TestDataArray(:1:size(TestDataArray2) - 1);
test_data = [T Y];
clear TestDataArray;   


%%%%%%%%%%% Load training dataset
%train_data = load(TrainingData_File);
T=train_data(:1)‘;
P=train_data(:2:size(train_data2))‘;
clear train_data;                                   %   Release raw training data array

%%%%%%%%%%% Load testing dataset
%test_data = load( TestingData_File );
TV.T=test_data(:1)‘;
TV.P=test_data(:2:size(test_data2))‘;
clear test_data;                                    %   Release raw testing data array

NumberofTrainingData=size(P2);
NumberofTestingData=size(TV.P2);
%NumberofInputNeurons=size(P1);

%%%%%%%%%%%% Preprocessing the data of classification
    sorted_target=sort(cat(2TTV.T)2);
    label=zeros(11);                               %   Find and save in ‘label‘ class label from training and testing data sets
    label(11)=sorted_target(11);
    j=1;
    for i = 2:(NumberofTrainingData+NumberofTestingData)
        if sorted_target(1i) ~= label(1j)
            j=j+1;
            label(1j) = sorted_target(1i);
        end
    end
    number_class = j;
    NumberofOutputNeurons = number_class;
%%%%%%%%%% Processing the targets of training
    temp_T=zeros(NumberofOutputNeurons NumberofTrainingData);
    for i = 1:NumberofTrainingData
        for j = 1:number_class
            if label(1j) == T(1i)
                break; 
            end
        end
        temp_T(ji)=1;
    end
    T = temp_T * 2 - 1;

%%%%%%%%%% Processing the targets of testing
    temp_TV_T=zeros(NumberofOutputNeurons NumberofTestingData);
    for i = 1:NumberofTestingData
        for j = 1:number_class
            if label(1j) == TV.T(1i)
                break; 
            end
        end
        temp_TV_T(ji)=1;
    end
TV.T = temp_TV_T * 2 - 1;
                                              %   end if of Elm_Typ
%%%%%%%%%%% Calculate weights & biases
% start_time_train=cputime;
tic;
n = size(T2);
Omega_train = kernel_matrix(P‘‘RBF_kernel‘ sigma2);


%OutputWeight = ( ( W * Omega_train + speye(n)/C ) \ ( W * T‘ ) ); 
OutputWeight = ( ( Omega_train + speye(n)/C ) \ (  T‘ ) ); 

 %OutputWeight=mtimesx(H((mtimesx(H‘H)+speye(n)/C)\T‘)); 
 %OutputWeight=inv(H * H‘) * H * T‘;                         % faster implementation
% end_time_train=cputime;
% TrainingTime=end_time_train-start_time_train     ;   %   Calculate CPU time (seconds) spent for training ELM
%TrainingTime=toc;
%%%%%%%%%%% Calculate the training accu

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       2536  2013-06-24 09:37  kernel_matrix.m

     文件       1325  2013-06-28 13:42  TEST_kernel_imbalance.m

     文件        899  2013-06-26 19:15  TestELM_kernel.m

     文件       4896  2013-06-28 09:53  ELM_kernel.m

----------- ---------  ---------- -----  ----

                 9656                    4


评论

共有 条评论