AttributeError using pyBrain _splitWithPortion - object type changed?

前端 未结 6 884
遥遥无期
遥遥无期 2021-02-07 06:36

I\'m testing out pybrain following the basic classification tutorial here and a different take on it with some more realistic data here. However I receive this error when applyi

6条回答
  •  北荒
    北荒 (楼主)
    2021-02-07 07:22

    The simplest workaround that I found was to do first the splitWithProportion(), update the number of classes and then do the _convertToOneOfMany().

    tstdata, trndata = alldata.splitWithProportion( 0.25 )
    tstdata.nClasses = alldata.nClasses
    trndata.nClasses = alldata.nClasses
    tstdata._convertToOneOfMany(bounds=[0, 1])
    trndata._convertToOneOfMany(bounds=[0, 1])
    

    And with the update of nClasses of both testdata and trndata, it is guarantee that you don't get different dimensions in the target fields.

    I was geting errors either if I did first _convertToOneOfMany and second splitWithProportion or the other way around when working with a ClassificationDataSet. So, I suggested and update in the splitWithProportion function. You can see the whole code in this pullRequest.

提交回复
热议问题