<div dir="ltr">umm i can do skype<div><br></div></div><br><div class="gmail_quote"><div dir="ltr">On Sat, Sep 19, 2015 at 1:46 PM Lewit, Douglas <<a href="mailto:d-lewit@neiu.edu">d-lewit@neiu.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><font size="4">Hey Joshua!  I would LOVE to, but I have classes on Wednesday and Thursday evenings.  So.... ???</font></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Sep 19, 2015 at 1:30 PM, Joshua Herman <span dir="ltr"><<a href="mailto:zitterbewegung@gmail.com" target="_blank">zitterbewegung@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="white-space:pre-wrap">Hey I'm doing machine learning too why don't you come to one of the python meet ups in Chicago</div><div><div><br><div class="gmail_quote"><div dir="ltr">On Sat, Sep 19, 2015 at 12:56 PM Lewit, Douglas <<a href="mailto:d-lewit@neiu.edu" target="_blank">d-lewit@neiu.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><font size="4">Hi William,</font><div><font size="4"><br></font></div><div><font size="4">I'm doing a KNN program (K-Nearest-Neighbors).  I'm attaching what I've done so far.  It's not complete!  But I've made good progress I think.  (The program won't work unless you also download the .txt file that the program uses to read in the data.)  </font></div><div><font size="4"><br></font></div><div><font size="4">For this problem the data has to get split into two sets: a training set (kind of like a control group in an experiment) and the test set (the experimental group or its equivalent).  I have to use the K smallest normalized distances to make a guess about which class the records in the Training Set belong to.  (There are six classes: {1, 2, 3, 5, 6, 7}.  There's no class #4.)  </font></div><div><font size="4"><br></font></div><div><font size="4">This problem has given me a massive headache, but I think I'm almost done with it.  All that's left really is to use one of the algorithms to make a decision about which class each Test record should be assigned to.</font></div><div><font size="4"><br></font></div><div><font size="4">Thanks for the feedback!</font></div><div><font size="4"><br></font></div><div><font size="4">Best,</font></div><div><font size="4"><br></font></div><div><font size="4">Douglas.</font></div><div><font size="4"><br></font></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Sep 19, 2015 at 10:45 AM, William E. S. Clemens <span dir="ltr"><<a href="mailto:wesclemens@gmail.com" target="_blank">wesclemens@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I would agree that Jimmy's solution is the correct one for doing this. But I would avoid setting up your data structure in this manner. A dict is a hash table and it is be extremely fast a looking up a value by key.<div><br></div><div>You are building an array of the keys to linearly search. This operation is going to be slow and will not scale well. If you described what this data is and what your trying todo with it. I maybe able to suggest a better data structure for storing and accessing it. </div><div><br></div><div><br><div><br></div></div></div><div class="gmail_extra"><br clear="all"><div><div>--<br>William Clemens<br>Phone: <a href="tel:847.485.9455" value="+18474859455" target="_blank">847.485.9455</a><br>E-mail: <a href="mailto:wesclemens@gmail.com" target="_blank">wesclemens@gmail.com</a><br></div></div><div><div>
<br><div class="gmail_quote">On Sat, Sep 19, 2015 at 10:02 AM, Lewit, Douglas <span dir="ltr"><<a href="mailto:d-lewit@neiu.edu" target="_blank">d-lewit@neiu.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><font size="4">I love it!  Thanks Jim.</font></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Sep 19, 2015 at 8:09 AM, Jimmy Calahorrano via Chicago <span dir="ltr"><<a href="mailto:chicago@python.org" target="_blank">chicago@python.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">is more elegant but not sure if is the best option:<br>
<br>
<br>
[A[key] for key in A.keys() if key[0] == 1]<br>
<br>
<br>
<br>
--------------------------------------------<br>
On Sat, 9/19/15, Lewit, Douglas <<a href="mailto:d-lewit@neiu.edu" target="_blank">d-lewit@neiu.edu</a>> wrote:<br>
<br>
 Subject: [Chicago] Question about accessing dictionary's elements.<br>
 To: "The Chicago Python Users Group" <<a href="mailto:chicago@python.org" target="_blank">chicago@python.org</a>><br>
 Date: Saturday, September 19, 2015, 7:43 AM<br>
<div><div><br>
 Hi<br>
 guys,<br>
 I have a problem and not<br>
 sure how to address it.  Let's say I have a simple<br>
 dictionary such as.<br>
 A = { (1, 2) : 10, (1, 3) :<br>
 15, (1, 4) : 50, (2, 0) : 2, (2, 5) : 8, (2, 12) : 19<br>
 }<br>
 I would like to access any<br>
 and all tuples whose first value is 1 or let's say 2. <br>
 How would I do that?<br>
 So what I'm trying to<br>
 go for is:<br>
 A[(1, placeholder for any<br>
 int value)] thus giving me all the values that correspond to<br>
 (1, #).  Not really sure how to go about this.  Unless....<br>
 I suppose I could do something like<br>
 this:<br>
 for key in<br>
 A:     if list(key)[0]<br>
 == 1:           <br>
 print(A[key])  #### Or whatever I want to do with the<br>
 number.<br>
 Hmmm.... maybe that would<br>
 work, but is there a more "elegant" way to do<br>
 this?  Is there any "pattern matching" in Python<br>
 so that I could do this:<br>
 A[(1, #placeholder for any<br>
 int )]<br>
 Hey, thanks for your<br>
 help.<br>
 By the way, has anyone seen<br>
 the book LEARNING PYTHON by Mark Lutz?  Wow!  Full of<br>
 great information, but the book is HUGE!!!  I'll have<br>
 serious back problems if I carry that thing around in my<br>
 backpack!  There's something about small, lightweight<br>
 books that I really prefer.  (And then there's eBooks,<br>
 but that's a horse of a different color in my<br>
 opinion.)<br>
 Have a great weekend and<br>
 I'm looking forward to some ideas on the above<br>
 problem.  Thanks in advance.<br>
 Best,<br>
 Douglas<br>
 L.<br>
<br>
</div></div> -----Inline Attachment Follows-----<br>
<br>
 _______________________________________________<br>
 Chicago mailing list<br>
 <a href="mailto:Chicago@python.org" target="_blank">Chicago@python.org</a><br>
 <a href="https://mail.python.org/mailman/listinfo/chicago" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/chicago</a><br>
<br>
_______________________________________________<br>
Chicago mailing list<br>
<a href="mailto:Chicago@python.org" target="_blank">Chicago@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/chicago" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/chicago</a><br>
</blockquote></div><br></div>
</div></div><br>_______________________________________________<br>
Chicago mailing list<br>
<a href="mailto:Chicago@python.org" target="_blank">Chicago@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/chicago" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/chicago</a><br>
<br></blockquote></div><br></div></div></div>
<br>_______________________________________________<br>
Chicago mailing list<br>
<a href="mailto:Chicago@python.org" target="_blank">Chicago@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/chicago" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/chicago</a><br>
<br></blockquote></div><br></div>
_______________________________________________<br>
Chicago mailing list<br>
<a href="mailto:Chicago@python.org" target="_blank">Chicago@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/chicago" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/chicago</a><br>
</blockquote></div>
</div></div><br>_______________________________________________<br>
Chicago mailing list<br>
<a href="mailto:Chicago@python.org" target="_blank">Chicago@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/chicago" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/chicago</a><br>
<br></blockquote></div><br></div>
_______________________________________________<br>
Chicago mailing list<br>
<a href="mailto:Chicago@python.org" target="_blank">Chicago@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/chicago" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/chicago</a><br>
</blockquote></div>