From e020fb4317bc2347006bc1444f2e91c4fe6eb1b2 Mon Sep 17 00:00:00 2001 From: Martin Date: Tue, 6 Feb 2018 21:02:15 +0100 Subject: Minor corrections. --- aied2018/rules.tex | 69 +++++++++++++++++++++++++++--------------------------- 1 file changed, 34 insertions(+), 35 deletions(-) (limited to 'aied2018/rules.tex') diff --git a/aied2018/rules.tex b/aied2018/rules.tex index ff47939..acdd8a6 100644 --- a/aied2018/rules.tex +++ b/aied2018/rules.tex @@ -1,24 +1,26 @@ \section{Learning rules} \label{sec:rules} -The goal of learning rules in this paper is to discover and explain common approaches and mistakes in student programs. We use a rule learner called ABCN2e, implemented within the Orange data mining library~\cite{demsar2013orange}. ABCN2e modifies the original CN2 algorithm~\cite{clarkECML1991} to learn unordered rules; modifications are described in a technical report at \url{https://ailab.si/abml}. +The goal of learning rules in this paper is to discover and explain common approaches and mistakes in student programs. We use a rule learner called ABCN2e, implemented within the Orange data mining library~\cite{demsar2013orange}. ABCN2e modifies\footnote{Modifications are described in a technical report available at \url{https://ailab.si/abml}.} the original CN2 algorithm~\cite{clarkECML1991}. General rule-learning algorithms, such as CN2, tend to generate many specific rules. This produces more accurate results but makes rules harder to explain. This section describes the problem-specific configuration of the rule-learning algorithm for extracting relevant and explainable patterns from student programs. -Each program is represented in the feature space of AST patterns described in the previous section. Based on test results each program is classified either as \emph{correct} or \emph{incorrect}. A program can be incorrect for one of two reasons: either a) it contains some incorrect pattern (a buggy pattern) that should be removed or modified, or b) it is missing one or more programing constructs (patterns) that should be present for the program to be correct. +Each program is represented in the feature space of AST patterns described in the previous section. Based on test results each program is classified either as \emph{correct} or \emph{incorrect}. Our main motivation for learning rules bases on assumption that the patterns highly correlated with incorrect programs represent mistakes. -Classification rules can express both reasons. For buggy patterns we learn rules for incorrect programs, where each condition in the rule must express the presence of a pattern. The condition of such a rule therefore contains a set of patterns that imply a bug in the program. For missing patterns, we learn another set of rules covering programs that are not covered by above rules. These rules may contain missing patterns within their conditions, and describe the missing constructs in a program that have to be implemented. All rules explaining incorrect programs are called \emph{n-rules}. +A program can be incorrect for one of two reasons: either a) it contains some incorrect pattern (a buggy pattern) that should be removed or modified, or b) it is missing one or more programing constructs (patterns) that should be present for the program to be correct. + +Classification rules can express both reasons. To identify buggy patterns we learn a set of rules covering incorrect programs, where each condition in the rule must express the presence of a pattern. For missing patterns, we learn another set of rules, which may contain missing patterns within their conditions, and describe the missing constructs in a program that have to be implemented. All rules explaining incorrect programs are called \emph{n-rules}. To learn explainable, meaningful and non-redundant rules, we impose the following additional constraints on the rule learner: \begin{itemize} - \item classification accuracy of each rule must exceed 90\%, because we accept a 10\% false-positive error as acceptable; - \item each conjunct in the condition of a rule must be significant according to the likelihood test, meaning that each pattern in the condition part is indeed relevant (we set the significance threshold to p=0.05); + \item classification accuracy of each rule must exceed 90\%, because we deem a 10\% false-positive error as acceptable; + \item each term in the condition of a rule must be significant according to the likelihood test, meaning that each pattern in the condition part is indeed relevant (we set the significance threshold to p=0.05); \item a condition can have at most 3 patterns; and - \item each rule must cover at least 5 distinct programs -- this avoids redundant rules that represent the same error with a different combination of patterns. + \item each rule must cover at least 5 distinct programs -- to avoid learning redundant rules representing the same error. \end{itemize} -Different approaches can be represented with rules explaining correct programs. A program is correct when it implements all required patterns and no buggy patterns. There may be several possible sets of required patterns for each exercise, with each set corresponding to a different approach to solving it. +To identify different approaches to solving an exercise, we learn rules that explain correct programs. A program is correct when it implements all required patterns and no buggy patterns. There may be several possible sets of required patterns for each exercise, with each set corresponding to a different approach. We use the same constraints as in the case of n-rules and learn rules for correct programs called \emph{p-rules}. In this case, we always require that conditions mention the presence of patterns, since it is easier to explain different approaches of students with something they have written and not with something they have not. To account for possible buggy patterns, the requirement to achieve 90\% classification accuracy was not evaluated on full data, but only on data not covered by n-rules. Hence, a rule can cover an example with a specific approach even though it contains a buggy pattern. @@ -63,8 +65,8 @@ P5 ∧ P35 ⇒ incorrect [72, 0] Pattern \textsf{P5} matches programs where the result of the \texttt{input} call is not cast to \texttt{float} but stored as a string. Pattern \textsf{P35} matches programs where the value 32 is subtracted from a variable on the left-hand side of a multiplication. Sample programs matching the first rule (left) and the second rule (right) are: \begin{Verbatim} -g2 = input() g2 = \blue{input}('Temperature [F]? ') -g1 = \blue{int}(g2) g1 = (\red{(g2 - 32) *} (5 / 9)) +g2 = input() g2 = \blue{\underline{input}}('Temperature [F]? ') +g1 = \blue{\underline{int}}(g2) g1 = (\red{\dashuline{(g2 - 32) *}} (5 / 9)) print(((g1-32)*(5/9))) print(g2, 'F equals', g1, 'C') \end{Verbatim} @@ -93,11 +95,11 @@ P80 ⇒ correct [0, 38] \noindent Patterns in the condition of the first rule, \textsf{P2} and \textsf{P8}, correspond respectively to expressions of the form \texttt{float(input(?))} and \texttt{print((?-32)*?)}. Programs matching both patterns wrap the function \texttt{float} around \texttt{input}, and have an expression that subtracts 32 and then uses multiplication within the \texttt{print}. -This first rule demonstrates an important property of p-rules: although patterns \textsf{P2} and \textsf{P8} are in general not sufficient for a correct program (it is trivial to implement a matching but incorrect program), only one out of 201 student submissions matching these patterns was incorrect. This suggests that the conditions of p-rules represent the critical elements of the solution. Once a student has figured out these patterns, they are almost certain to have a correct solution. A sample program matching the first rule is: +This first rule demonstrates an important property of p-rules: although patterns \textsf{P2} and \textsf{P8} are in general not sufficient for a correct program (it is trivial to implement a matching but incorrect program), only one out of 201 student submissions matching these patterns was incorrect. This suggests that the conditions of p-rules represent the critical elements of the solution. Once students have figured out these patterns, they are almost certain to have a correct solution. A sample program matching the first rule is: \begin{Verbatim} -g1 = \blue{float(input(}'Temperature [F]: ')) -print(((g1 \red{- 32) *} (5 / 9))) +g1 = \blue{\underline{float(input(}}'Temperature [F]: ')) +print(((g1 \red{\dashuline{- 32) *}} (5 / 9))) \end{Verbatim} \noindent @@ -105,7 +107,7 @@ The second and third p-rules are variations of the first. For instance, the seco \begin{Verbatim} g1 = input('Fahrenheit?') -g0 = (\blue{(float(g1) - 32)} * (5 / 9)) +g0 = (\blue{\underline{(float(g1) - 32)}} * (5 / 9)) print(g0) \end{Verbatim} @@ -122,10 +124,9 @@ def max_abs(l): return vmax \end{Verbatim} -We have received 155 submissions (57 correct, 98 incorrect) for this exercise. Due to its higher complexity and since the solutions are much more diverse, we obtained 8298 patterns to be used as attributes in learning. High number of patterns together with a low number of learning examples could present a problem for rule learning: since the space of possible rules is large, some of the learned rules might be a result of statistical anomalies. One needs to apply a certain amount of caution when interpreting these rules. - -The rule-learning algorithm learned 15 n-rules (7 mentioning only presence of patterns) and 6 p-rules. Below we can see the two best n-rules referring to the presence of patterns and two programs; the left one is covered by the first rule, and the right one by the second rule: +We have received 155 submissions (57 correct, 98 incorrect) for this exercise. Due to its higher complexity and since the solutions contain definitions of lists, we obtained 8298 patterns to be used as attributes in learning. High number of patterns together with a low number of learning examples could present a problem for rule learning, since the large number of candidate rules could lead to statistical anomalies. Still, most of the learned rules seem valuable. +The rule-learning algorithm learned 15 n-rules (7 mentioning only presence of patterns) and 6 p-rules. Below we can see the two best n-rules referring to the presence of patterns and two programs (left for first rule, right for second): \begin{Verbatim}[fontfamily=sf] P64 ⇒ incorrect [22, 0] P2 ∧ P70 ⇒ incorrect [17, 0] @@ -135,14 +136,14 @@ P2 ∧ P70 ⇒ incorrect [17, 0] def max_abs(l): def max_abs(l): vmax = 0 vmax = None for i in range(len(l)): for v in l: - if \blue{vmax} < abs(l[i]): if vmax==None or vmax