# Two-Stage Dimensionality Reduction for Social Media Engagement Classification
## 3 Proposed Algorithm
### Second Stage--Multiobjective Optimization  
The optimization problem for the second stage is to find a unique transformation function that maximizes the distance between different cluster centers while minimizing the spread between instances within the same class [11]. The cluster center is represented by the arithmetic mean of all the points belonging to the cluster (class). Assume that \(X^{k}_{m_{k}\times n}\) includes all instances of class \(k\) (a _subset_ of \(S_{k}\)), where each line corresponds to an instance. We transform each row of this matrix via the function \(F\) so that we obtain \(Y^{k}_{m_{k}\times p}\). We define \(\overrightarrow{a}^{k}\), a vector of \(p\) dimensions, as the cluster center of all \(m_{k}\) instances in \(Y^{k}_{m_{k}\times p}\), according to Equation (12).  
\[\overrightarrow{a}^{k}=\frac{1}{m_{k}}\sum_{i=1}^{m_{k}}\overrightarrow{y}^ {i} \tag{12}\]  
The vector \(\overrightarrow{y}^{i}\) is the i-th row of \(Y^{k}_{m_{k}\times p}\). We also define the scalar \(v^{k}\) as the norm of the eigenvalues of the covariance matrix of \(Y^{k}_{m_{k}\times p}\), according to Equation (13).  
\[v^{k}=\left\|\operatorname*{Eig}(\operatorname*{Cov}(Y^{k}_{m_{k}\times p}))\right\| \tag{13}\]  
We determine \(\operatorname*{Cov}(.)\) to be the covariance operator and \(\operatorname*{Eig}(.)\) to be the calculation of the eigenvalues of the input matrix. The value of \(v^{k}\) indicates how many instances of class \(k\) are distributed around its center through its most important directions (eigenvectors). The objective of the method is to adapt the \(F\) transform so that \(v^{k}\) is minimized for all \(k\), while the distances between the cluster centers are maximized. This can be formulated as a multi-objective optimization problem, as per Equation (14), and calculated as described in Algorithm 2.  
\[\Omega=\begin{cases}\max\big{\|}\overrightarrow{a}^{i}-\overrightarrow{a}^{ j}\big{\|}&\text{for all }j>i\\ \min v^{i}&\text{for all }i\end{cases}\quad i,j\in\{1,\ldots,c\} \tag{14}\]  
In this work, Equation (14) is solved by finding the minimum of the unconstrained multivariable function \(\Omega\) using a derivative-free interior-point method [19]. In other words, a nonlinear programming solver is used to search for the minimum of the function and thus to find the optimal coefficients.  
From the matrix, once the coefficients have been found, a matrix product is produced between it and the high-quality features subset obtained in the first stage. This results in the final (and reduced) subset are to be forwarded to subsequent methods. As in linear discriminant analysis, the proposed algorithm can be used only as dimensionality reduction method for a subsequent classifier or also as a classifier itself when using the proposed built-in discriminator described in Section 3.3.  
```
0: Subspace \(W^{*}\) (hereby referred as \(x\)) from the first stage.
0: Optimal subspace \(\{X,T\}\).
1:Step 1
2: Solve \(\Omega\) following \(\Omega=\min\frac{\gamma+\sum_{j=1}^{x}p^{k}}{(\prod_{i}^{c}\prod_{j=i+1}^{c} \left\|\overrightarrow{a^{j}}-\overrightarrow{a^{j}}\right\|)^{\frac{1}{2(c-1)}}}\).
3:Step 2
4: Find the subspace \(X\) by calculating \(X=\Omega\times x\).
5:Step 3 Optional discriminator
6:Step 3.1
7: Find the distances between the individuals of the new subspace \(X\)
8: to their respective cluster centers by calculating Equation (15).
9:Step 3.2
10: Find the classification vector \(T\) by considering the smallest index found
11: for each individual.
```  
**Algorithm 2** Multiobjective Optimization