# Advanced Methodology for Fraud Detection in Energy Using Machine Learning Algorithms
## 3 Research Method
The dataset includes both residential and commercial users, with 1872 confirmed fraud cases identified through field inspections. Each record contains key data points, such as billing amounts, consumption trends, geographical location, and, when available, smart meter data, along with inspection results. The records provide essential details, including usage patterns and location-based insights, while incorporating smart meter readings where applicable. Each entry offers a comprehensive overview, combining financial, geographical, and technical information to ensure accurate analysis. To ensure a balanced dataset, stratified sampling was applied to include 60% residential, 30% commercial, and 10% industrial consumers. The data was split into 80% training and 20% testing sets, maintaining the same fraud-non-fraud ratio. To address class imbalance, SMOTE (Synthetic Minority Over-sampling Technique) was used, improving model performance by generating synthetic fraud cases while preserving real consumption patterns. To ensure high data quality and improve the accuracy of fraud detection, a series of preprocessing steps was applied to the dataset. These steps focused on data cleaning, feature engineering, and normalization to enhance model performance and reliability. Data cleaning was a crucial step in refining the dataset and eliminating inconsistencies that could affect the performance of machine learning models. The analysis utilized several techniques, including the removal of duplicate records, where redundant entries were identified and eliminated to maintain data accuracy. Missing values were handled through interpolation methods, ensuring a continuous dataset without significant data loss. The choice of interpolation technique depended on the nature of the missing data, with linear and polynomial interpolations applied where appropriate. Feature engineering was employed to enhance the predictive capabilities of machine learning models by leveraging domain knowledge and historical fraud patterns. Anomalydetection features were created to identify irregular consumption behaviors, such as sudden drops in electricity usage, which could indicate fraud or meter tampering. These anomalies were detected through statistical thresholding and machine learning-based outlier detection techniques. Additionally, a fraud probability score was developed using historical inspection data, incorporating past fraud incidents, consumption trends, and customer behavior to assess the likelihood of fraudulent activity. Higher probabilities were assigned to customers whose consumption patterns resembled those of previously identified fraudulent cases. To standardize the dataset and eliminate biases in model training, normalization and scaling techniques were applied. Min-max scaling was used to transform feature values into a uniform range, ensuring equal contribution from all variables and improving model convergence, particularly in neural networks. Feature standardization was also explored to maintain a zero-mean and unit-variance distribution, benefiting algorithms reliant on distance-based calculations, such as k-nearest neighbors (kNN). Before deploying machine learning models, extensive exploratory data analysis (EDA) was conducted to uncover trends, anomalies, and potential fraud indicators. A histogram analysis was used to examine fraud distribution among clients, revealing distinct consumption differences between fraudulent and non-fraudulent users. Box plots helped visualize consumption anomalies and identify extreme outliers, flagging customers with unusual energy usage for further investigation. A time-series analysis was performed to assess fluctuations in energy consumption, identifying sudden spikes or drops as potential fraud indicators. Seasonality effects were analyzed to differentiate between legitimate seasonal variations and fraudulent manipulations. A comparative analysis between electricity and gas consumption was also conducted to detect inconsistencies indicative of fraud.