Pharmaceutical compounds, such as carbamazepine, have become a concern in aquatic environments due to their wide usage, resistance to degradation, and inefficiency of wastewater treatment processes. Therefore, it is important to find methods to remove these compounds from aqueous solutions. This study focuses on using Fe@Fe2O3 nanowires combined with electro Fenton process in an electrochemical reactor to decompose carbamazepine (CBZ). Various parameters were considered in 81 experiments, such as pH, current density, concentrations of FeSO4·7H2O, carbamazepine, Fe@Fe2O3, and reaction time. The removal efficiency ranged from 30.4 % to 88.6 %. This study utilized a hybrid adaptive neuro fuzzy inference system (ANFIS) combined with the ant colony optimization algorithm (ACO). The ACO is integrated with the ANFIS models to determine the optimum values for the studied parameters. The implementation of optimization through ACO enhances the ANFIS models' ability. A total of 65 data points were used for training the model, and 16 data points were used to test it. The model's performance was assessed using the coefficient of determination (R2 = 0.9988), the root-mean-squared error (RMSE = 4.54E-03), and the average absolute relative deviation (AARD% = 0.7153). The optimal input parameters for CBZ removal were determined as follows: concentrations of CBZ, FeSO4·7H2O and Fe@Fe2O3 nanowire dose of 9.0 mg/L, 4.5 mg/L, and 1050.0 mg/L; contact time of 45.0 min; pH of 4.0; and current of 0.18 A, resulting in a removal efficiency of 91.2 %. Additionally, the extended Fourier amplitude sensitivity test (EFAST) sensitivity analysis was applied to assess the influence of individual input parameters or their interactions on the model's output.