主要内容

Anfis

Tune Sugeno-type fuzzy inference system using training data

描述

example

fis= anfis(训练数据)generates a single-output Sugeno fuzzy inference system (FIS) and tunes the system parameters using the specified input/output training data. The FIS object is automatically generated using grid partitioning.

训练算法使用最小二乘和反向传播梯度下降方法的组合来对训练数据集进行建模。

example

fis= anfis(训练数据,选项)使用指定的培训数据和选项来调整FIS。使用此语法,您可以指定:

  • 调谐的初始FIS对象。

  • 验证数据,以防止过度适合培训数据。

  • 培训算法选项。

  • 是否显示培训进度信息。

example

[fis,Trainerror] = anfis(___)为每个训练时期返回均方根训练错误。

example

[fis,Trainerror,一步的大小] = anfis(___)returns the training step size at each training epoch.

example

[fis,Trainerror,一步的大小,chkfis,Chkerror] = anfis(训练数据,选项)返回每个培训时期的验证数据错误,Chkerror, and the tuned FIS object for which the validation error is minimum,chkfis。要使用此语法,您必须使用options.validationdata

例子

全部收缩

负载培训数据。该数据具有单个输入和一个输出。

加载fuzex1trnData.dat

生成并训练模糊的推理系统。默认情况下,FIS结构是使用带有两个成员功能的输入变量范围的网格分区创建的。

fis = anfis(fuzex1trndata);
ANFIS info: Number of nodes: 12 Number of linear parameters: 4 Number of nonlinear parameters: 6 Total number of parameters: 10 Number of training data pairs: 25 Number of checking data pairs: 0 Number of fuzzy rules: 2 Start training ANFIS ... 1 0.229709 2 0.22896 3 0.228265 4 0.227624 Step size increases to 0.011000 after epoch 5. 5 0.227036 6 0.2265 7 0.225968 8 0.225488 Step size increases to 0.012100 after epoch 9. 9 0.225052 10 0.22465 Designated epoch number reached. ANFIS training completed at epoch 10. Minimal training RMSE = 0.22465

绘制ANFIS输出和培训数据。

x = fuzex1trnData(:,1); anfisOutput = evalfis(fis,x); plot(x,fuzex1trnData(:,2),'*r',x,anfisOutput,'.b') 传奇(“培训数据”,“ ANFIS输出”,'地点','NorthWest')

图包含一个轴对象。轴对象包含2个类型行的对象。这些对象表示训练数据,ANFIS输出。

ANFIS数据与培训数据不太匹配。改善比赛:

  • 将FIS结构中的成员功能数量增加到4。这样做会在系统中添加模糊规则和可调参数。

  • Increase the number of training epochs.

opt = anfisoptions('InitialFIS',4,'EpochNumber',40);

Suppress the error and step size Command Window display.

opt.displayErrorValues = 0;opt.displaystepsize = 0;

训练FIS。

fis = anfis(fuzex1trnData,opt);
ANFIS信息:节点的数量:20个线性参数数:8非线性参数数:12参数总数:20训练数数据对数:25检查数据对数:0模糊规则数:4最小培训rmse = RMSE = RMSE = RMSE =0.0833853

绘制ANFIS输出和培训数据。

图anfisOutput = evalfis(fis,x);绘图(x,fuzex1trndata(:,2),,'*r',x,anfisOutput,'.b') 传奇(“培训数据”,“ ANFIS输出”,'地点','NorthWest')

图包含一个轴对象。轴对象包含2个类型行的对象。这些对象表示训练数据,ANFIS输出。

训练数据和ANFIS输出之间的匹配有所改善。

创建单输入单输出培训数据。

x =(0:0.1:10)';y = sin(2*x)./ exp(x/5);

Define an initial FIS structure with five Gaussian input membership functions.

genOpt = genfisOptions(“网状分区”);genopt.nummembershipfunctions = 5;genopt.inputMembershipFunctionType ='高斯'; inFIS = genfis(x,y,genOpt);

配置ANFIS培训选项。设置初始FIS,并抑制训练进度显示。

opt = anfisoptions('InitialFIS',Infis);opt.displayanfisinformation = 0;opt.displayErrorValues = 0;opt.displaystepsize = 0;opt.displayfinalResults = 0;

Train the FIS using the specified options.

utfis = anfis([x y],opt);

将ANFIS输出与培训数据进行比较。

图(x,y,x,evalfis(Outfis,x))传奇(“培训数据”,“ ANFIS输出”)

图包含一个轴对象。轴对象包含2个类型行的对象。这些对象表示训练数据,ANFIS输出。

负载培训数据。该数据具有单个输入和一个输出。

加载fuzex2trndata.dat

Specify the training options.

opt = anfisoptions('InitialFIS',4,'EpochNumber',40); opt.DisplayANFISInformation = 0; opt.DisplayErrorValues = 0; opt.DisplayStepSize = 0; opt.DisplayFinalResults = 0;

Train the FIS, and return the training error.

[fis,trainerror] = anfis(fuzex2trndata,opt);

Trainerror在每个训练时期内包含训练数据的根平方误差。训练错误的错误fis是最小值Trainerror

fisrmse = min(trainerror)
Fisrmse = 0.2572

创建单输入单输出培训数据。

x =(0:0.1:10)';y = sin(2*x)./ exp(x/5);

