制作经过培训的数据集python的图形

制作经过培训的数据集python的图形,python,networking,dataset,graphic,Python,Networking,Dataset,Graphic,大家好,我第一次在这里发帖,但是谢谢你们的工作 好的,我正在使用神经网络(多层前置器)进行测试,我正在使用UCI ML存储库进行测试,我必须用图形显示错误与历元数的关系,但我不知道我做错了什么,这是我得到的错误: y1 = [] y2 = [] x = [] for i in range(40): #fer dos llistes (error y epoch) y despres fer un plot trainer.trainEpochs( 1 ) trnresul

大家好,我第一次在这里发帖,但是谢谢你们的工作

好的,我正在使用神经网络(多层前置器)进行测试,我正在使用UCI ML存储库进行测试,我必须用图形显示错误与历元数的关系,但我不知道我做错了什么,这是我得到的错误:

y1 = []
y2 = []
x = []
for i in range(40):
    #fer dos llistes (error y epoch) y despres fer un plot
    trainer.trainEpochs( 1 )
    trnresult = percentError( trainer.testOnClassData(),trndata['class'] )
    tstresult = percentError( trainer.testOnClassData(dataset=tstdata ),tstdata['class'] )

    print "epoch: %4d" % trainer.totalepochs, \
          "  train error: %5.2f%%" % trnresult, \
          "  test error: %5.2f%%" % tstresult

    if i==1:
        g=Gnuplot.Gnuplot()
    else:
        y1 = y1.append(float(trnresult))
        y2 = y2.append(float(tstresult))
        x = x.append(i)
d1=Gnuplot.Data(x,y1,with_="line")
d2=Gnuplot.Data(x,y2,with_="line")
g.plot(d1,d2)
我曾尝试在y1.append()处使用int和float,但我得到了相同的错误。 这是我在控制台上得到的全部信息:

y1 = y1.append(float(trnresult))
AttributeError: 'NoneType' object has no attribute 'append'
培训模式数量:233
输入和输出维度:6 2
第一个示例(输入、目标、类):
[ 63.03  22.55  39.61  40.48  98.67  -0.25] [1 0] [ 0.]
总误差:0.110573541007
历元:1列车错误:33.05%测试错误:29.87%
总误差:0.0953749484982
历元:2列错误:32.19%测试错误:35.06%
总误差:0.0977600868845
历元:3列错误:27.90%测试错误:29.87%
回溯(最近一次呼叫最后一次):
文件“C:\Python\Practice\dataset.py”,第79行,在
y1=y1.追加(浮点(trnresult))
AttributeError:“非类型”对象没有属性“附加”
谢谢。

列表上的
append()
函数不返回值。因此,将
y1
替换为
None
。您应该执行
y1.append()
y2.append()
,而不必重新分配到
y1
y2

更具体地说

Number of training patterns:  233

Input and output dimensions:  6 2

First sample (input, target, class):

[ 63.03  22.55  39.61  40.48  98.67  -0.25] [1 0] [ 0.]

Total error: 0.110573541007

epoch:    1   train error: 33.05%   test error: 29.87%

Total error: 0.0953749484982

epoch:    2   train error: 32.19%   test error: 35.06%

Total error: 0.0977600868845

epoch:    3   train error: 27.90%   test error: 29.87%

Traceback (most recent call last):
  File "C:\Python\Practice\dataset.py", line 79, in <module>
    y1 = y1.append(float(trnresult))
AttributeError: 'NoneType' object has no attribute 'append'
如果需要,可以使用列表上的
+
运算符(注意
[]
周围的
3
):


好的,第二种解释似乎很有效,谢谢。
>>> a = []
>>> b = a.append(1)
>>> b is None
True
>>> a
[1]
>>> a.append(2)
>>> a
[1, 2]
>>> a = a + [3]
>>> a
[1, 2, 3]