【ANFIS分类】基于遗传算法优化模糊和ANFIS实现数据分类附matlab代码

简介: 【ANFIS分类】基于遗传算法优化模糊和ANFIS实现数据分类附matlab代码

✅作者简介:热爱科研的Matlab仿真开发者,修心和技术同步精进,matlab项目合作可私信。

🍎个人主页:Matlab科研工作室

🍊个人信条:格物致知。

更多Matlab仿真内容点击👇

智能优化算法  神经网络预测雷达通信 无线传感器

信号处理图像处理路径规划元胞自动机无人机 电力系统

⛄ 内容介绍

个人信用作为社会信用体系建设的重要部分,将其结合现代计算机理论技术来构建个人信用评分模型一直是研究的热点.本文利用前人遗传算法筛选出来的个人信用相关重要属性,并从这些重要属性的3种分类中依类定性地取出部分属性,结合自适应神经模糊推理系统理论(ANFIS),建立基于遗传算法和AN-FIS的个人信用评分模型.对选取的数据实证分析,并与GA-fuzzy方法的结果作了比较,试验结果表明该模型只需少量重要属性变量就能够有较好的分类效果.

⛄ 部分代码

%% Genetic Fuzzy and Genetic ANFIS Classification

% Okay, what about combining evolutionary algorithms with fuzzy logic and

% ANFIS for classification? Well, let痴 push some limits!!! Data is

% consisted of 50 samples with 5 features and 5 classes. You can put your

% data in the system and run it. You have to play with parameters depending

% on your data and system. Right now, you can just run the code and see the

% result. You have to wait for Genetic Algorithm to finish training.

% This code is part of the following project. So, please cite them after use:

% Mousavi, Seyed Muhammad Hossein, et al. "A PSO fuzzy-expert system: As an assistant for specifying the acceptance by NOET measures, at PH. D level." 2017 Artificial Intelligence and Signal Processing Conference (AISP). IEEE, 2017.

% Mousavi, Seyed Muhammad Hossein, S. Younes MiriNezhad, and Mir Hossein Dezfoulian. "Galaxy gravity optimization (GGO) an algorithm for optimization, inspired by comets life cycle." 2017 Artificial Intelligence and Signal Processing Conference (AISP). IEEE, 2017.

% Enjoy the code and feel free to ask your question from me:



%% Lets Do This

% Clearing the Space

clc;

clear;

close all;

warning('off');

%% Start The System

% Loading Data

load evolve.mat

% Shuffling or Swapping Rows (Diverse Result in Each Run)

random_x = dat(randperm(size(dat, 1)), :);

% Deviding Data and Labels

traininput=random_x(:,1:end-1);

traintarget=random_x(:,end);

% Creating Final Struct

data.TrainInputs=traininput;

data.TrainTargets=traintarget;


%% Training Stage

% Generating the FIS

Fuzzy=FISCreation(data,3);

% Tarin Using ANFIS Method

ANFIS=ANFISTrain(Fuzzy,data);

% Tarining By Genetic Algorithm (GA-Fuzzy)

[GA_Fuzzy G_FUZ_results]=GeneticTrain(Fuzzy,data);

% Tarining By Genetic Algorithm (GA-ANFIS)

[GA_ANFIS G_ANF_results]=GeneticTrain(ANFIS,data);

figure;

plotfis(Fuzzy)

figure;

plotfis(ANFIS)

figure;

plotfis(GA_Fuzzy)

figure;

plotfis(GA_ANFIS)

% figure;

% plotmf(GA_ANFIS,'input',3)


%% What Is Achieved In Visual.

BestGAFUZ=G_FUZ_results.BestCost;

BestGAANF=G_ANF_results.BestCost;

% Plot Training

figure;

set(gcf, 'Position',  [300, 50, 600, 600])

subplot(2,1,1)

plot(BestGAFUZ,'-.','LineWidth',3,'MarkerSize',12,'MarkerEdgeColor','b',...

   'Color',[0.3,0,0.9]);title('Fuzzy Genetic Algorithm','Color','r');

xlabel('GA Iteration Number','FontSize',12,'FontWeight','bold','Color',[0.3,0,0.9]);

ylabel('GA Best Cost Result','FontSize',12,'FontWeight','bold','Color',[0.3,0,0.9]);

legend({'Fuzzy GA Train'});

subplot(2,1,2)

