# Relaxed Rule-Based Learning for Automated Predictive Maintenance: Proof of Concept
## 2 Relaxed Separate-and-Conquer Rule Learning approach
The function \(IsChosen\) operates when no AVP has been chosen yet to add to the current rule and this function decides whether the currently considered interval is a viable (though possibly not the best) candidate for the rule growth. The function \(IsReplaced\) operates when there is already a candidate AVP to be returned and a new one is considered, and the function decides whether the new AVP is preferable to the current favorite. It is the responsibility of \(IsChosen\) to ensure that the whole algorithm does not enter into an infinite loop. In particular, when all the rows with outcome 1 have been covered by the current collection of rules, \(IsChosen\) must reject all the candidate AVPs. Then an empty rule will be returned by the function \(FormRule\) and the run of the main function \(RSC\) will be terminated. In order to describe functions \(IsChosen\) and \(IsReplaced\) we need to introduce new terminology. First of all, each row of table \(DATA\) is associated with its index (as usual row 1, row 2, and so on). When we refer to a set of rows, we mean the set of their respective numbers. Let \(R\) be a rule. We denote by \(POS(R)\) and \(NEG(R)\) the sets of rows covered by \(R\) that respectively have positive and negative outcomes. That is, \(POS(R)\cup NEG(R)\) is the total set of rows covered by \(R\). **Definition 5**. : _The precision \(prec(R)\) of a rule \(R\) is defined as follows. If \(POS(R)\cup NEG(R)=\emptyset\) then \(prec(R)=0\). Otherwise, \(prec(R)=|POS(R)|/(|POS(R)|+|NEG(R)|)\)._

Let \(\mathbf{C}\) be a collection of rules. Then \(POS(\mathbf{C})=\bigcup_{R\in\mathbf{C}}POS(R)\). In other words, the positive rows covered by the collection is the union of the positive rows covered by the rules in this collection. Definition 6: Let \(\mathbf{C}\) be a collection of rules and let \(R\) be a rule such that \(R\
otin\mathbf{C}\). Then the free coverage of \(R\) w.r.t. \(\mathbf{C}\) is \(\mathit{POS}(R)\setminus\mathit{POS}(\mathbf{C})\) and it is denoted by \(\mathit{Free}(R,\mathbf{C})\). In other words, the free coverage corresponds to the positive rows that are covered by the new rule \(R\) being formed but is not covered by the current collection \(\mathbf{C}\) of rules. ```
functionChooseNext(\(\mathit{Collection}\), \(Rule\)) \(CurV\gets nil\) for each half-interval \(AVP\)do if\(CurAVP=nil\)then ifIsChosen(\(\mathit{Collection}\), \(Rule\), \(AVP\))then \(CurAVP\gets AVP\) endif else ifIsReplaced(\(\mathit{Collection}\), \(Rule\), \(CurAVP\), \(AVP\))then \(CurAVP\gets AVP\) endif endif endfor return\(CurAVP\) endfunction
```
**Algorithm 2** ChooseNext heuristic for RSC approach. The pseudocode of the function _IsChosen_ is given in Algorithm 3. _IsChosen_ uses two parameters (thresholds) _init_free_ and _init_prec_. They are not specified by the algorithm and their right value is determined by experiments. Thus _IsChosen_ decides to not grow the rule with \(AVP\) if the result of adding \(AVP\) to the current rule covers less 'new' positive rows than the specified threshold. For this condition to prevent the whole algorithm running into an infinite loop, _init_free_ must be at least 1. Setting the parameter to a larger value will force the new rules to cover more new positive rows and, as a result, to potentially decrease the total number of rules needed. The initial precision threshold _init_prec_ is not necessary for a properly functioning algorithm. However, making sure that the initial precision is sufficiently high, the algorithm potentially avoids creation of too long rules. The pseudocode of the function _IsReplaced_ is provided in Algorithm 3. _IsReplaced_ compares two different AVPs to be added to the current rule. In order to compare them, _IsReplaced_ forms two new rules, \(Rule_{1}\) and \(Rule_{2}\), \(Rule_{1}\) with the current best candidate to be added to the current rule and \(Rule_{2}\) with a new AVP added. If the \(Rule_{2}\) covers less new rows than \(init\_free\) then the new AVP is immediately discarded.