import anfis import membership.mfDerivs import membership.membershipfunction import numpy ts = numpy.loadtxt("trainingSet.txt", usecols=[1,2,3])#numpy.loadtxt('c:\\Python_fiddling\\myProject\\MF\\trainingSet.txt',usecols=[1,2,3]) X = ts[:,0:2] Y = ts[:,2] mf = [[['gaussmf',{'mean':0.,'sigma':1.}],['gaussmf',{'mean':-1.,'sigma':2.}],['gaussmf',{'mean':-4.,'sigma':10.}],['gaussmf',{'mean':-7.,'sigma':7.}]], [['gaussmf',{'mean':1.,'sigma':2.}],['gaussmf',{'mean':2.,'sigma':3.}],['gaussmf',{'mean':-2.,'sigma':10.}],['gaussmf',{'mean':-10.5,'sigma':5.}]]] mfc = membership.membershipfunction.MemFuncs(mf) anf = anfis.ANFIS(X, Y, mfc) anf.trainHybridJangOffLine(epochs=20) print(round(anf.consequents[-1][0],6)) print(round(anf.consequents[-2][0],6)) print(round(anf.fittedValues[9][0],6)) if round(anf.consequents[-1][0],6) == -5.275538 and round(anf.consequents[-2][0],6) == -1.990703 and round(anf.fittedValues[9][0],6) == 0.002249: print('test is good') print("Plotting errors") anf.plotErrors() print("Plotting results") anf.plotResults()是什么意思
时间: 2023-08-11 12:06:41 浏览: 166
anfis2v1.zip_ANFIS_anfis matlab_anfis prediction_training of ANF
这段代码是使用 ANFIS(Adaptive Neuro-Fuzzy Inference System) 进行模型训练和测试。ANFIS 是一种结合了神经网络和模糊逻辑的方法,用于解决复杂的非线性问题。这个代码使用了两个输入变量和一个输出变量的训练集,通过设置高斯函数的参数来定义隶属度函数,然后使用 ANFIS 对数据进行拟合,得到输出结果。最后,将训练结果进行可视化,以便分析模型的表现。
阅读全文