Git Product home page Git Product logo

Comments (12)

dnouri avatar dnouri commented on July 20, 2024

What's happening here is that you're probably also shuffling the batches of your test set iterator (batch_iterator_test). When you run net.predict() it'll also use an iterator to go over the samples, so in your case they'll come out in this random order.

from nolearn.

run2 avatar run2 commented on July 20, 2024

Daniel
I am unaware of batch_iterator_test. Like I said I only changed those three lines in BatchIterator. And I am not sure I understand what you mean. Why would that cause extremely bad test performance when the validation errors are less. Why would the prediction have dependency on the order of the batches ?

from nolearn.

dnouri avatar dnouri commented on July 20, 2024

@run2 So if you're running the version that doesn't have batch_iterator_test (which was added three weeks ago), then put a if self.test around your shuffling logic, so it won't shuffle if it's in test mode.

Why would the prediction depend on the order of the batches? Because that order defines the order of predictions on the way out. So imagine you want to predict for values A, B, and C. After your batch iterator's shuffle (assume batch size of 1), the predictions might come out as b, c, and a. If this doesn't make sense, then I suggest you take a closer look at the predict_proba method.

from nolearn.

run2 avatar run2 commented on July 20, 2024

Ah! I see. Very interesting. Thanks - let me try that out.

from nolearn.

run2 avatar run2 commented on July 20, 2024

Wow! That makes a big difference now. Much much better prediction results. You might want to try out what I did and see if that gives you much faster learning and lower val errors. It will be great if you can let me know.

from nolearn.

run2 avatar run2 commented on July 20, 2024

I am closing this issue but waiting to hear from you.

from nolearn.

dnouri avatar dnouri commented on July 20, 2024

I think this is a fine idea. FTR, here's some code that I use in another project:

def shuffle(*arrays):
    p = np.random.permutation(len(arrays[0]))
    return [array[p] for array in arrays]


class ShufflingBatchIteratorMixin(object):
    def __iter__(self):
        self.X, self.y = shuffle(self.X, self.y)
        for res in super(ShufflingBatchIteratorMixin, self).__iter__():
            yield res

from nolearn.

cancan101 avatar cancan101 commented on July 20, 2024

@dnouri For the reasons listed here: #36, there are limitations to this approach.

from nolearn.

dnouri avatar dnouri commented on July 20, 2024

@cancan101 Not sure I get it. Is nn.enc_ relevant for shuffling?

from nolearn.

cancan101 avatar cancan101 commented on July 20, 2024

I am using is not for shuffling, but rather for subsampling one of the classes.

from nolearn.

dnouri avatar dnouri commented on July 20, 2024

So you suggest #36 as an alternative to the code in #13, is that right?

from nolearn.

cancan101 avatar cancan101 commented on July 20, 2024

Ah, yes, #36 instead of #13 (specifically cancan101@00c2ce9). In looking at your code above, I think that is a much cleaner solution and doesn't require the change in #13 and subclassing of NeuralNet. I would be happy to use change/ subclass the Iterator but currently I do need a reference to the NeuralNet.

from nolearn.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.