配置ANFIS培训选项。设置初始FIS,并抑制训练进度显示。

opt = anfisoptions('InitialFIS',4,'EpochNumber',60);opt.displayanfisinformation = 0;opt.displayErrorValues = 0;opt.displaystepsize = 0;opt.displayfinalResults = 0;

A larger step size increase rate can make the training converge faster. However, increasing the step size increase rate too much can lead to poor convergence. For this example, try doubling the step size increase rate.

opt.StepSizeIncreaseRate = 2*opt.StepSizeIncreaseRate;

训练FIS,然后返回步长数组。

[fis,〜,stepize] = anfis([x y],opt);

绘制步长大小配置文件。最佳的步长轮廓最初应增加,达到最大值,然后在其余训练中减小。

图图(步骤尺寸)

图包含一个轴对象。轴对象包含一个类型行的对象。

负载培训数据。

加载fuzex1trnData.dat

加载验证数据。

加载fuzex1chkdata.dat

Specify the following training options:

  • 4在put membership functions

  • 30训练时期

  • 抑制训练进度显示

opt = anfisoptions('InitialFIS',4,'EpochNumber',30);opt.displayanfisinformation = 0;opt.displayErrorValues = 0;opt.displaystepsize = 0;opt.displayfinalResults = 0;

将验证数据添加到培训选项中。

opt.validationdata = fuzex1chkdata;

训练FIS,并返回验证结果。

[FIS,TrainError,Stepize,Chkfis,Chkerror] = Anfis(fuzex1trndata,opt);

这training error,Trainerror, and validation error,Chkerror,每个训练时期每个阵列都包含一个错误值。绘制训练错误和验证错误。

x = [1:30]; plot(x,trainError,'.b',x,chkerror,'*r')

图包含一个轴对象。轴对象包含2个类型行的对象。

这minimum validation error occurs at epoch 17. The increase in validation error after this point indicates overfitting of the model parameters to the training data. Therefore, the tuned FIS at epoch 17,chkfis,表现出最佳的概括性能。

输入参数

全部收缩

培训数据,指定为阵列。用于模糊系统N输入,指定训练数据作为一个数组N+1 columns. The firstNcolumns contain input data, and the final column contains output data. Each row of训练数据contains one data point.

通常,培训数据应完全代表FIS旨在建模的数据的功能。

培训选项,指定为Anfisoptions选项集。使用选项,您可以指定:

  • 调谐的初始FIS结构options.initialfis

  • 防止过度适合培训数据的验证数据,options.validationdata

  • 培训算法选项,例如最大培训时期数量,选项。EpochNumber,或训练错误目标,options.errorgoal

  • Whether to display training progress information, such as the training error values for each training epoch,选项。DisplayErrorValues

输出参数

全部收缩

经过训练的模糊推理系统,使用培训数据调整了成员功能参数,返回为Mamfis或者sugfis目的。This fuzzy system corresponds to the epoch for which the training error is smallest. If two epochs have the same minimum training error, the FIS from the earlier epoch is returned.

Root mean square training error for each training epoch, returned as an array. The minimum value inTrainerroris the training error for fuzzy systemfis

每个时期的训练步长,作为数组返回。这Anfis训练算法使用梯度下降优化方法来调整FIS参数。训练步骤大小是参数空间中梯度跃迁的大小。

Ideally, the step size increases at the start of training, reaches a maximum, and then decreases for the remainder of the training. To achieve this step size profile, adjust the initial step size (options.initialStepsize),步长增加率(options.StepsizeIncreaserate)和步长降低率选项。步进式销售

调谐FI,验证错误最小,返回为Mamfis或者sugfis目的。如果两个时期的最小验证误差相同,则返回了早期时期的FIS。

chkfis仅当您使用使用验证数据时,才返回options.validationdata

根平方训练误差,作为阵列返回,长度等于训练时期的数量。最小值Chkerroris the training error for fuzzy systemchkfis

Chkerror仅当您使用使用验证数据时,才返回options.validationdata

替代功能

tunefis功能

从R2019A开始,您可以使用模糊系统使用tunefis。This function provides several other options for tuning algorithms, specified by theTunefisoptions目的。

To use ANFIS, specify the tuning algorithm as"anfis"Tunefisoptions。这n, use the options object as an input argument fortunefis。例如:

创建初始模糊推理系统,并定义可调参数设置。

x =(0:0.1:10)';y = sin(2*x)./ exp(x/5);选项= genfisoptions(“网状分区”);选项。NumMembershipFunctions = 5; fisin = genfis(x,y,options); [in,out,rule] = getTunableSettings(fisin);

调整会员函数参数"anfis"

opt = tunefisoptions(“方法”,"anfis");fisout = tunefis(fisin,[in; out],x,y,opt);

兼容性考虑

展开全部

警告从R2019b开始

参考

[1] Jang,J.-S。R.,“使用广义神经网络和Kalman滤波器算法进行模糊建模,”Proc。第九国民conf。关于人工智能(AAAI-91)。July 1991, pp. 762-767.

[2] Jang,J.-S。R.,“ ANFIS:基于自适应网络的模糊推理系统”,”IEEE关于系统,人和控制论的交易,卷。23,第3号,1993年5月,第665-685页。

在R2006a之前引入