# Anomaly Detection in Financial Time Series by Principal Component Analysis and Neural Networks +
## 6 Model Evaluation: Additional Results
### Anomaly Imputations  
To assess the imputation values suggested by our approach, we started with the time series simulated without anomalies, then we randomly selected a time stamp of the time series and added a noise to the corresponding value following the methodology described in Section 3. The imputation value suggested by the PCA NN was the reconstructed observation. This imputation technique was compared to the naive methods of the imputation of missing values, namely backward fill (BF), which consists of replacing the anomaly with the previous value, and linear interpolation (LI). The choice of these imputation methods was motivated by their low computational costs. In fact, the PCA NN imputation came at no additional cost as stated before. Therefore, we only challenged its performance using methods with similar complexities. To assess the quality of the imputation value \begin{table}
\begin{tabular}{l c c c c} \hline \hline
**Model** & **Accuracy** & \(\mathbf{F_{1}}\)**-Score** & **Accuracy** & \(\mathbf{F_{1}}\)**-Score** \\ \hline IF & 89.79\% & 2.296\% & 70.94\% & 1.611\% \\ LOF & 99.51\% & 0\% & 2.066\% & 0.9816\% \\ DBSCAN & N/A & NA & NA & NA \\ sig-IF & N/A & N/A & N/A & N/A \\ \hline KNN & 99.99\% & 99.99\% & 95.56\% & 2.794\% \\ SVM & NA & NA & NA & NA \\ PCA NN & 89.65\% & 89.68\% & 94.39\% & 94.38\% \\ \hline \hline \end{tabular}
\end{table} 
Table 11: Performance evaluation of unsupervised (upper part) and supervised (lower part) models for anomaly localization step. Results for DBSCAN, sig-IF, and SVM are not provided due to high computational costs. \begin{table}
\begin{tabular}{l c c c c c c} \hline \hline
**Algorithm** & **IF** & **LOF** & **DBSCAN** & **KNN** & **SVM** & **sig-IF** & **PCA NN** \\ \hline Exec. Time & 14.50 & 2.287 & N/A & 14.19 & N/A & N/A & 0.002004 \\ \hline \hline \end{tabular}
\end{table} 
Table 12: Execution time in seconds for the anomaly localization step. Results for DBSCAN, sig-IF, and SVM are not provided due to high computational costs. suggested by each approach, we considered the following metrics. The imputation errors were computed for each time series \(i\) as  
\[\text{ImputationError}^{i}=\sqrt{\sum_{j}\frac{\left(S_{ij}^{i}-\widetilde{S}_{ij }^{i}\right)^{2}}{n^{atom}}}\,\]  
where \(\widetilde{S}^{i}\) refers to the \(i\)-th path price with imputed values. The error on the covariance matrix was computed as  
\[\text{ErrCov}=\|\Sigma-\widetilde{\Sigma}\|_{\text{Frob}},\]  
where \(\|\cdot\|_{\text{Frob}}\) is the Frobenius norm, \(\Sigma\) is the sample covariance matrix, and \(\widetilde{\Sigma}\) is the covariance matrix estimated for the data after the anomalies were replaced by their respective imputation values. Each stock path was diffused and contaminated 100 times. The anomalies were then imputed following two baseline approaches (BF and LI). Figure 9 clearly shows that the imputation using the reconstructed values with PCA reduced the imputation error but not as much as the basic imputation techniques (LI and BF), as shown in Figure 10. Table 13 shows that the baseline imputation approaches achieved even lower errors in the estimation of the covariance matrix. Figure 11 shows a higher mean but a lower variance of the errors for the PCA-based imputation approach. In conclusion, it is recommended to replace the flagged anomalies with approaches such as backward fill or linear interpolation. Figure 11: Box plot representation of the distribution of the errors on the covariance matrix (on several stock path samples). Ano, PCA NN, LI, BF, and Clean refer to the errors in the covariance when estimated for time series with anomalies; time series after anomaly imputation following three approaches, imputation by the reconstructed values suggested by PCA, linear interpolation (LI), backward fill (BF); and time series without anomalies (Clean). The Ano, PCA NN, LI, BF, and Clean errors in the covariance estimation are all represented (**upper**). For better visualization we remove the Ano errors (**below**).