# 1. 极限学习机简介

ELM是一类基于前馈神经网络（Feedforward Neuron Network, FNN）构建的机器学习方法，适用于监督学习和非监督学习问题，其特点是隐含层节点的权重为随机或人为给定的，且不需要更新，学习过程仅计算输出权重。因此在实际使用时ELM的训练速度比传统BP网络快很多。

# 2. 极限学习机的Matlab实现

% 回归问题示例

% 数据读取及预处理

[nPatterns, nInputs] = size(data);
% 最后一列为待预测参数
nInputs = nInputs - 1;

% 归一化至 -1～1
for i = 1 : (nInputs + 1)
data(:,i) = -1 + 2.*(data(:,i) - min(data(:,i)))./(max(data(:,i)) - min(data(:,i)));
end

% 数据集划分，前60%为训练集，后40%为测试集
percTraining = 0.6;
endTraining = ceil(percTraining * nPatterns);

trainData = data(1:endTraining,:);
validData = data(endTraining+1:end,:);

% 隐层数目
nHidden = 10;

% 建立模型
ELM = ELM_MatlabClass('REGRESSION',nInputs,nHidden);

% 训练模型
ELM = train(ELM,trainData);

% 进行预测
Yhat = predict(ELM,trainData(:,1:end-1));
fprintf('TRAINING RSquared = %3.3f\n',computeR2(trainData(:,end),Yhat));

% 计算准确度
Yhat = predict(ELM,validData(:,1:end-1));
fprintf('VALIDATION RSquared = %3.3f\n',computeR2(validData(:,end),Yhat));

%% 灵敏度分析，可确定最佳隐层数目，范围1～100
nHidden = 1:100;
trainR2 = zeros(size(nHidden));
validR2 = zeros(size(nHidden));
for i = 1 : numel(nHidden)
ELM = ELM_MatlabClass('REGRESSION',nInputs,nHidden(i));
ELM = train(ELM,trainData);
Yhat = predict(ELM,trainData(:,1:end-1));
trainR2(i) = computeR2(trainData(:,end),Yhat);
Yhat = predict(ELM,validData(:,1:end-1));
validR2(i) = computeR2(validData(:,end),Yhat);
end

% 显示曲线图
plot(nHidden,[trainR2;validR2],'-o');
xlabel('Number of Hidden Neurons');
ylabel('RSquared');
legend({'training','validation'},'Location','southeast')

# 3. 回归问题测试

TRAINING RSquared = 0.999

VALIDATION RSquared = 0.998 ## 发送评论编辑评论

|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
（╯‵□′）╯︵┴─┴
￣﹃￣
(/ω＼)
∠( ᐛ 」∠)＿
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ｀)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ(￣∇￣o)
ヾ(´･ ･｀｡)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò｡)
Σ(っ °Д °;)っ
( ,,´･ω･)ﾉ"(´っω･｀｡)
╮(╯▽╰)╭
o(*////▽////*)q
＞﹏＜
( ๑´•ω•) "(ㆆᴗㆆ)

Emoji
{"ft_lang_label":"__label__zh","ft_lang_prob":0.5934776,"math_prob":0.9996935,"size":2396,"snap":"2023-40-2023-50","text_gpt3_token_len":1339,"char_repetition_ratio":0.11329431,"word_repetition_ratio":0.011494253,"special_character_ratio":0.27879798,"punctuation_ratio":0.27272728,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9950022,"pos_list":[0,1,2],"im_url_duplicate_count":[null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-12-11T22:56:29Z\",\"WARC-Record-ID\":\"<urn:uuid:169734bf-432d-415a-9996-700cf34e86dc>\",\"Content-Length\":\"109100\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:9f3c6c4b-955a-4c9b-93ef-db44d887bef4>\",\"WARC-Concurrent-To\":\"<urn:uuid:a381ab83-d080-4148-a6f6-9b9fcae262e6>\",\"WARC-IP-Address\":\"81.70.91.8\",\"WARC-Target-URI\":\"https://wdshine.com/articles/machine-learning/205\",\"WARC-Payload-Digest\":\"sha1:P2CQLJDQJVSWP6RGDNNC6ZPP7L2XUVVH\",\"WARC-Block-Digest\":\"sha1:EZVJDHCNUPU5I7NEXWPZSR4SFGPLFHGJ\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-50/CC-MAIN-2023-50_segments_1700679518883.99_warc_CC-MAIN-20231211210408-20231212000408-00392.warc.gz\"}"}