## 3 Proposed Method
### Algorithm for Joint Discretization and Grouping
To implement it, instead of one best solution, at each iteration of the algorithm, it is required to save several best solutions, and then it is for them to perform the subsequent merging of categories. To prevent the number of such solutions from growing to unacceptable values, it is proposed to limit them to a fixed value \(m\), which is the same for each iteration. In order to store information about all the best solutions at a given iteration of the relative initial (rather than current) partitions of the explanatory variables, it is proposed to use lists of clusters formed by the levels of factors as a result of their merging. For categorical factors, the initial numbering of levels is set in an arbitrary order, for quantitative variables--it is set in ascending order of their values. At the initialization stage, each level is placed in its own cluster with the corresponding number. Thus, for example, for the factor \(x_{1}\) with \(T_{0}\) original levels, the list of clusters \(L_{11}\) at the first step contains \(T_{0}\) elements [1,..., \(T_{0}\)]. If the \(k\)-th best solution involves combining the levels \(t_{1}\) and \(t_{2}\) (\(t_{1}<t_{2}\)), then in the list \(L_{1k}\) the element \(t_{2}\) is reset to zero, and the element \(t_{2}\) is added to the element \(t_{1}\). For a newly formed cluster consisting of levels \(t_{1}\) and \(t_{2}\), the goodness function is calculated according to the relation (3), since the subsets with levels \(t_{1}\) and \(t_{2}\) are replaced by one new subset (\(t_{1}\lor t_{2}\)). Thus, the developed algorithm includes the following steps (Algorithm 1). Input: raw data includes response values, quantitative exploratory variable \(x_{1}\) with \(T_{0}\) levels, and qualitative exploratory variable \(x_{2}\) with \(J_{0}\) levels. We set a constant \(c\) for the goodness function (2), the number \(m\) of best solutions, fixed and stored at each iteration. Step 1. Set \(H=1\). Form the initial cluster lists \(L_{1H}\), \(L_{2H}\). Step 2. Calculate the value \(Q_{0}\) of function (2) according to the initial data. Step 3. For \(h\) from 1 to \(H\) do  
Step 3.1. Form subsets \(G_{1 Hj}\) in accordance with the lists of clusters \(L_{1H}\) and \(L_{2h}\). Step 3.2. If the number of non-zero clusters in the list \(L_{1H}\) (\(L_{2h}\)) does not exceed 2, then \(t_{1}=t_{2}=0\) (\(j_{1}=j_{2}=0\)). Step 3.3. For each pair of nonzero neighboring clusters \(t_{1}\), \(t_{2}\) from the list \(L_{1h}\) and for \(t_{1}=t_{2}=0\), and each pair of nonzero clusters \(j_{1}\) and \(j_{2}\) from the list and for \(j_{1}=j_{2}=0\), perform:  
Step 3.3.1. If \(t_{1}=t_{2}=0\) (\(j_{1}=j_{2}=0\)), then the merging for the first (second) exploratory variable is not performed. Step 3.3.2. Calculate the values \(Q_{1}\) of the goodness function using the Formula (3):  
- if the merging occurs for two variables, then subsets \(G_{1 Hj}\), \(G_{1 Hj}\), \(G_{1 Hj}\), \(j^{\prime}\
eq j_{1},j_{2}\) are replaced by the subset \(G_{1H(t_{1}\lor j_{1})j^{\prime}}\), subsets \(G_{1 Hj}\), \(G_{1 Hj}\), \(G_{1 Hj}\  
It is clearly seen that for \(m=1\) the best solution was never achieved, that is, the original greedy version of the algorithm never gave a global optimum. Therefore, the proposed modification of the algorithm with a partial screening of solutions provides better results in comparison with a greedy version presented by the authors of [68]. However, since the proportion of cases where the best result was achieved does not grow with increasing of \(m\), it is impossible to recommend a certain value \(m\) at which the best results are guaranteed. Thus, with each new application of the algorithm, a preliminary adjustment is required, which consists in calculating for several consecutive values of \(m\) and choosing the best solution. Let us denote by \(m^{*}\) minimum value of \(m\) at which the best value of the goodness function \(Q\) was achieved.