English subtitles

← 07-20 Learning Regular Expressions Solution

Get Embed Code
3 Languages

Showing Revision 1 created 06/29/2012 by Amara Bot.

  1. Well, there are a number of ways to go about this--
  2. actually, an infinite number of ways to go about this.
  3. An entirely legitimate strategy but one that might feel almost like cheating
  4. would be just to put these together.
  5. You could submit the Python code that corresponds to either this or this or this.
  6. Now you're guaranteed that it accepts the three strings on the left and nothing else.
  7. Now, you'd have to be careful about how you group things or whatnot,
  8. so that the or and the parentheses would bind correctly, but that's one way to do it.
  9. Let's go see if we can make a more natural feeling regular expression that actually does it though.
  10. It looks like we definitely have to start with an a.
  11. Now I have my choice of what I want to say the difference is between these other strings--
  12. abb and here we've got aabbb.
  13. In some sense one of the key differences is the number of b's.
  14. Here's one regular expression that captures all the ones on the left and none of the ones on the right.
  15. It's an a*--so that gets this first one, and then after you're done with the a's,
  16. you may optionally have either bb or cc. Great.
  17. That gets 1, 2, and 3 but none of these to hers.
  18. This one is ruled because it's not bb cc with a's in front of it.
  19. These have too many b's. These have too many c's.
  20. But there are a large number of ways you could've done this.
  21. In fact, there is an area of study called learning theory that tries to make machines find patterns
  22. the same way that we can with our brain.
  23. There's a notion that you've really learned something when you've abstracted it to a small rule.
  24. The reason we're less happy with this answer up here is because its' over-fitting the data in some sense.
  25. It's just recording the yes instances. It's not really generalizing the pattern.
  26. We say that more learning is happening when we generalize a smaller pattern
  27. than just copying all of the available input, but that was by no means required for this problem.