plot(BestGAANF,'-.','LineWidth',3,'MarkerSize',12,'MarkerEdgeColor','b',...

   'Color',[0.6,0,0.9]);title('ANFIS Genetic Algorithm','Color','r');

xlabel('GA Iteration Number','FontSize',12,'FontWeight','bold','Color',[0.6,0,0.9]);

ylabel('GA Best Cost Result','FontSize',12,'FontWeight','bold','Color',[0.6,0,0.9]);

legend({'ANFIS GA Train'});


% Plot Statistics

   figure;

   set(gcf, 'Position',  [5, 50, 800, 200])

FyzzyOutputs=evalfis(data.TrainInputs,Fuzzy);

PlotVisual(data.TrainTargets,FyzzyOutputs,'Fuzzy');

   xlabel('Fuzzy','FontSize',14,'FontWeight','bold','Color',[0.9,0.1,0.1]);

   figure;

   set(gcf, 'Position',  [50, 100, 800, 200])

ANFISOutputs=evalfis(data.TrainInputs,ANFIS);

PlotVisual(data.TrainTargets,ANFISOutputs,'ANFIS');

   xlabel('ANFIS','FontSize',14,'FontWeight','bold','Color',[0.9,0.1,0.1]);

   figure;

   set(gcf, 'Position',  [150, 150, 800, 200])

GAFuzzyOutputs=evalfis(data.TrainInputs,GA_Fuzzy);

PlotVisual(data.TrainTargets,GAFuzzyOutputs,'GA Fuzzy');

   xlabel('GA Fuzzy','FontSize',14,'FontWeight','bold','Color',[0.9,0.1,0.1]);

   figure;

   set(gcf, 'Position',  [200, 200, 800, 200])

GAANFISOutputs=evalfis(data.TrainInputs,GA_ANFIS);

PlotVisual(data.TrainTargets,GAANFISOutputs,'GA ANFIS');

   xlabel('GA ANFIS','FontSize',14,'FontWeight','bold','Color',[0.9,0.1,0.1]);


%% Calculating Classification Accuracy

AllTar=data.TrainTargets;

% Generating Outputs

FORound=round(FyzzyOutputs);

AORound=round(ANFISOutputs);

GFORound=round(GAFuzzyOutputs);

GAORound=round(GAANFISOutputs);

sizedata=size(FORound);sizedata=sizedata(1,1);

classsize=max(AllTar);

for i=1 : sizedata

   if FORound(i) > classsize

       FORound(i)=classsize;

   end;end;

for i=1 : sizedata

   if AORound(i) > classsize

       AORound(i)=classsize;

   end;end;

for i=1 : sizedata

   if GFORound(i) > classsize

       GFORound(i)=classsize;

   end;end;

for i=1 : sizedata

   if GAORound(i) > classsize

       GAORound(i)=classsize;

   end;end;

% Calculating Accuracy

% Fuzzy Accuracy

ctfuzz=0;

for i = 1 : sizedata(1,1)

if FORound(i) ~= AllTar(i)

   ctfuzz=ctfuzz+1;

end;end;

finfuzz=ctfuzz*100/ sizedata;  

FuzzyAccuracy=(100-finfuzz);

% ANFIS Accuracy

ctanf=0;

for i = 1 : sizedata(1,1)

if AORound(i) ~= AllTar(i)

   ctanf=ctanf+1;

end;end;

finanf=ctanf*100/ sizedata;

ANFISAccuracy=(100-finanf);

% GA Fuzzy Accuracy

ctgf=0;

for i = 1 : sizedata(1,1)

if GFORound(i) ~= AllTar(i)

   ctgf=ctgf+1;

end;end;

fingf=ctgf*100/ sizedata;

GFAccuracy=(100-fingf);

% GA ANFIS Accuracy

ctganf=0;

for i = 1 : sizedata(1,1)

if GAORound(i) ~= AllTar(i)

   ctganf=ctganf+1;

end;end;

finganf=ctganf*100/ sizedata;

GANFAccuracy=(100-finganf);

% Confusion Matrixes

% Extracting Errors

FOMSE=mse(AllTar,FORound);

AOMSE=mse(AllTar,AORound);

GFOMSE=mse(AllTar,GFORound);

GAOMSE=mse(AllTar,GAORound);

figure

set(gcf, 'Position',  [50, 100, 1300, 300])

subplot(1,4,1)

cm1 = confusionchart(AllTar,FORound);

cm1.Title = (['Fuzzy Classification =  ' num2str(FuzzyAccuracy-FOMSE) '%']);

