## 3 Orthogonal Matrix-Autoencoder-Based Encoding Method for Unordered Multi-Categorical Variables
### Code Generation  
The \(N\)-order square matrix is set as \(\mathbf{A}\in\mathbb{R}^{N\times N}\), \(\mathbf{A}=[\mathbf{a_{1}},\mathbf{a_{2}},\cdots,\mathbf{a_{i}},\cdots,\mathbf{a_{N}}]\), where \(\mathbf{a_{i}}\) is the column vector of \(\mathbf{A}\) and \(\mathbf{a_{i}}=[a_{i}^{1},a_{i}^{2},\cdots,a_{i}^{N}]^{T}\). There exists a series of transformations that decompose \(\mathbf{A}\) into an orthogonal matrix \(\mathbf{Q}\) and an upper triangular matrix \(\mathbf{R}\), i.e., \(\mathbf{A}=\mathbf{Q}\mathbf{R}\). These transformations are also called QR decomposition of \(\mathbf{A}\). Figure 1: O-AE for unordered multi-categorical variable encoding and dimensionality reduction process. The orthogonal matrix \(\mathbf{Q}\) is set to consist of \(N\) column vectors, \(\mathbf{Q}=[q_{1},q_{2},\cdots,q_{i},\cdots,q_{N}]\), where \(\mathbf{q}_{i}=\left[q_{1}^{1},q_{i}^{2},\cdots,q_{i}^{N}\right]^{T}\). The row and column vectors of an orthogonal matrix are two-by-two orthogonal unit vectors. \[\mathbf{Q}\mathbf{Q}^{T}=\mathbf{Q}^{T}\mathbf{Q}=\mathbf{E} \tag{9}\]  
\[\mathbf{q}_{i}^{T}\mathbf{q}_{j}=\left\{ \begin{array}{c}\mathbf{0},i\
eq j\\ \mathbf{1},i=j\end{array} \right. \tag{10}\]  
\[\left\|q_{i}\right\|_{2}=\mathbf{1} \tag{11}\]  
Therefore, mapping unordered multi-categorical variables into orthogonal numerical codes can ensure that the different categories are independent of each other in terms of location, are equal distances, and are the same size, and at the same time increase the data richness to avoid underfitting in the subsequent prediction process brought about by data impoverishment. The steps for encoding unordered multi-categorical variables using an orthogonal matrix are as follows. (1) Construct \(N\)-order square matrix \(\mathbf{A}\in\mathbb{R}^{N\times N}\) based on the number of categories \(N\) in the unordered multi-categorical variables. (2) Perform the QR decomposition of \(\mathbf{A}\) using the Gram-Schmidt orthogonal transformation to obtain the orthogonal matrix \(\mathbf{Q}\in\mathbb{R}^{N\times N}\). The Gram-Schmidt orthogonal transformation is able to convert non-orthogonal bases into orthogonal bases by first orthogonalizing the non-orthogonal bases and, second, unitizing them. \[\left\{ \begin{array}{l}\widetilde{\mathbf{q}}_{\mathbf{1}}=\mathbf{a}_{\mathbf{1}}\\ \widetilde{\mathbf{q}}_{\mathbf{2}}=\mathbf{a}_{\mathbf{2}}-\frac{\left\langle\mathbf{a}_{\mathbf{2}} \widetilde{\mathbf{q}}_{\mathbf{1}}\right\rangle}{\left\langle\widetilde{\mathbf{q}}_\mathbf{{1}}\widetilde{\mathbf{q}}_{\mathbf{1}}\right\rangle}\widetilde{\mathbf{q}}_{\mathbf{1}}\\ \cdots\\ \widetilde{\mathbf{q}}_{\mathbf{N}}=\mathbf{a}_{\mathbf{N}}-\frac{\left\langle\mathbf{a}_{\mathbf{N}} \widetilde{\mathbf{q}}_{\mathbf{1}}\right\rangle}{\left\langle\widetilde{\mathbf{q}}_\mathbf{{1}}\widetilde{\mathbf{q}}_{\mathbf{1}}\right\rangle}\widetilde{\mathbf{q}}_{\mathbf{1}}-\frac {\left\langle\mathbf{a}_{\mathbf{N}}\widetilde{\mathbf{q}}_{\mathbf{2}}\right\rangle}{\left \langle\widetilde{\mathbf{q}}_{\mathbf{2}}\widetilde{\mathbf{q}}_{\mathbf{2}}\right\rangle} \widetilde{\mathbf{q}}_{\mathbf{2}}\cdots-\frac{\left\langle\mathbf{a}_{\mathbf{N}}\widetilde{ \mathbf{q}}_{\mathbf{N}-1}\right\rangle}{\left\langle\widetilde{\mathbf{q}}_{\mathbf{N}-1} \widetilde{\mathbf{q}}_{\mathbf{N}-1}\right\rangle}\widetilde{\mathbf{q}}_{\mathbf{N}-1}\\ \\ \end{array} \right. \tag{12}\]  
\[\mathbf{Q}=[\mathbf{q}_{\mathbf{1}},\mathbf{q}_{\mathbf{2}},\cdots,\mathbf{q}_{\mathbf{i}},\cdots,\mathbf{q}_ {\mathbf{N}}] \tag{13}\]  
(3) Construct the \(N\)-order identity matrix \(\mathbf{E}\). Using matrix multiplication, map the orthogonal matrix to the original unordered multi-categorical variables one by one according to the position indexes to obtain the orthogonal numerical code matrix \(\mathbf{X}\in\mathbb{R}^{N\times N}\), which consists of row vectors. \[CV: \begin{bmatrix}c_{1}\\ c_{2}\\ \cdots\\ c_{i}\\ \cdots\\ c_{N}\end{bmatrix} \rightarrow\mathbf{X}: