# AI-Powered Stroke Diagnosis System: Methodological Framework and Implementation
## 4 Methodology Development
### Technological Components
#### 4.1.4 Neural Network Design and Hyperparameter Optimization  
Within our AI framework, defined as the comprehensive workflow encompassing data ingestion, preprocessing, model fitting, ensemble fusion, and calibrated decision making, we established a systematic hyperparameter optimization approach for each model component. We established a unified search space for our gradient-boosted trees under Python's param_dist, utilized by RandomizedSearchCV.  
\begin{table}
\begin{tabular}{c c c} \hline
**Pipeline Component** & **Techniques Applied** & **Purpose and Rationale** \\ \hline \multirow{3}{*}{Numeric data} & Zero-imputation; one-hot encoding; & Handle missing values, encode categories, \\  & min-max scaling; SMOTE & standardize ranges, balance classes \\  & Resize to 224 \(\times\) 224; random flip and & \\  & rotation; tensor conversion; & \\  & ImageNet normalization & \\  & MobileNet-V2 (IMAGENET1K\_V1); all & Efficient feature extraction on CPU, \\  & backbone weights frozen & \\  & Dropout (\(p\) = 0.3) + linear \(\to\) 1 logit & \\  & Adam optimizer (lr = 1 \(\times\) 10\({}^{-3}\)), & \\  & 10 epochs, batch size = 16 & \\ \hline \end{tabular}
\end{table}
Table 1: Summary of preprocessing, normalization, and model configuration.  
* XGBoost: n_estimators \(\in\) [100, 200], max_depth \(\in\) [3, 6], learning_rate \(\in\) [0.01, 0.05, 0.1], subsample and colsample_bytree \(\in\) [0.6, 0.8], gamma \(\in\) [0.0, 0.1], min_child_weight \(\in\) [1, 5], reg_alpha \(\in\) [0.0, 0.1], reg_lambda \(\in\) [0.5, 1.0], and scale_pos_weight set automatically to the ratio of non-stroke to stroke cases. We ran ten randomized iterations with two-fold stratified CV, optimizing average_precision. The best estimator was then wrapped in CalibratedClassifierCV(method = 'isotonic') to align probabilities before the threshold search.
* CatBoost: we fixed iterations = 200, depth = 6, learning_rate = 0.05, and loss_function = 'Logloss', based on preliminary grid searches that balanced the performance against the training time; the class imbalance was addressed via SMOTE when available.
* Stacking: The meta-learner is a CatBoost with iterations = 100, depth = 4, learning_rate = 0.05. It was trained on the out-of-fold probability outputs of XGBoost and CatBoost. We also tuned its class_weights in the same random-search framework to maximize F-\(\beta\) (\(\beta\) = 2).  
We selected MobileNet-V2 (1.0 \(\times\) 224, IMAGENET1K_V1 weights) for the convolutional branch because of its depthwise-separable convolutions and sub-3 million parameter count. Following the freezing of the entire backbone, we substituted its classifier with a dropout layer (\(p\) = 0.3) and a linear projection to a single logit. Utilizing PyTorch, we conducted a hyperparameter sweep of learning rates [1 \(\times\) 10\({}^{-4}\), 5 \(\times\) 10\({}^{-4}\), 1 \(\times\) 10\({}^{-3}\)], batch sizes [8; 16; 32], and epochs [5; 10; 15] employing BCEWithLogitsLoss and the Adam optimizer. The ultimate configuration--ten epochs with a learning rate of 1 \(\times\) 10\({}^{-3}\) and a batch size of 16--was selected due to the validation accuracy and stroke recall reaching a plateau by the tenth epoch, with no additional benefits warranting extended training durations.