【ANFIS分类】基于遗传算法优化模糊和ANFIS实现数

?作者简介:热爱科研的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电子书和数学建模资料

你的内心会被洗成一片空白,自由而宁静,

【ANFIS分类】基于遗传算法优化模糊和ANFIS实现数

相关文章:

  • 【算法】直接插入排序C语言实现
  • 嵌入式 FAAC1.28 在海思HI3518C/HI3518A平台linux中的编译优化
  • Android 动画animation 深入分析
  • Mybatis极其(最)简(好)单(用)的一个分页插件
  • 你感兴趣的文章:

    标签云:

    亚洲高清电影在线, 免费高清电影, 八戒影院夜间, 八戒电影最新大片, 出轨在线电影, 午夜电影院, 在线影院a1166, 在线电影院, 在线观看美剧下载, 日本爱情电影, 日韩高清电影在线, 电影天堂网, 直播盒子app, 聚合直播, 高清美剧, 高清美剧在线观看 EhViewer-E站, E站, E站绿色版, qqmulu.com, qq目录网, qq网站目录,