# Predicting Architectural Space Preferences Using EEG-Based Emotion Analysis: A CNN-LSTM Approach
## 4 Data Analysis and Model Development
### Model 1: CNN-LSTM with ERP Segments  
To predict emotional responses to architectural images, we built a CNN-LSTM hybrid model capable of simultaneously learning both the spatial and temporal characteristics of EEG data. This model extracts spatial features through 2D convolutional layers and learns temporal dependencies via LSTM layers. Table 14 describes the hyperparameters and roles of the CNN and LSTM components. The final output of the LSTM layer had a hidden state dimension of 40, which was passed through a fully connected layer, leading to the final classification stage. The classification layer consisted of two output neurons with a Softmax activation function, designed to compute the probabilities for the two target classes: preference and non-preference. To address the issue of class imbalance, focal loss (\(\alpha\) = 0.25, \(\gamma\) = 2.0) was employed as the loss function, and the Adam optimizer was used with a learning rate of 0.000203. Figure 9: Event-related potential average waveforms: (**a**) N100 component (0.08–0.12 s); (**b**) N200 component (0.18–0.35 s); (**c**) P300 component (0.25–0.50 s); and (**d**) late positive potential (LPP) component (0.30–0.70 s). Figure 10 visually depicts the CNN-LSTM model architecture. \begin{table}
\begin{tabular}{c c c c} \hline \hline
**Model** & **Parameter** & **Value** & **Description** \\ \hline \multirow{6}{*}{Convolutional neural network (CNN)} & \multirow{2}{*}{Convolution filters} & \multirow{2}{*}{50 (Conv1), 100 (Conv2)} & 50 filters in the first convolutional layer and 100 filters in the second layer for spatial feature extraction \\ \cline{2-4}  & & & Defines the receptive field size of each filter Smaller sizes allow for finer spatial feature learning \\ \cline{2-4}  & & & \\ \cline{2-4}  & & & \\ \cline{2-4}  & & & \\ \cline{2-4}  & & & \\ \cline{2-4}  & & & \\ \cline{2-4}  & & & \\ \cline{2-4}  & & & \\ \cline{2-4}  & & & \\ \cline{2-4}  & & & \\ \cline{2-4}  & & & \\ \hline \multirow{2}{*}{Pooling size} & \multirow{2}{*}{\(2\times 2\)} & \multirow{2}{*}{\begin{tabular}{c} Specifies the filter size for max pooling, \\ reducing spatial dimensions while \\ preserving critical information \\ \end{tabular} } \\ \cline{2-4}  & & & \\ \hline \multirow{2}{*}{Strides} & \multirow{2}{*}{2} & \multirow{2}{*}{\begin{tabular}{c} Sets the step size of the pooling filter, \\ reducing computational load \\ \end{tabular} } \\ \cline{2-4}  & & & \\ \hline \multirow{6}{*}{Long short-term memory (LSTM)} & \multirow{2}{*}{Activation} & Built-in gate functions & Internal functions in the LSTM for managing and updating cell states \\ \cline{2-4}  & & & \\ \cline{2-4}  & & & \\ \cline{2-4}  & & & \\ \cline{2-4}  & & & \\ \cline{2-4}  & & & \\ \cline{2-4}  & & & \\ \cline{2-4}  & & & \\ \hline \multirow{6}{*}{Optimizer} & \multirow{2}{*}{\
\begin{tabular}{c} Adaptive moments of \\ gradient (learning \\ rate = 0.000203) \\ \end{tabular} } & \multirow{2}{*}{
\begin{tabular}{c} Optimization algorithm for training; \\ adjusts weights to minimize loss \\ \end{tabular} } \\ \cline{1-1} \cline{3-4}  & & & \\ \hline \hline \end{tabular}
\end{table} 
Table 14: The convolutional neural network long short-term memory configuration. Figure 10: A convolutional neural network long short-term memory (CNN-LSTM) model structure diagram. We utilized Optuna to optimize key hyperparameters such as LSTM unit count, CNN filter count, dropout rate, learning rate, and batch size. After 50 trials, the optimal combination was as shown in Table 15.  
By incorporating focal loss, the model emphasized the contribution of difficult-to-classify samples (e.g., non-preferred stimuli) by assigning greater loss values to these instances. The training was conducted using a mini batch size of 16 over a total of 30 epochs. Early stopping was applied to terminate training when the validation loss failed to improve over a predefined number of iterations, thereby preventing overfitting and enhancing generalization.