# Prediction of Cyanobacteria Using Decision Tree Algorithm and Sensor Monitoring Data
## 2 Research Method
### Evaluation of the Optimal Prediction Model and Cycles  
Among the four sections, DS-HC was selected to compare the prediction accuracy of the RF, XGBoost, and CatBoost algorithms because of its high algae occurrence and high accuracy. All three algorithms are artificial neural networks based on decision tree ensemble learning, with the ensemble methods classified into bagging and boosting functions. RF utilizes the bagging method, whereas XGBoost and CatBoost employ the boosting technique. We analyzed the prediction accuracy according to the characteristics of each algorithm to select the optimal model. We also compared the accuracy of algae category prediction at the same time and after 7 days. The factors used for training were those of Case 8 in Table 7.  
As shown in Table 7, the accuracy of RF was approximately 9% higher than that of the other two algorithms for predictions made at the same time and after 7 days. In the average cross-validation test, the results of RF and CatBoost were similar for the \begin{table}
\begin{tabular}{c c c c c c} \hline \hline \multirow{2}{*}{**Station**} & \multirow{2}{*}{**Data**} & \multicolumn{3}{c}{**Test Accuracy**} & \multirow{2}{*}{**References**} \\ \cline{3-3} \cline{5-6}  & & **Day** & & **Day + 7** & \\ \hline \multirow{2}{*}{Case 1} & TN, NO\({}_{3}\), NH\({}_{4}\), TP, PO\({}_{4}\), Cond, Interval, Wlevel, Inflow, Discharge, & & \\  & Precip, Atemp, Wspeed & & & \\ \hline \multirow{2}{*}{Case 2} & TN, NO\({}_{3}\), NH\({}_{4}\), TP, PO\({}_{4}\), Cond, Interval, Wlevel, Inflow, Discharge, & & \\  & Dhydro, Precip, Atemp, Wspeed & & & \\ \hline \multirow{2}{*}{Case 3} & DO, Turbidity, TN, TP, TOC, WT, Chl-a, EC, pH, DMAT, DR, DTSD & 0.761 & 0.806 & [46] \\ \hline \multirow{2}{*}{Case 4} & COD, BOD, TOC, TSS, TP, DTP, PO\({}_{4}\)-P, TN, DTN, NO\({}_{3}\)-N, NH\({}_{3}\)-N, & & \\  & Chl-a, Temperature, Precip, Flow Rate, DO, pH, EC, TColi, FColi & & \\ \hline \multirow{2}{*}{Case 5} & BOD, COD, SS, Ecoil, TN, TP, EC, TOC, W.T., pH, DO, Chl-a, HRT, & & \\  & W.Volume, Rainfall, Inflow, Outflow & & & \\ \hline \multirow{2}{*}{Case 6} & BOD, COD, SS, Ecoil, TN, TP, EC, TOC, WT., pH, DO, Chl-a & 0.808 & 0.798 & \\ \hline \multirow{2}{*}{Case 7} & EC, TOC, W.T., pH, DO, Chl-a & 0.785 & 0.791 & \\ \hline \multirow{2}{*}{Case 8} & EC, TOC, W.T., pH, DO, Chl-a, HRT, W.Volume, Rainfall, & & \\  & Inflow, Outflow & & & \\ \hline \hline \end{tabular}
\end{table} 
Table 6: Evaluation of prediction model accuracy according to training factors. \begin{table}
\begin{tabular}{c c c c c c c} \hline \hline  & \multicolumn{3}{c}{**Day Same Time**} & \multicolumn{3}{c}{**Day + 7**} \\ \hline
**DS–HC** & **RF** & **XGBoost** & **CatBoost** & **RF** & **XGBoost** & **CatBoost** \\ \hline Test accuracy & 0.831 & 0.739 & 0.746 & 0.825 & 0.725 & 0.722 \\ \hline Ave. cross-validation & 0.865 & 0.832 & 0.852 & 0.854 & 0.798 & 0.884 \\ \hline \hline \end{tabular}
\end{table} 
Table 7: Comparison of the prediction accuracy of each algorithm. same-time predictions, whereas CatBoost performed better for the predictions after 7 days. Considering the overall results, we conclude that RF is the optimal algorithm for category-type algae prediction. We also evaluated the subdivision of categories and the optimal prediction cycle (Table 8). The prediction accuracy was estimated by subdividing the existing three prediction categories into seven levels (i.e., 1000, 5000, 10,000, 50,000, 100,000, 500,000, and 1,000,000 cells/mL). The prediction cycle was divided into 7, 14, 21, and 28 days to determine the prediction accuracy. The seven categories were approximately 5-6% less accurate than the original three categories. With regard to the optimal forecast cycle, the three categories showed 80% accuracy for predictions after 7 and 14 days, whereas the subcategories showed 76% accuracy for those after 7 days.