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

本文涉及的产品
MSE Nacos/ZooKeeper 企业版试用,1600元额度,限量50份
注册配置 MSE Nacos/ZooKeeper,182元/月
服务治理 MSE Sentinel/OpenSergo,Agent数量 不受限
简介: 【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电子书和数学建模资料


相关文章
|
7天前
|
存储 编解码 算法
【多光谱滤波器阵列设计的最优球体填充】使用MSFA设计方法进行各种重建算法时,图像质量可以提高至多2 dB,并在光谱相似性方面实现了显著提升(Matlab代码实现)
【多光谱滤波器阵列设计的最优球体填充】使用MSFA设计方法进行各种重建算法时,图像质量可以提高至多2 dB,并在光谱相似性方面实现了显著提升(Matlab代码实现)
|
4天前
|
机器学习/深度学习 人工智能 搜索推荐
从零构建短视频推荐系统:双塔算法架构解析与代码实现
短视频推荐看似“读心”,实则依赖双塔推荐系统:用户塔与物品塔分别将行为与内容编码为向量,通过相似度匹配实现精准推送。本文解析其架构原理、技术实现与工程挑战,揭秘抖音等平台如何用AI抓住你的注意力。
110 6
从零构建短视频推荐系统:双塔算法架构解析与代码实现
|
7天前
|
机器学习/深度学习 传感器 算法
【高创新】基于优化的自适应差分导纳算法的改进最大功率点跟踪研究(Matlab代码实现)
【高创新】基于优化的自适应差分导纳算法的改进最大功率点跟踪研究(Matlab代码实现)
87 14
|
9天前
|
算法 计算机视觉
【MPDR & SMI】失配广义夹角随输入信噪比变化趋势、输出信干噪比随输入信噪比变化趋势研究(Matlab代码实现)
【MPDR & SMI】失配广义夹角随输入信噪比变化趋势、输出信干噪比随输入信噪比变化趋势研究(Matlab代码实现)
|
9天前
|
编解码 人工智能 算法
【采用BPSK或GMSK的Turbo码】MSK、GMSK调制二比特差分解调、turbo+BPSK、turbo+GMSK研究(Matlab代码实现)
【采用BPSK或GMSK的Turbo码】MSK、GMSK调制二比特差分解调、turbo+BPSK、turbo+GMSK研究(Matlab代码实现)
|
9天前
|
机器学习/深度学习 编解码 并行计算
【改进引导滤波器】各向异性引导滤波器,利用加权平均来实现最大扩散,同时保持图像中的强边缘,实现强各向异性滤波,同时保持原始引导滤波器的低低计算成本(Matlab代码实现)
【改进引导滤波器】各向异性引导滤波器,利用加权平均来实现最大扩散,同时保持图像中的强边缘,实现强各向异性滤波,同时保持原始引导滤波器的低低计算成本(Matlab代码实现)
|
9天前
|
机器学习/深度学习 传感器 边缘计算
【故障诊断】基于时滞反馈随机共振的增强型旋转电机故障诊断(Matlab代码实现)
【故障诊断】基于时滞反馈随机共振的增强型旋转电机故障诊断(Matlab代码实现)
|
9天前
|
传感器 机器学习/深度学习 算法
【UASNs、AUV】无人机自主水下传感网络中遗传算法的路径规划问题研究(Matlab代码实现)
【UASNs、AUV】无人机自主水下传感网络中遗传算法的路径规划问题研究(Matlab代码实现)
|
9天前
|
运维 算法
【故障诊断】基于最小熵反卷积、最大相关峰度反卷积和最大二阶环平稳盲反卷积等盲反卷积方法在机械故障诊断中的应用研究(Matlab代码实现)
【故障诊断】基于最小熵反卷积、最大相关峰度反卷积和最大二阶环平稳盲反卷积等盲反卷积方法在机械故障诊断中的应用研究(Matlab代码实现)
|
7天前
|
机器学习/深度学习 算法
【概率Copula分类器】实现d维阿基米德Copula相关的函数、HACs相关的函数研究(Matlab代码实现)
【概率Copula分类器】实现d维阿基米德Copula相关的函数、HACs相关的函数研究(Matlab代码实现)

热门文章

最新文章