subplot(1,4,2)

cm2 = confusionchart(AllTar,AORound);

cm2.Title = (['ANFIS Classification =  ' num2str(ANFISAccuracy-AOMSE) '%']);

subplot(1,4,3)

cm3 = confusionchart(AllTar,GFORound);

cm3.Title = (['Genetic Fuzzy Classification =  ' num2str(GFAccuracy-GFOMSE) '%']);

subplot(1,4,4)

cm4 = confusionchart(AllTar,GAORound);

cm4.Title = (['Genetic ANFIS Classification =  ' num2str(GANFAccuracy-GAOMSE) '%']);

% Print Accuracy

fprintf('The Fuzzy Classification Accuracy is = %0.4f.\n',FuzzyAccuracy-FOMSE)

fprintf('The ANFIS Classification Accuracy is = %0.4f.\n',ANFISAccuracy-AOMSE)

fprintf('The Genetic Fuzzy Classification Accuracy is = %0.4f.\n',GFAccuracy-GFOMSE)

fprintf('The Genetic ANFIS Classification Accuracy is = %0.4f.\n',GANFAccuracy-GAOMSE)


⛄ 运行结果

⛄ 参考文献

[1]林娟, 陈健, 王富英. 基于遗传算法和ANFIS的个人信用评分模型[J]. 福建师大福清分校学报, 2013(5):6.

⛄ 完整代码

❤️部分理论引用网络文献,若有侵权联系博主删除
❤️ 关注我领取海量matlab电子书和数学建模资料


相关文章
|
3月前
|
机器学习/深度学习 算法 机器人
【水下图像增强融合算法】基于融合的水下图像与视频增强研究(Matlab代码实现)
【水下图像增强融合算法】基于融合的水下图像与视频增强研究(Matlab代码实现)
382 0
|
3月前
|
机器学习/深度学习 算法 机器人
使用哈里斯角Harris和SIFT算法来实现局部特征匹配(Matlab代码实现)
使用哈里斯角Harris和SIFT算法来实现局部特征匹配(Matlab代码实现)
209 8
|
3月前
|
机器学习/深度学习 算法 自动驾驶
基于导向滤波的暗通道去雾算法在灰度与彩色图像可见度复原中的研究(Matlab代码实现)
基于导向滤波的暗通道去雾算法在灰度与彩色图像可见度复原中的研究(Matlab代码实现)
221 8
|
3月前
|
算法 定位技术 计算机视觉
【水下图像增强】基于波长补偿与去雾的水下图像增强研究(Matlab代码实现)
【水下图像增强】基于波长补偿与去雾的水下图像增强研究(Matlab代码实现)
173 0
|
3月前
|
算法 机器人 计算机视觉
【图像处理】水下图像增强的颜色平衡与融合技术研究(Matlab代码实现)
【图像处理】水下图像增强的颜色平衡与融合技术研究(Matlab代码实现)
142 0
|
3月前
|
新能源 Java Go
【EI复现】参与调峰的储能系统配置方案及经济性分析(Matlab代码实现)
【EI复现】参与调峰的储能系统配置方案及经济性分析(Matlab代码实现)
146 0
|
3月前
|
机器学习/深度学习 编解码 算法
基于OFDM技术的水下声学通信多径信道图像传输研究(Matlab代码实现)
基于OFDM技术的水下声学通信多径信道图像传输研究(Matlab代码实现)
222 8
|
3月前
|
机器学习/深度学习 数据采集 测试技术
基于CEEMDAN-VMD-BiLSTM的多变量输入单步时序预测研究(Matlab代码实现)
基于CEEMDAN-VMD-BiLSTM的多变量输入单步时序预测研究(Matlab代码实现)
131 8
|
3月前
|
编解码 运维 算法
【分布式能源选址与定容】光伏、储能双层优化配置接入配电网研究(Matlab代码实现)
【分布式能源选址与定容】光伏、储能双层优化配置接入配电网研究(Matlab代码实现)
204 12
|
3月前
|
人工智能 数据可视化 网络性能优化
【顶级SCI复现】虚拟电厂的多时间尺度调度:在考虑储能系统容量衰减的同时,整合发电与多用户负荷的灵活性研究(Matlab代码实现)
【顶级SCI复现】虚拟电厂的多时间尺度调度:在考虑储能系统容量衰减的同时,整合发电与多用户负荷的灵活性研究(Matlab代码实现)
163 9

热门文章

最新文章