Thanks to visit codestin.com
Credit goes to github.com

Skip to content

splitWithProportion works now for different dataset classes - #164

Open
fzalkow wants to merge 2 commits into
pybrain:masterfrom
fzalkow:master
Open

splitWithProportion works now for different dataset classes#164
fzalkow wants to merge 2 commits into
pybrain:masterfrom
fzalkow:master

Conversation

@fzalkow

@fzalkow fzalkow commented May 19, 2015

Copy link
Copy Markdown

I fixed an issue: When doing splitWithProportion on a ClassificationDataSet, the resulting datasets has been of type SupervisedDataSet:

from pybrain.datasets import ClassificationDataSet
ds = ClassificationDataSet(100, 1)
print type(ds)                # <class 'pybrain.datasets.classification.ClassificationDataSet'>
tstdata, trndata = ds.splitWithProportion(0.25)
print type(tstdata)           # <class 'pybrain.datasets.supervised.SupervisedDataSet'>
print type(trndata)           # <class 'pybrain.datasets.supervised.SupervisedDataSet'>
tstdata._convertToOneOfMany() # error

This is because ClassificationDataSet inherits its method splitWithProportion from SupervisedDataSet. So I fixed this by dynamically detecting the class of self in the attribute, and instantiating these classes.

Related: http://stackoverflow.com/questions/27887936/attributeerror-using-pybrain-splitwithportion-object-type-changed

@attoPascal

Copy link
Copy Markdown

The bug was introduced in this commit: 2f02b8d

attoPascal referenced this pull request Jun 16, 2015
…roportion

Now splitWithProporion uses numpy array indicies with numpy.random.permutation instead of for loop, before this change on large datasets this method was very slow, now its finish almost instant.
@mattgabor

Copy link
Copy Markdown

This still isn't working for me, any help?

@fzalkow

fzalkow commented Oct 17, 2016

Copy link
Copy Markdown
Author

This pull request is nearly one and a half years old. For me tstdata._convertToOneOfMany() doesn't raise an error anymore. Without having used pybrain quite some time, I assume my pull request is obsolete meanwhile.

@mattgabor

Copy link
Copy Markdown

It still raises an error for me on version 0.3.3 (latest),

trndata._convertToOneOfMany()
AttributeError: 'SupervisedDataSet' object has no attribute '_convertToOneOfMany'

Sorry, I didn't notice the date on the thread earlier. Would you suggest I create a new issue for this?

@fzalkow

fzalkow commented Oct 17, 2016

Copy link
Copy Markdown
Author

Oh, you are right. I tried with version 3.0, that didn't raise an error. With the latest release, the error seems to be there again. My pull request still fixes this as far as I see. So it could just be merged, no new issue needed...

@mattgabor

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants