## 4 Proposed DETD Algorithm and Simulation Results
### The Proposed Algorithm  
Our proposed algorithm has the following steps which are repeated for every consumer in the SG. Since the performance and complexity of the theft detector vary based on the consumer usage pattern, we report the average performance of the algorithm. In order to replicate theft window-based theft cases, we use the d-ToU and f-ToU pricing data to generate our malicious samples. We assume that the \"normal\" and \"high\" price periods are the most likely theft period or \"theft window period\", while the \"low\" price period is the least likely theft period or the \"non-theft window period\".  
To train the XGBoost module in the DETD algorithm, we label the generated theft patterns as \"1\" and corresponding real usage patterns as \"0\". During the training stage,  
\begin{table}
\begin{tabular}{c c c} \hline \hline
**CPBETD** & **d-ToU** & **f-ToU** \\ \hline DR [\%] & 67 & 72 \\ FPR [\%] & 34 & 29 \\ \hline
**GBTD** & **d-ToU** & **f-ToU** \\ \hline DR [\%] & 87 & 89 \\ FPR [\%] & 11 & 8 \\ \hline \hline \end{tabular}
\end{table}
Table 2: Average theft detection performance of SVM-based CPBETD and XGBoost-based GBTD when using the dynamic ToU (d-ToU) and fixed ToU (f-ToU) window-based theft cases for an average of 1000 consumers (Existing Schemes).  
the theft detector is trained to minimize error between actual labels and predicted labels (\"0\" or \"1\"). Figure 3 describes the algorithm in a block diagram.  
DETD Algorithm:  
1. Dataset cleaning to fill in missing values or adjust sampling using standardized techniques.
2. Store the usage values in a \"usage feature vector\" of size 48.
3. Create the theft window period and non-theft window period feature vector using 0 or 1 as the respective values on the \(Y\)-axis and store them in a \"window feature vector\" of size 48.
4. Generate synthetic theft cases which are based on the window feature vector corresponding to the real usage vectors.
5. Concatenate the usage feature vector generated in step ii with the window feature vector obtained in step iv to generate a feature vector of size 96.
6. Label vectors with real-usage and theft-usage cases as \"0\" and \"1\", respectively.
7. Split the dataset into training and testing data in the ratio of 7:3.
8. Train and test the binary classifier. Here, we use the XGBoost classifier with the novel training set while passing the hyperparameter \"scale_pos_weight\", which is the \"number of theft usage data/number of benign (real) usage data\", to scale the imbalance in the two classes.
9. Use random search for hyperparameter tuning to optimize the XGBoost classifier.  
We report the performance for d-ToU using the test set (for an average of 1000 consumers) in Table 3. Then, we repeat the same process (steps i to vii) for f-ToU and report it accordingly. Note that passing the \"scale_pos_weight\" value eliminates the need for  
Figure 3: Schematic diagram of the DETD algorithm.  
creating synthetic minority class (benign) data using SMOTE [21], such that memory usage is reduced and the classifier is kept from overfitting.  
Figure 4 shows the novelty of the DETD algorithm, showcasing the novel 96 feature data processing by concatenating the consumption data with ToU pricing data. Although emphasizing the ToU pricing-based window feature vector in the algorithm, we can substitute (or combine) it with other window vectors, if it is necessary.  
Throughout the paper, all the simulations were performed using Python programming language on an Intel i7 processor, Nvidia RTX 2070 graphic card with a 16 GB RAM system.