# Relaxed Rule-Based Learning for Automated Predictive Maintenance: Proof of Concept
## 2 Relaxed Separate-and-Conquer Rule Learning approach
Randomly generate a collection of \(\mathbf{C}\) having number of rules \(num\_rules\). Each rule is a random generation of \(len\_rule\) AVPs that can be done as follows. 1. Randomly choose \(len\_rule\) attributes for the given rule. 2. For each chosen attribute \(attr\), randomly generate an interval \([a,b]\) such that \(0\leq a\leq b\leq max\_val\) and the resulting AVP is \((attr,[a,b])\). 3. Randomly generate \(num\_rows\) of the 'truth' table for the above rules in order to create a training set. A row of the truth table is generated as follows. 1. Randomly generate a value for each attribute between \(0\) and \(max\_val\). 2. Let \(tp\) be the resulting tuple of attribute values. 3. If \(tp\) is covered by \(\mathbf{C}\) then \(out=1\), otherwise \(out=0\). 4. Add \(out\) in the last column of \(tp\). To make the work of a rule learner more complicated, we also generate rows by introducing a _random noise_. In order to do this, we choose a small parameter \(noise\_prob\) (e.g. 0.005) and then, in the above algorithm, after having computed the outcome, alter it with probability \(noise\_prob\). Example 3 demonstrates the experiment. **Example 3**. : _Suppose \(max\_val=1\) that means that all the attribute values are binary: \(0\) or \(1\). Moreover, this also means that the collection of rules become Disjunctive Normal Forms (DNFs)._

_Then \(num\_rules\) becomes the number of conjuncts and \(len\_rule\) becomes the length of the conjuncts. Suppose that both of them equal \(2\). Let the collection of rules be \((x_{1}\wedge x_{2})\vee(x_{3}\wedge x_{4})\). Let also the number of attributes be \(10\). Thus we have defined the function \(f(x_{1},\ldots,x_{10})=(x_{1}\wedge x_{2})\vee(x_{3}\wedge x_{4})\). The whole dataset is just the truth table of this function. The \(num\_rows\) parameter is the size of the training set (seen by the algorithm). These \(num\_rows\) rows are randomly selected out of the whole dataset. A RL algorithm is supposed to guess the whole function out of these rows._

### Testing and analysis of the results. Now, suppose a RL algorithm returns a collection of rules \(g\). How can we determine the closeness of \(g\) to the function \(f\) induced by the collection of rules? The truth table of \(g\) consists of the same tuples as the truth table of \(f\) (but the values of the function can, of course be different). Therefore, we proceed as follows. 1. Calculate the numbers of rows that are satisfied by \(f\), \(g\) and \(f\wedge g\) (both \(g\) and \(f\)) and denote them by \(|f|\), \(|g|\) and \(|f\wedge g|\), respectively. 2. The number \(|f\wedge g|/|f|\) is the percent of rows covered by \(f\) that are also covered by \(g\). The larger this number the better is the quality of the learned model. 3. The number \(|f\wedge g|/|g|\) is the percent of rows covered by \(g\) that are also covered by \(f\). The larger this number the smaller the number of rows of \(g\) that are not covered by \(f\) and the better the quality of \(g\). Note that the computation of the number of rows is in general an intractable problem. However, since we consider small collections of small rules this can be done by a brute-force algorithm. We test the algorithms (RSC, SeCo, and DT) in the modes specified by the following parameters. 1. The number of _extra variables_. Extra variables are those that do not take part in the rules of \(f\). They are inessential, however their presence can seriously hinder performance of an RL algorithm. Getting rid of such variables is the main task of the _feature selection_ algorithm. We consider two extreme modes: few extra variables and many extra variables. We gradually increase the number of variables in order to see a point where the rule learner starts to work much worse. In case of many variables, the performance can be significantly improved with the introduction of feature selection algorithms. However, in this experiment we want to see how the algorithm deals alone with this matter.