<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">

  <title><![CDATA[CMPSCI 383: Artificial Intelligence]]></title>
  <link href="http://people.cs.umass.edu/~liberato/courses/2014-fall-cmpsci383/atom.xml" rel="self"/>
  <link href="http://people.cs.umass.edu/~liberato/courses/2014-fall-cmpsci383/"/>
  <updated>2015-12-24T08:16:50-05:00</updated>
  <id>http://people.cs.umass.edu/~liberato/courses/2014-fall-cmpsci383/</id>
  <author>
    <name><![CDATA[Marc Liberatore]]></name>
    
  </author>
  <generator uri="http://octopress.org/">Octopress</generator>

  
  <entry>
    <title type="html"><![CDATA[The End]]></title>
    <link href="http://people.cs.umass.edu/~liberato/courses/2014-fall-cmpsci383/blog/2014/12/12/the-end/"/>
    <updated>2014-12-12T13:52:21-05:00</updated>
    <id>http://people.cs.umass.edu/~liberato/courses/2014-fall-cmpsci383/blog/2014/12/12/the-end</id>
    <content type="html"><![CDATA[<blockquote><p>&ldquo;By far the greatest danger of Artificial Intelligence is that people conclude too early that they understand it.&rdquo; ― Eliezer Yudkowsky</p></blockquote>

<p>We&rsquo;ve reached the end of the semester.</p>

<p>This semester, I tried to give you a guided tour of topics in Artificial Intelligence. I hope that the material we covered has weighted your (biological) neural networks appropriately, and helps you in the future when the need or interest arises.</p>

<p>Please get in touch if you&rsquo;re around in the future. I&rsquo;d love to hear what you&rsquo;re up to.</p>

<p>Cheers,<br/>
Marc</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Final Exam Graded]]></title>
    <link href="http://people.cs.umass.edu/~liberato/courses/2014-fall-cmpsci383/blog/2014/12/12/final-exam-graded/"/>
    <updated>2014-12-12T11:36:47-05:00</updated>
    <id>http://people.cs.umass.edu/~liberato/courses/2014-fall-cmpsci383/blog/2014/12/12/final-exam-graded</id>
    <content type="html"><![CDATA[<p>The Final Exam has been graded, and the grades are up on <a href="https://moodle.umass.edu">Moodle</a>. The mean was 70, the median 74. The approximate distribution was as follows:</p>

<pre><code>(90,100]: 2  
(80,90]: 10
(70,80]: 13
(60,70]:  8
(50,60]:  4
(0,50]:   5
</code></pre>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Assignment 10 Graded]]></title>
    <link href="http://people.cs.umass.edu/~liberato/courses/2014-fall-cmpsci383/blog/2014/12/08/assignment-10-graded/"/>
    <updated>2014-12-08T21:13:33-05:00</updated>
    <id>http://people.cs.umass.edu/~liberato/courses/2014-fall-cmpsci383/blog/2014/12/08/assignment-10-graded</id>
    <content type="html"><![CDATA[<p>The <a href="http://people.cs.umass.edu/~liberato/courses/2014-fall-cmpsci383/assignments/assignment10">Assignment 10</a> submissions have been graded. I have posted grades on <a href="https://moodle.umass.edu/">Moodle</a>.</p>

<p>The test cases referenced in the autograder&rsquo;s output for are available for download here: <a href="http://people.cs.umass.edu/~liberato/courses/2014-fall-cmpsci383/downloads/samples/assignment10-test-cases.tar.gz">assignment10-test-cases.tar.gz</a></p>

<p>A sample solution in Java is available here: <a href="http://people.cs.umass.edu/~liberato/courses/2014-fall-cmpsci383/downloads/code/HMMInference.tar.gz">HMMInference.tar.gz</a>. The implementation of the filtering algorithm is straightforward and two-part as described in class. The implementation of the Viterbi algorithm is an ugly port of my first draft in Python to Java. I wish I had time to make it beautiful for you all, but like you, I am pressed for time at the end of the semester.</p>

<p>As usual, if you think something in the grading was incorrect (and not in your favor), please email or come to see me.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Exam 3 Graded]]></title>
    <link href="http://people.cs.umass.edu/~liberato/courses/2014-fall-cmpsci383/blog/2014/12/06/exam-3-graded/"/>
    <updated>2014-12-06T16:07:04-05:00</updated>
    <id>http://people.cs.umass.edu/~liberato/courses/2014-fall-cmpsci383/blog/2014/12/06/exam-3-graded</id>
    <content type="html"><![CDATA[<p>Exam 3 has been graded, and the grades are up on <a href="https://moodle.umass.edu">Moodle</a>. The mean was 74. The approximate distribution was as follows:</p>

<pre><code>(90,100]: 8  
(80,90]: 10
(70,80]:  9
(60,70]:  5
(50,60]:  6
(0,50]:   4
</code></pre>

<p>I will have regular office hours Monday; I will email and post on the blog if there is a location change, and if I plan a separate review session.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Assignment 09 Sample Solution and Test Cases]]></title>
    <link href="http://people.cs.umass.edu/~liberato/courses/2014-fall-cmpsci383/blog/2014/12/03/assignment-09-sample-solution-and-test-cases/"/>
    <updated>2014-12-03T05:53:37-05:00</updated>
    <id>http://people.cs.umass.edu/~liberato/courses/2014-fall-cmpsci383/blog/2014/12/03/assignment-09-sample-solution-and-test-cases</id>
    <content type="html"><![CDATA[<p>The test cases referenced in the autograder&rsquo;s output for <a href="http://people.cs.umass.edu/~liberato/courses/2014-fall-cmpsci383/assignments/assignment09">Assignment 09</a> are available for download here: <a href="http://people.cs.umass.edu/~liberato/courses/2014-fall-cmpsci383/downloads/samples/assignment09-test-cases.tar.gz">assignment09-test-cases.tar.gz</a></p>

<p>A sample solution in Java is available here: <a href="http://people.cs.umass.edu/~liberato/courses/2014-fall-cmpsci383/downloads/code/KMeans.tar.gz">KMeans.tar.gz</a>. It implements the algorithm for k-means clustering with the constraints given in the assignment. When computing Euclidean distance between points, it computes the sum of the squares of the dimension-wise differences, but doesn&rsquo;t take the square root of that sum. This is fine, since the square root is a monotonically increasing function of its input.</p>

<p>Some notes on the grading from Patrick:</p>

<blockquote><p>Some people misunderstood the algorithm.</p>

<ul>
<li> For example, one person updated each cluster center by assigning it the value of the data point closest to the mean of the cluster rather than the mean itself.</li>
<li> Another person did something with random numbers that I didn&rsquo;t understand.</li>
<li> Another did not iterate, outputting the first cluster assignment.</li>
</ul>
</blockquote>

<p>I also noticed a pair of mistakes crop up more than once.</p>

<ul>
<li>One mistake was not handling greater than 1 dimension correctly (by ignoring the additional values, or doing something else that was unclear to me). In this case, the two 1d tests passed, but the other tests had errors.</li>
<li>One more subtle mistake was using Manhattan distance (the sum of the absolute value of the dimension-wise differences) rather than the Euclidean distance as specified. This error resulted in only a small number of mis-labelings in the 2d case, but many in the 10d case.</li>
</ul>


<p>As usual, if you think something in the grading was incorrect (and not in your favor), please email or come to see Patrick or me.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Assignment 08 Sample Solution and Test Cases]]></title>
    <link href="http://people.cs.umass.edu/~liberato/courses/2014-fall-cmpsci383/blog/2014/12/02/assignment-08-sample-solution-and-test-cases/"/>
    <updated>2014-12-02T17:06:21-05:00</updated>
    <id>http://people.cs.umass.edu/~liberato/courses/2014-fall-cmpsci383/blog/2014/12/02/assignment-08-sample-solution-and-test-cases</id>
    <content type="html"><![CDATA[<p>The test cases referenced in the autograder&rsquo;s output for <a href="http://people.cs.umass.edu/~liberato/courses/2014-fall-cmpsci383/assignments/assignment08">Assignment 08</a> are available for download here: <a href="http://people.cs.umass.edu/~liberato/courses/2014-fall-cmpsci383/downloads/samples/assignment08-test-cases.tar.gz">assignment08-test-cases.tar.gz</a></p>

<p>A sample solution in Java is available here: <a href="http://people.cs.umass.edu/~liberato/courses/2014-fall-cmpsci383/downloads/code/DecisionTree.tar.gz">DecisionTree.tar.gz</a>. It mostly follows the algorithm in Russell and Norvig. It omits the first termination condition (&ldquo;if <em>examples</em> is empty&rdquo;) since that case will not arise in a tree composed of only boolean attributes (though it didn&rsquo;t hurt to leave it in). You can run the program with only training data specified on the command line to see a crude printout of the tree it learns.</p>

<p>Some notes on the grading:</p>

<ul>
<li>Unlike the naive Bayes classifier, there is ambiguity in the tree your program could correctly learn. If there is a tie in information gain, it&rsquo;s unspecified which attribute the program should select to split on.

<ul>
<li>The <code>small</code> test cases are all intended to be unambiguous in terms of output, so your program&rsquo;s output was evaluated strictly. That is, they had to match the expected output exactly. If you believe I am mistaken here, please send me an email outlining your reasoning. If I&rsquo;m wrong I&rsquo;ll be more than happy to give you (and everyone else) their points back.</li>
<li>The <code>large</code> test cases are somewhat ambiguous, depending upon the exact tree your program constructed, so I evaluated liberally. This means that I checked that the labels were right (I did not examine the probabilities), and that I allowed for a small fraction of misclassification relative to my sample implementation (up to 15% different and you still received full credit).</li>
</ul>
</li>
<li>A common mistake was to stop splitting early when all attributes had an information gain of zero. Some functions require splitting on several attributes. The XOR <code>small</code> test caught this error.</li>
</ul>


<p>As usual, if you think something in the grading was incorrect (and not in your favor), please email or come to see Patrick or me.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Exam 3 Review Session]]></title>
    <link href="http://people.cs.umass.edu/~liberato/courses/2014-fall-cmpsci383/blog/2014/12/02/exam-3-review-session/"/>
    <updated>2014-12-02T12:14:55-05:00</updated>
    <id>http://people.cs.umass.edu/~liberato/courses/2014-fall-cmpsci383/blog/2014/12/02/exam-3-review-session</id>
    <content type="html"><![CDATA[<p><strong>CHANGE OF LOCATION</strong>: The session will be held in CS203, not CS343 as originally announced.</p>

<p>At 1200 on Wednesday 03 December in room <del>343</del> 203 of the Computer Science building, I will hold a question-and-answer-style review session for Exam 3. This room is not my office &ndash; it&rsquo;s a conference room down the hall.</p>

<p>It may be helpful to look over the <a href="http://people.cs.umass.edu/~liberato/courses/2014-fall-cmpsci383/exam-info/exam-3-review">review sheet</a> before this session.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Assignment 09 Graded]]></title>
    <link href="http://people.cs.umass.edu/~liberato/courses/2014-fall-cmpsci383/blog/2014/12/01/assignment-09-graded/"/>
    <updated>2014-12-01T10:11:37-05:00</updated>
    <id>http://people.cs.umass.edu/~liberato/courses/2014-fall-cmpsci383/blog/2014/12/01/assignment-09-graded</id>
    <content type="html"><![CDATA[<p>The <a href="http://people.cs.umass.edu/~liberato/courses/2014-fall-cmpsci383/assignments/assignment09">Assignment 09</a> submissions have been graded. Patrick has posted grades on <a href="https://moodle.umass.edu/">Moodle</a>.</p>

<p>As is the case for the previous assignment, a couple of extensions are still in effect, so for reasons of fairness I have not yet posted the test cases and the sample solution. I will post them as soon as all deadlines are expired. I&rsquo;ll have more to say about the grading then.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Assignment 08 Graded]]></title>
    <link href="http://people.cs.umass.edu/~liberato/courses/2014-fall-cmpsci383/blog/2014/11/30/assignment-08-graded/"/>
    <updated>2014-11-30T16:06:00-05:00</updated>
    <id>http://people.cs.umass.edu/~liberato/courses/2014-fall-cmpsci383/blog/2014/11/30/assignment-08-graded</id>
    <content type="html"><![CDATA[<p>The <a href="http://people.cs.umass.edu/~liberato/courses/2014-fall-cmpsci383/assignments/assignment08">Assignment 08</a> submissions have been graded. Patrick has posted grades on <a href="https://moodle.umass.edu/">Moodle</a>.</p>

<p>A couple of extensions are still in effect, so for reasons of fairness I have not yet posted the test cases and the sample solution. I will post them as soon as all deadlines are expired. I&rsquo;ll have more to say about the grading then.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Reminder: Exam 3]]></title>
    <link href="http://people.cs.umass.edu/~liberato/courses/2014-fall-cmpsci383/blog/2014/11/30/reminder-exam-3/"/>
    <updated>2014-11-30T06:34:17-05:00</updated>
    <id>http://people.cs.umass.edu/~liberato/courses/2014-fall-cmpsci383/blog/2014/11/30/reminder-exam-3</id>
    <content type="html"><![CDATA[<p>Exam 3 is this Wednesday, 03 December at 1900 in AEBN 119. I’ve posted a <a href="http://people.cs.umass.edu/~liberato/courses/2014-fall-cmpsci383/exam-info/exam-3-review">review sheet</a>.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Assignment 07 Graded, Sample Solution Posted]]></title>
    <link href="http://people.cs.umass.edu/~liberato/courses/2014-fall-cmpsci383/blog/2014/11/27/assignment-07-graded/"/>
    <updated>2014-11-27T06:20:27-05:00</updated>
    <id>http://people.cs.umass.edu/~liberato/courses/2014-fall-cmpsci383/blog/2014/11/27/assignment-07-graded</id>
    <content type="html"><![CDATA[<p>The <a href="http://people.cs.umass.edu/~liberato/courses/2014-fall-cmpsci383/assignments/assignment07">Assignment 07</a> submissions have been graded. I have posted grades on <a href="https://moodle.umass.edu/">Moodle</a>.</p>

<p>The test cases referenced in the autograder&rsquo;s output are available for download here: <a href="http://people.cs.umass.edu/~liberato/courses/2014-fall-cmpsci383/downloads/samples/assignment07-test-cases.tar.gz">assignment07-test-cases.tar.gz</a></p>

<p>A Java sample solution is available here: <a href="http://people.cs.umass.edu/~liberato/courses/2014-fall-cmpsci383/downloads/code/NaiveBayesClassifier.tar.gz">NaiveBayesClassifier.tar.gz</a>. The <code>useAlternativeMethod</code> flag indicates which way the classifier will handle <code>?</code> values (see below).</p>

<p>Some notes on the tests and grading:</p>

<ul>
<li><p>Correctness was defined as outputting both the correct class and the correct probability of that class. With a few minor exceptions detailed here and that we accounted for when grading, there was no ambiguity in the correct output. Just outputting the right class label was not sufficient for credit, nor was getting anything but close (±0.01) to the correct probability.</p></li>
<li><p>There were two sets of tests. The <code>small</code> tests were on synthetic data and intended to evoke specific types of errors. For one of them, I used a student&rsquo;s test that was posted to Moodle; many people used it to validate their submission so I thought you should get credit for it. The <code>large</code> tests were on subsets of the full vote data.</p></li>
<li><p>No test explicitly pushed at the boundaries of underflow. (Do not take this to mean that the tests in Assignment 10 won&rsquo;t!) The log transform can lose a small bit of precision, but not enough to matter to the tests we did (within ±0.01 of the correct value). It&rsquo;s not actually necessary to use it unless underflow occurs&mdash;look at <code>estimateProbability()</code> in the solution for an example.</p></li>
<li><p>We accounted for floating-point roundoff errors around 0.5, for example, <code>democrat,0.5000000000000004</code> was acceptable when <code>republican,0.5</code> was the correct answer.</p></li>
<li><p>As noted in the assignment question and answer section, we accepted two distinct ways of handling unknown values. If your program&rsquo;s output didn&rsquo;t match the way that I specified, the autograder re-checked it against the way that Patrick specified. These are the <code>.alt</code>ernative solutions.</p></li>
</ul>


<p>As usual, if you think something is amiss, please email or come see me or Patrick.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Assignment 11 Posted]]></title>
    <link href="http://people.cs.umass.edu/~liberato/courses/2014-fall-cmpsci383/blog/2014/11/24/assignment-11-posted/"/>
    <updated>2014-11-24T13:01:11-05:00</updated>
    <id>http://people.cs.umass.edu/~liberato/courses/2014-fall-cmpsci383/blog/2014/11/24/assignment-11-posted</id>
    <content type="html"><![CDATA[<p><a href="http://people.cs.umass.edu/~liberato/courses/2014-fall-cmpsci383/assignments/assignment11">Assignment 11</a> has been posted. <strong>It is optional.</strong></p>

<p>To complete it, you can re-do a previous assignment or choose a new assignment.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Assignment 10 Posted]]></title>
    <link href="http://people.cs.umass.edu/~liberato/courses/2014-fall-cmpsci383/blog/2014/11/24/assignment-10-posted/"/>
    <updated>2014-11-24T11:17:40-05:00</updated>
    <id>http://people.cs.umass.edu/~liberato/courses/2014-fall-cmpsci383/blog/2014/11/24/assignment-10-posted</id>
    <content type="html"><![CDATA[<p><a href="http://people.cs.umass.edu/~liberato/courses/2014-fall-cmpsci383/assignments/assignment10">Assignment 10</a> has been posted.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Assignment 06 Graded]]></title>
    <link href="http://people.cs.umass.edu/~liberato/courses/2014-fall-cmpsci383/blog/2014/11/24/assignment-06-graded/"/>
    <updated>2014-11-24T09:00:32-05:00</updated>
    <id>http://people.cs.umass.edu/~liberato/courses/2014-fall-cmpsci383/blog/2014/11/24/assignment-06-graded</id>
    <content type="html"><![CDATA[<p>The <a href="http://people.cs.umass.edu/~liberato/courses/2014-fall-cmpsci383/assignments/assignment06">Assignment 06</a> submissions have been graded. Patrick has posted grades on <a href="https://moodle.umass.edu/">Moodle</a>.</p>

<p>The test cases referenced in the autograder&rsquo;s output are available for download here: <a href="http://people.cs.umass.edu/~liberato/courses/2014-fall-cmpsci383/downloads/samples/assignment06-test-cases.tar.gz">assignment06-test-cases.tar.gz</a></p>

<p>Two notes:</p>

<ul>
<li>Because the simulator(s) you wrote were stochastic, the autograder accepted as correct any output within 15% of the correct value. That is, for each possible setting of query values,
if |prob_expected - prob_observed| / prob_expected &lt; 0.15, then your simulator passed the given test case. There was a chance some values would be wrong just due to randomness. Patrick watched for this case and adjusted grades upward if he suspected it was occurring. If you think he overlooked such a case, send us both email and we&rsquo;ll investigate. Generally, if this occurred at all, it occurred on test case <code>5-j-m.query</code>.</li>
<li>According to Patrick, &ldquo;Many students parsed and/or created json with their own code rather than a library, which caused many mistakes.&rdquo;</li>
</ul>


<p>As usual, if you think something is amiss, please email or come see me or Patrick.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Assignment 06 Sample Solution]]></title>
    <link href="http://people.cs.umass.edu/~liberato/courses/2014-fall-cmpsci383/blog/2014/11/21/assignment-06-sample-solution/"/>
    <updated>2014-11-21T13:42:40-05:00</updated>
    <id>http://people.cs.umass.edu/~liberato/courses/2014-fall-cmpsci383/blog/2014/11/21/assignment-06-sample-solution</id>
    <content type="html"><![CDATA[<p>A sample solution in Java for Assignment 06 is available here: <a href="http://people.cs.umass.edu/~liberato/courses/2014-fall-cmpsci383/downloads/code/ApproximateInference.tar.gz">ApproximateInference.tar.gz</a>.</p>

<p>I had the brilliant idea (ha-ha) that I&rsquo;d write this one up in a largely imperative style, passing and mutating arrays and array indices, in an attempt to get it to run quickly. It does run fairly fast (the Gibbs sampler gets around 2M samples / second on my desktop computer). Part of the cost of using this style is that it took a little longer than I expected to complete; it also is less readable than I&rsquo;d like.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Assignment 09 Posted]]></title>
    <link href="http://people.cs.umass.edu/~liberato/courses/2014-fall-cmpsci383/blog/2014/11/18/assignment-09-posted/"/>
    <updated>2014-11-18T14:07:39-05:00</updated>
    <id>http://people.cs.umass.edu/~liberato/courses/2014-fall-cmpsci383/blog/2014/11/18/assignment-09-posted</id>
    <content type="html"><![CDATA[<p><a href="http://people.cs.umass.edu/~liberato/courses/2014-fall-cmpsci383/assignments/assignment09">Assignment 09</a> has been posted.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Exam 2 Graded]]></title>
    <link href="http://people.cs.umass.edu/~liberato/courses/2014-fall-cmpsci383/blog/2014/11/10/exam-2-graded/"/>
    <updated>2014-11-10T13:40:15-05:00</updated>
    <id>http://people.cs.umass.edu/~liberato/courses/2014-fall-cmpsci383/blog/2014/11/10/exam-2-graded</id>
    <content type="html"><![CDATA[<p>Exam 2 has been graded, and the grades are up on <a href="https://moodle.umass.edu">Moodle</a>. I&rsquo;ll have additional comments in class on Wednesday.</p>

<p>A note: Each term exam is weighted equally. This exam is not worth twice as much as Exam 1!</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Assignment 08 Posted]]></title>
    <link href="http://people.cs.umass.edu/~liberato/courses/2014-fall-cmpsci383/blog/2014/11/10/assignment-08-posted/"/>
    <updated>2014-11-10T10:42:42-05:00</updated>
    <id>http://people.cs.umass.edu/~liberato/courses/2014-fall-cmpsci383/blog/2014/11/10/assignment-08-posted</id>
    <content type="html"><![CDATA[<p><a href="http://people.cs.umass.edu/~liberato/courses/2014-fall-cmpsci383/assignments/assignment08">Assignment 08</a> has been posted.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Assignment 05 Sample Solution in Java]]></title>
    <link href="http://people.cs.umass.edu/~liberato/courses/2014-fall-cmpsci383/blog/2014/11/07/assignment-05-sample-solution-in-java/"/>
    <updated>2014-11-07T12:28:33-05:00</updated>
    <id>http://people.cs.umass.edu/~liberato/courses/2014-fall-cmpsci383/blog/2014/11/07/assignment-05-sample-solution-in-java</id>
    <content type="html"><![CDATA[<p>At multiple students&#8217; requests, I&rsquo;ve transliterated the <a href="http://people.cs.umass.edu/~liberato/courses/2014-fall-cmpsci383/blog/2014/10/27/assignment-05-sample-solution/">Python solution to Assignment 05</a> into Java. You can download it here: <a href="http://people.cs.umass.edu/~liberato/courses/2014-fall-cmpsci383/downloads/code/FJDQuery.tar.gz">FJDQuery.tar.gz</a>.</p>

<p>This is a fairly direct translation that takes the same approach as the Python previously posted. The entire dataset is loaded, then filtered by the condition in the query. Then, each line of the output is generated by creating another subset of the data, corresponding to exactly one possible setting of the query variables.</p>

<p>I suggest you eyeball the Cartesian product code in <code>Query.java</code>. The implementation I wrote is recursive.  Recursion is a convenient way to think about things, but can cause problems in some languages (like Java) if too many recursive calls are nested. With prior knowledge of the data set we were working with, I knew it wouldn&rsquo;t be a problem here.</p>

<p>You should understand how this method works, and perhaps take the time to translate it to an iterative form if you&rsquo;re rusty on the equivalence between recursive and iterative algorithms. If you don&rsquo;t know how to do that, then dust off your 220 notes, or come see me and we can talk about it.</p>

<p>The solution clocks in at about 150 source lines of code, which is within the typical range of expansion I expect when going from Python to Java (1.5x &ndash; 3x). The extra length in Java comes from a few things. For example, Python has less boilerplate and supports very useful syntax sugar to reduce code length (such as <a href="https://en.wikipedia.org/wiki/List_comprehension">list comprehensions</a>).</p>

<p>Python also has a more comprehensive standard library. The input code in Python is a line or two, where Java took about a dozen; similarly, generating the Cartesian product of variable settings is a library call in Python but needs to be written in Java. You can add third-party JARs to Java to help cut down on code length (e.g., <a href="http://opencsv.sourceforge.net/">OpenCSV</a> to read <code>car.data</code> and <a href="https://github.com/google/guava">Guava</a> for many things, including Cartesian product). I chose not to do that so as to keep this solution self-contained, but you might consider it in future assignments. A drawback to this approach is that you have to understand the third-party API well enough to be sure you&rsquo;re using it correctly.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Assignment 07 Posted]]></title>
    <link href="http://people.cs.umass.edu/~liberato/courses/2014-fall-cmpsci383/blog/2014/11/03/assignment-07-posted/"/>
    <updated>2014-11-03T16:35:00-05:00</updated>
    <id>http://people.cs.umass.edu/~liberato/courses/2014-fall-cmpsci383/blog/2014/11/03/assignment-07-posted</id>
    <content type="html"><![CDATA[<p><a href="http://people.cs.umass.edu/~liberato/courses/2014-fall-cmpsci383/assignments/assignment07">Assignment 07</a> has been posted.</p>
]]></content>
  </entry>
  
</feed>
