On Fri, Dec 28, 2018 at 03:34:19PM -0500, Avi Gross wrote: [...] > You replied to one of my points with this about a way to partition data: > > --- > The obvious solution: > > keys = list(mydict.keys()) > random.shuffle(keys) > index = len(keys)*3//4 > training_data = keys[:index] > reserved = keys[index:] > --- > > (In the above, "---" is not python but a separator!) > > That is indeed a very reasonable way to segment the data. But it sort of > makes my point. If the data is stored in a dictionary, the way to access it > ended up being to make a list and play with that. I would still need to get > the values one at a time from the dictionary such as in the ways you also > show and I omit.
Yes? How else do you expect to get the value given a key except by looking it up? > For me, it seems more natural in this case to simply have the data in > a data frame where I have lots of tools and methods available. I'm not sure if your understanding of a data frame is the same as my understanding. Are you talking about this? http://www.r-tutor.com/r-introduction/data-frame In other words, a two-dimensional array of some sort? Okay, you have your data frame. Now what? How do you solve the problem being asked? I'm not interested in vague handwaving that doesn't solve anything. You specified data in a key:value store, let's say like this: mydict = {'spam': 25, 'ham': 2, 'eggs': 7, 'cheddar': 1, 'brie': 14, 'aardvark': 3, 'argument': 11, 'parrot': 16} Here it is as a data frame: df = [['spam', 'ham', 'eggs', 'cheddar', 'brie', 'aardvark', 'argument', 'parrot'], [25, 2, 7, 1, 14, 3, 11, 16]] Now what? How do you randomly split that into randomly selected set of training data and reserved data? Feel free to give an answer in terms of R, provided you also give an answer in terms of Python. Remember that unlike R, Python doesn't have a standard data frame type, so you are responsible for building whatever methods you need. -- Steve _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor