💥1 概述
文化和谐学习算法 - 创建于 18 Jan 2022 由 赛义德·穆罕默德·侯赛因·穆萨维
这里都是关于使用进化算法学习的。和谐搜索和文化算法是两种快速优化算法,它们的结果在这里组合在一起,以便在一个简单的中训练目标的输入数据集。基本上,系统从制作初始模糊模型和拟合开始基于输入的输出首先通过和谐搜索,然后尝试拟合和谐搜索输出与第二阶段的输入通过文化算法。这意味着我们正在同时使用两者,进化算法,以提高准确性。系统很容易,用于回归、分类和其他优化任务。您可以使用您的数据并使用参数。
📚2 运行结果
部分代码:
%% Cleaning clc; clear; warning('off'); %% Data Loading data=JustLoad(); %% Generate Basic Fuzzy Model % Number of Clusters in FCM ClusNum=4; % fis=GenerateFuzzy(data,ClusNum); % %% Tarining Cultural Harmony Algorithm % Harmony Search Learning HarFis=hars(fis,data); % Harmony Cultural Algorithm Learning CAHSfis=CulturalFCN(HarFis,data); %% Plot Cultural Harmony Results (Train - Test) % Train Output Extraction TrTar=data.TrainTargets; TrainOutputs=evalfis(data.TrainInputs,CAHSfis); % Test Output Extraction TsTar=data.TestTargets; TestOutputs=evalfis(data.TestInputs,CAHSfis); % Train calc Errors=data.TrainTargets-TrainOutputs; MSE=mean(Errors.^2);RMSE=sqrt(MSE); error_mean=mean(Errors);error_std=std(Errors); % Test calc Errors1=data.TestTargets-TestOutputs; MSE1=mean(Errors1.^2);RMSE1=sqrt(MSE1); error_mean1=mean(Errors1);error_std1=std(Errors1); % Train figure('units','normalized','outerposition',[0 0 1 1]) subplot(3,2,1); plot(data.TrainTargets,'c'); hold on; plot(TrainOutputs,'k');legend('Target','Output'); title('Cultural Harmony Training Part');xlabel('Sample Index');grid on; % Test subplot(3,2,2); plot(data.TestTargets,'c'); hold on; plot(TestOutputs,'k');legend('Cultural Harmony Target','Cultural Harmony Output'); title('Cultural Harmony Testing Part');xlabel('Sample Index');grid on; % Train subplot(3,2,3); plot(Errors,'k');legend('Cultural Harmony Training Error'); title(['Train MSE = ' num2str(MSE) ' , Train RMSE = ' num2str(RMSE)]);grid on; % Test subplot(3,2,4); plot(Errors1,'k');legend('Cultural Harmony Testing Error'); title(['Test MSE = ' num2str(MSE1) ' , Test RMSE = ' num2str(RMSE1)]);grid on; % Train subplot(3,2,5); h=histfit(Errors, 50);h(1).FaceColor = [.1 .2 0.9]; title(['Train Error Mean = ' num2str(error_mean) ' , Train Error STD = ' num2str(error_std)]); % Test subplot(3,2,6); h=histfit(Errors1, 50);h(1).FaceColor = [.1 .2 0.9]; title(['Test Error Mean = ' num2str(error_mean1) ' , Test Error STD = ' num2str(error_std1)]); %% Plot Just Fuzzy Results (Train - Test) % Train Output Extraction fTrainOutputs=evalfis(data.TrainInputs,fis); % Test Output Extraction fTestOutputs=evalfis(data.TestInputs,fis); % Train calc fErrors=data.TrainTargets-fTrainOutputs; fMSE=mean(fErrors.^2);fRMSE=sqrt(fMSE); ferror_mean=mean(fErrors);ferror_std=std(fErrors); % Test calc fErrors1=data.TestTargets-fTestOutputs; fMSE1=mean(fErrors1.^2);fRMSE1=sqrt(fMSE1); ferror_mean1=mean(fErrors1);ferror_std1=std(fErrors1); % Train figure('units','normalized','outerposition',[0 0 1 1]) subplot(3,2,1); plot(data.TrainTargets,'m');hold on; plot(fTrainOutputs,'k');legend('Target','Output'); title('Fuzzy Training Part');xlabel('Sample Index');grid on; % Test subplot(3,2,2); plot(data.TestTargets,'m');hold on; plot(fTestOutputs,'k');legend('Target','Output'); title('Fuzzy Testing Part');xlabel('Sample Index');grid on; % Train subplot(3,2,3); plot(fErrors,'g');legend('Fuzzy Training Error'); title(['Train MSE = ' num2str(fMSE) ' , Test RMSE = ' num2str(fRMSE)]);grid on; % Test subplot(3,2,4); plot(fErrors1,'g');legend('Fuzzy Testing Error'); title(['Train MSE = ' num2str(fMSE1) ' , Test RMSE = ' num2str(fRMSE1)]);grid on; % Train subplot(3,2,5); h=histfit(fErrors, 50);h(1).FaceColor = [.3 .8 0.3]; title(['Train Error Mean = ' num2str(ferror_mean) ' , Train Error STD = ' num2str(ferror_std)]); % Test subplot(3,2,6); h=histfit(fErrors1, 50);h(1).FaceColor = [.3 .8 0.3]; title(['Test Error Mean = ' num2str(ferror_mean1) ' , Test Error STD = ' num2str(ferror_std1)]);
🌈3 Matlab代码实现
🎉4 参考文献
部分理论来源于网络,如有侵权请联系删除。
[1]Seyed Muhammad Hossein Mousavi (2022). Cultural Harmony Learning Algorithm