Water quality detection and prediction system based on time sequence analysis
By constructing an intelligent water quality monitoring and prediction system based on embedded hardware and time series analysis, the problems of high manpower and material consumption and insufficient detection accuracy of traditional water quality detection methods have been solved. The system enables real-time detection of water quality data and high-precision trend prediction, and is adaptable to various water quality environments.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-01-12
- Publication Date
- 2026-04-07
AI Technical Summary
Traditional water quality testing methods are labor-intensive and resource-intensive, difficult to acquire data, have long analysis cycles, and cannot be processed in a timely manner. Intelligent water quality testing equipment is expensive and lacks accuracy, and its model scenarios are highly limited, especially in turbulent water environments where its effectiveness is reduced.
An intelligent water quality monitoring and prediction system based on embedded hardware and time series analysis was constructed, including a water quality detection module, a data preprocessing module, a stationarity test module, a model order determination module, and a model validation module. An STM32 microcontroller and multiple sensors were used for real-time data acquisition, and an ARIMA model was used for trend prediction. The stationarity of the data was ensured by ADF and KPSS tests, and the model parameters were determined using the AIC and BIC criteria.
It enables real-time detection and high-precision trend prediction of water quality data, reduces equipment costs, improves the timeliness and accuracy of detection, and adapts to various water quality environments.
Smart Images

Figure CN121808192A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of environmental monitoring and Internet of Things technology, specifically relating to a water quality detection and prediction system based on time series analysis. Background Technology
[0002] Industrialization and urbanization are being rolled out globally, and water quality protection is receiving increasing attention worldwide, making water quality testing a crucial element. Traditional water quality testing methods are largely assembly-line processes, relying on manual data collection, followed by laboratory analysis and statistical processing by researchers. This approach is extremely resource-intensive, with difficulties in data acquisition, long analysis cycles, and delayed data release. It also hinders timely intervention when problems arise. Intelligent water quality testing technology also faces numerous challenges in practical applications, such as complex data processing, high equipment costs, and the need for improved accuracy. Furthermore, the models have limitations in application scenarios; for example, the WASP model is only effective in relatively calm waters, and its effectiveness diminishes in turbulent waters. Additionally, a large amount of historical data is required. Summary of the Invention
[0003] (a) Technical problems to be solved
[0004] To address the shortcomings of existing technologies, this invention provides a water quality detection and prediction system based on time series analysis. Starting from the functional requirements of an intelligent water quality monitoring and prediction system, this invention studies the temporal variation patterns of key water quality parameters and their impact on the accuracy of prediction models. It constructs an intelligent water quality monitoring and prediction system based on embedded hardware and time series analysis to achieve the dual functions of real-time water quality detection and accurate trend prediction.
[0005] (II) Technical Solution
[0006] To achieve the above objectives, the present invention provides the following technical solution: a water quality detection and prediction system based on time series analysis, comprising a water quality detection module, a data preprocessing module, a stationarity test module, a model order determination module, and a model validation module;
[0007] The water quality detection module is constructed by a main control unit, a sensing unit, and a display unit. The main control unit is used to receive data from the sensing unit and send control commands to the display unit. The sensing unit is used to monitor data and transmit the detected data to the main control unit. The display unit is used to receive commands from the main control unit and present the data to the user in a visual form.
[0008] The data preprocessing module is used to perform random perturbation processing on the time-series data collected by the sensing unit, and divide the training set and test set according to a preset ratio.
[0009] The stationarity testing module performs a dual verification mechanism using both the ADF test and the KPSS test.
[0010] The model order determination module determines the optimal parameter combination of the ARIMA model based on the AIC and BIC criteria.
[0011] The model validation module is used to validate the ARIMA model.
[0012] Preferably, the sensing unit is used to connect multiple sensors for data monitoring. The multiple sensors specifically include: a temperature sensor, a pH sensor, and a turbidity sensor. The temperature sensor is used to collect temperature time-series data, the pH sensor is used to collect pH value time-series data, and the turbidity sensor is used to collect turbidity time-series data.
[0013] Preferably, the preset ratio of dividing the training set to the test set is 8:2.
[0014] Preferably, the expression for the ADF test model is:
[0015] ;
[0016] In the formula, Represents the first-order difference, i.e. ; For the defined part, it represents the constant term; The parameter to be tested is used to determine the existence of a unit root. Representing time series The value at time; Represents the lag order; Representing the The coefficients of each lagged difference term; Representing time series The value at time; Represents the random error term; Represents a time index;
[0017] difference Used for modeling the error term in ARIMA models. satisfy , Representing time series The value at time; Representing time series The value at time; Represents a lag operator polynomial; This represents the coefficients in the lag operator polynomial; Represents a lag operator;
[0018] Based on the principles of hypothesis testing, the following null and alternative hypotheses are proposed:
[0019] ;
[0020] ;
[0021] In the formula, The original hypothesis is that the time series has a unit root, i.e., it is not stationary. Represents the autoregressive coefficient; The alternative hypothesis is that the time series does not have a unit root, i.e., it is stationary.
[0022] Preferably, the null hypothesis of the KPSS test is that the time series is stationary, and the model expression is:
[0023] ;
[0024] In the formula, Represents a time series; Represents the mean of a time series; Represents the stochastic trend term; This represents the random error term.
[0025] Preferably, the KPSS test statistic is based on the variance estimate of the cumulative sum of the series, as follows:
[0026] ;
[0027] In the formula, Representative error term Long-term variance estimation; Represents the number of time series observations; The sum of cumulative errors is expressed by the following formula:
[0028] ;
[0029] Preferably, the dual authentication mechanism includes:
[0030] If the result of the ADF test is contrary to the null hypothesis, and the result of the KPSS test accepts the null hypothesis, the time series is determined to meet the stationarity requirement and passes the test; otherwise, the time series does not meet the stationarity requirement and fails the test.
[0031] If the test fails, the time series is differentially analyzed until the stationarity requirement is met, and the iteration number is marked.
[0032] Preferably, the key parameters of the ARIMA model consist of three parts, including: the autoregressive order. Difference order and moving average order ;
[0033] The difference order The number of iterations marked in the test where the dual verification mechanism failed;
[0034] The autoregressive order and moving average order Determined based on the AIC and BIC criteria, the expression is:
[0035] ;
[0036] ;
[0037] In the formula, The maximum likelihood function value represents the ARIMA model; This represents the total number of model parameters. .
[0038] Preferably, the step of determining the optimal parameter combination of the ARIMA model is as follows:
[0039] A1. Set the autoregressive order and moving average order Candidate order ;
[0040] A2. Iterate through the array from (0,0) to (4,4) and construct the corresponding ARIMA model for each combination. ,in The number of iterations marked in the test where the dual verification mechanism failed;
[0041] A3. Use the built-in `estimate` function to fit the model and obtain the log-likelihood value `logL`. Then, use the built-in `aicbic` function to calculate the corresponding [log-likelihood value] based on the model's log-likelihood value, the total number of model parameters, and the number of valid samples. , Find , Minimum value Combination, in combination with S2 This represents the optimal parameter combination for the ARIMA model.
[0042] Preferably, the model validation module validates the ARIMA model to find a set of optimal model parameters. Specifically, it includes:
[0043] B1. Call the built-in estimate function to perform parameter estimation. The built-in estimate function is based on optimization methods such as maximum likelihood estimation. It automatically searches and outputs a set of optimal parameters and returns two main outputs. The first of these is a complete ARIMA model object containing all estimated parameters. This ARIMA model object will be directly used for subsequent predictive analysis.
[0044] B2. Based on the ARIMA model trained above, call the forecast function to make multi-step predictions of future water quality indicators. This multi-step prediction requires specifying the model object, prediction step size, and historical data sequence as input.
[0045] Compared with existing technologies, the present invention provides a water quality detection and prediction system based on time series analysis, which has the following beneficial effects:
[0046] This invention addresses the need for real-time, high-precision water quality data acquisition by designing and implementing a water quality data acquisition system based on STM32. The system aims to detect key parameters in water quality in real time. For the real-time acquisition of key water quality data such as temperature, pH, and turbidity, corresponding acquisition modules were constructed, solving the water quality data acquisition problem and realizing real-time water quality data acquisition. Simultaneously, leveraging the superior characteristics of the sensor, the system also meets the requirement of high-precision water quality data acquisition. Furthermore, to address the need for water quality trend prediction, a water quality prediction model based on ARIMA was constructed, aiming to accurately predict future water quality trends through time series analysis. This invention achieves the function of predicting future water quality trends. Attached Figure Description
[0047] Figure 1 This invention relates to the STM32 system architecture.
[0048] Figure 2 The relative error of the ARIMA water quality prediction model of this invention in predicting water quality and temperature in Guangdong Province;
[0049] Figure 3 The relative error of the ARIMA water quality prediction model of this invention in predicting water quality and temperature in Liaoning Province;
[0050] Figure 4 The relative temperature error of the ARIMA water quality prediction model of this invention in the Yangtze River Basin;
[0051] Figure 5 The relative error of the ARIMA water quality prediction model of this invention in the pH of water quality in the Yangtze River Basin;
[0052] Figure 6 The relative error of the ARIMA water quality prediction model of this invention in the turbidity of the Yangtze River Basin;
[0053] Figure 7This is a schematic diagram of the system of the present invention. Detailed Implementation
[0054] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention. It is worth noting that this application also relates to prior art. Since prior art is well known to those skilled in the art, it will not be described in detail in this application.
[0055] Please see Figures 1-7 A water quality detection and prediction system based on time series analysis includes a water quality detection module, a data preprocessing module, a stationarity test module, a model order determination module, and a model validation module.
[0056] The water quality detection module is built by a main control unit, a sensing unit, and a display unit, forming a multi-sensor integrated water quality data acquisition device. The main control unit uses an STM32F103C8T6 microcontroller to receive data from the sensing unit and send control commands to the display unit. The sensing unit is used to monitor data and transmit the detected data to the main control unit. The display unit uses an LCD1602 liquid crystal display module to receive commands from the main control unit and present the data to the user in a visual form.
[0057] The sensing unit is used to connect multiple sensors for data monitoring. The multiple sensors specifically include: a temperature sensor, a pH sensor, and a turbidity sensor. The temperature sensor uses a DS18B20 to collect temperature time-series data, the pH sensor uses a pH sensor from Weimengshi to collect pH value time-series data, and the turbidity sensor uses a TSW-30 to collect turbidity time-series data.
[0058] The specific connection and implementation steps for the water quality testing module are as follows:
[0059] a1. Connect the data pin DO of the DS18B20 temperature sensor to the GPIO pin of the STM32, and connect an external 4.7KΩ pull-up resistor to the 3.3V power supply;
[0060] a2. Connect the pH sensor to the STM32's serial port via RS485 serial port;
[0061] a3. Connect the analog output pin of the TSW-30 turbidity sensor to the ADC input channel of the STM32.
[0062] a4. Connect the data lines D4-D7 of the LCD1602 liquid crystal display module to the four GPIO pins of the STM32 respectively, and connect the control lines RS, RW, and E to the other GPIO pins respectively.
[0063] The workflow of the water quality testing module is as follows:
[0064] b1. Initialize immediately after system power-on;
[0065] b2, set the controller to trigger each sensor to perform measurement according to the sensor response time, read the temperature digital signal of DS18B20 through single bus protocol; send query command to pH sensor through Modbus-RTU protocol and receive the pH value data returned by it; start ADC to sample the analog voltage output by turbidity sensor and convert it into digital value, and calculate turbidity value according to sensor calibration curve;
[0066] b3. The collected temperature, pH value, and turbidity data are converted from ASCII code values to corresponding Chinese characters through the correspondence between address and display position and then displayed on the LCD1602 liquid crystal display module screen. The data display adopts a dynamic refresh method. When the sensor data is updated, the system automatically updates the display content of the corresponding area while keeping other information unchanged.
[0067] The data preprocessing module is used to perform random perturbation processing on the time series data collected by the sensing unit. This step is to avoid the data being completely stationary or having exactly the same value, especially to prevent the occurrence of singular matrices in subsequent difference operations, and to divide the training set and test set according to a preset ratio of 8:2.
[0068] The stability testing module implements a dual verification mechanism of ADF test and KPSS test to ensure the stability of water quality data;
[0069] The ADF test model expression is:
[0070] ;
[0071] In the formula, Represents the first-order difference, i.e. ; For the defined part, it represents the constant term; The parameter to be tested is used to determine the existence of a unit root. Representing time series The value at time; Represents the lag order; Representing the The coefficients of each lagged difference term; Representing time series The value at time; Represents the random error term; Represents a time index;
[0072] difference Used for modeling the error term in ARIMA models. satisfy , Representing time series The value at time; Representing time series The value at time; Represents a lag operator polynomial; This represents the coefficients in the lag operator polynomial; Represents a lag operator;
[0073] Based on the principles of hypothesis testing, the following null and alternative hypotheses are proposed:
[0074] ;
[0075] ;
[0076] In the formula, The original hypothesis is that the time series has a unit root, i.e., it is not stationary. Represents the autoregressive coefficient; The alternative hypothesis is that the time series does not have a unit root, i.e., it is stationary.
[0077] The null hypothesis of the KPSS test is that the time series is stationary, and the model expression is:
[0078] ;
[0079] In the formula, Represents a time series; Represents the mean of a time series; Represents the stochastic trend term; Represents the random error term; Represents a point in time;
[0080] The KPSS test statistic is based on the variance estimate of the cumulative sum of the series, and the formula is:
[0081] ;
[0082] In the formula, Representative error term Long-term variance estimation; Represents the number of time series observations; The sum of cumulative errors is expressed by the following formula:
[0083] ;
[0084] Two-factor authentication mechanisms include:
[0085] In MATLAB, stationarity tests using ADF and KPSS can be performed using the built-in functions adftest and kpsstest, respectively. For ADF stationarity testing, a return value of 0 indicates rejection of the null hypothesis, meaning the data is non-stationary; a return value of 1 indicates that the null hypothesis is not rejected, meaning the data is stationary. For KPSS stationarity testing, a return value of 1 indicates rejection of the null hypothesis; a return value of 0 indicates that the null hypothesis is not rejected, meaning the data is stationary.
[0086] The ADF test and the KPSS test use different perspectives to assess the stationarity of a time series: the ADF test assumes that the series is non-stationary, while the KPSS test assumes that the series is stationary. When the result of the ADF test is contrary to the null hypothesis and the result of the KPSS test accepts the null hypothesis, the time series is determined to meet the requirements of stationarity and passes the test; otherwise, the time series does not meet the requirements of stationarity and fails the test.
[0087] If the test fails, the time series is differentially analyzed until the stationarity requirement is met, and the iteration number is marked.
[0088] The model order determination module determines the optimal parameter combination of the ARIMA model based on the AIC and BIC criteria;
[0089] The expression for the ARIMA model is:
[0090]
[0091] In the formula, Represents a constant term; Represents time series data; arrive These represent AR model parameters, which are used to describe the current value compared to the past. The relationship between the values at various time points; arrive These represent the parameters of the MA model, which are used to describe the relationship between the current value and past values. The relationship between errors at different time points; represent The random error term at a given time point;
[0092] The key parameters of the ARIMA model consist of three parts, including: the autoregressive order. Difference order and moving average order ;
[0093] Difference order The number of iterations marked in the test where the dual verification mechanism failed;
[0094] First-order differencing is a preprocessing technique used to transform non-stationary time series into stationary ones. In a time series, first-order differencing involves comparing each observation with its preceding observation and then taking the difference between the two. For example, in a time series... Then the first difference is , The order difference is performed continuously. The second-order difference, for example, is a further difference of the first-order difference sequence;
[0095] Autoregressive order and moving average order Determined based on the AIC and BIC criteria, the expression is:
[0096] ;
[0097] ;
[0098] In the formula, The maximum likelihood function value represents the ARIMA model; This represents the total number of model parameters. ;
[0099] The steps to determine the optimal parameter combination for an ARIMA model are as follows:
[0100] A1. Set the autoregressive order and moving average order Candidate order ;
[0101] A2. Iterate through the array from (0,0) to (4,4) and construct the corresponding ARIMA model for each combination. ,in The number of iterations marked in the test where the dual verification mechanism failed;
[0102] A3. Use the built-in `estimate` function to fit the model and obtain the log-likelihood value `logL`. Then, use the built-in `aicbic` function to calculate the corresponding [log-likelihood value] based on the model's log-likelihood value, the total number of model parameters, and the number of valid samples. , Find , Minimum value Combination, in combination with S2 This is the optimal parameter combination for the ARIMA model, enabling it to generate the stationary time series data we observe with the highest probability.
[0103] The model validation module is used to validate the ARIMA model and find an optimal set of model parameters. Specifically, it includes:
[0104] B1. Call the built-in estimate function to perform parameter estimation. The built-in estimate function is based on optimization methods such as maximum likelihood estimation. It automatically searches and outputs a set of optimal parameters and returns two main outputs. The first of these is a complete ARIMA model object containing all estimated parameters. This ARIMA model object will be directly used for subsequent predictive analysis.
[0105] B2. Based on the ARIMA model trained above, call the forecast function to make multi-step predictions of future water quality indicators. This multi-step prediction requires specifying the model object, prediction step size, and historical data sequence as input.
[0106] To make the objectives, technical solutions, and advantages of this invention clearer, the embodiments of this invention will be described in detail below with reference to specific experimental data and comparative cases;
[0107] Step 1: Selecting the dataset and preprocessing
[0108] The Pearl River Basin in Guangdong Province and the Liao River Basin in Liaoning Province, which have significant differences in rainfall and climate characteristics, were selected as control areas.
[0109] Water quality and temperature time-series data were obtained from October 9, 2023 to December 9, 2023 in the Pearl River Basin of Guangdong Province and the Liao River Basin of Liaoning Province. Data was collected every 4 hours to form a control dataset for the same period in the target area. First, the water quality time-series data, such as temperature, pH, and turbidity, were imported by calling functions, and a small random perturbation was added to the raw data. This step was to avoid completely stationary data or identical values, especially to prevent singular matrices in subsequent differencing operations. A total of 366 water quality data points were divided into training and test sets in an 8:2 ratio.
[0110] The second step is to conduct a stationarity test.
[0111] To ensure the stability of water quality data, a dual validation mechanism will be employed. The primary validation methods used are the Augmented Dickey-Fuller (ADF) test proposed by Said and Dickey in 1984 based on the DF test, and the Kwiatkowski-PHillips-Schmikowski test.
[0112] dt-Shin (KPSS) test. This process will not be detailed here;
[0113] Only when the ADF test result is contrary to the null hypothesis, and the KPSS test result accepts its null hypothesis, can we determine that the time series meets the stationarity requirement. If the test fails, the series is differencing, which increases the difference count, and then the stationarity of the differrated time series information is tested to determine whether it meets the stationarity requirement.
[0114] Step 3: Model Recognition and Order Determination
[0115] The key parameters of the ARIMA model consist of three parts, including: the autoregressive order. Difference order and moving average order ;
[0116] After completing the stationarity test and determining the difference order Next, the autoregressive order needs to be determined. and moving average order ;
[0117] In determining the ARIMA model When determining the order, the most commonly used information criteria are the Akaike Information Criterion (AIC) and the Bayesian Information Criterion (BIC). Below are the definitions of AIC and BIC:
[0118] ;
[0119] ;
[0120] In the formula, The maximum likelihood function value represents the ARIMA model; This represents the total number of model parameters. ;
[0121] The steps to determine the optimal parameter combination for an ARIMA model are as follows:
[0122] A1. Set the autoregressive order and moving average order Candidate order ;
[0123] A2. Iterate through the array from (0,0) to (4,4) and construct the corresponding ARIMA model for each combination. ,in The number of iterations marked in the double validation mechanism failure test; A3, use the built-in estimate function to fit the model and obtain the log-likelihood value logL. Then, use the built-in aicbic function to calculate the corresponding [value] based on the model's log-likelihood value, the total number of model parameters, and the number of valid samples. , Find , Minimum value Combination, in combination with S2 This is the optimal parameter combination for the ARIMA model, which completes the model training and enables the ARIMA model to generate the stationary time series data we observe with the highest probability.
[0124] Step 4: Model Training and Prediction
[0125] The order of the model has been determined. Next, the model parameters are estimated, which completes the model training. The goal of this step is to find a set of optimal model parameters. This allows the model to generate the stationary time series data we observe with the highest probability;
[0126] B1. Call the built-in estimate function to perform parameter estimation. The built-in estimate function is based on optimization methods such as maximum likelihood estimation. It automatically searches and outputs a set of optimal parameters and returns two main outputs. The first of these is a complete ARIMA model object containing all estimated parameters. This ARIMA model object will be directly used for subsequent predictive analysis.
[0127] B2. Based on the ARIMA model described above, call the `forecast` function to predict future water quality indicators. The implementation requires specifying three inputs: the trained model object, the prediction step size, and the historical data sequence used for prediction.
[0128] Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the appended claims and their equivalents.
Claims
1. A water quality detection and prediction system based on time series analysis, characterized in that, It includes a water quality testing module, a data preprocessing module, a stability testing module, a model order determination module, and a model validation module; The water quality detection module is constructed by a main control unit, a sensing unit, and a display unit. The main control unit is used to receive data from the sensing unit and send control commands to the display unit. The sensing unit is used to monitor data and transmit the detected data to the main control unit. The display unit is used to receive commands from the main control unit and present the data to the user in a visual form. The data preprocessing module is used to perform random perturbation processing on the time-series data collected by the sensing unit, and divide the training set and test set according to a preset ratio. The stationarity testing module performs a dual verification mechanism using both the ADF test and the KPSS test. The model order determination module determines the optimal parameter combination of the ARIMA model based on the AIC and BIC criteria. The model validation module is used to validate the ARIMA model.
2. The water quality detection and prediction system based on time series analysis according to claim 1, characterized in that, The sensing unit is used to connect multiple sensors for data monitoring. The multiple sensors specifically include a temperature sensor, a pH sensor, and a turbidity sensor. The temperature sensor is used to collect temperature time-series data, the pH sensor is used to collect pH value time-series data, and the turbidity sensor is used to collect turbidity time-series data.
3. The water quality detection and prediction system based on time series analysis according to claim 1, characterized in that, The preset ratio for dividing the training set and the test set is 8:
2.
4. The water quality detection and prediction system based on time series analysis according to claim 1, characterized in that, The expression for the ADF test model is: ; In the formula, Represents the first-order difference, i.e. ; For the defined part, it represents the constant term; The parameter to be tested is used to determine the existence of a unit root. Representing time series The value at time; Represents the lag order; Representing the The coefficients of each lagged difference term; Representing time series The value at time; Represents the random error term; Represents a time index; difference Used for modeling the error term in ARIMA models. satisfy , Representing time series The value at time; Representing time series The value at time; Represents a lag operator polynomial; This represents the coefficients in the lag operator polynomial; Represents a lag operator; Based on the principles of hypothesis testing, the following null and alternative hypotheses are proposed: ; ; In the formula, The original hypothesis is that the time series has a unit root, i.e., it is not stationary. Represents the autoregressive coefficient; The alternative hypothesis is that the time series does not have a unit root, i.e., it is stationary.
5. The water quality detection and prediction system based on time series analysis according to claim 4, characterized in that, The null hypothesis of the KPSS test is that the time series is stationary, and the model expression is: ; In the formula, Represents a time series; Represents the mean of a time series; Represents the stochastic trend term; This represents the random error term.
6. The water quality detection and prediction system based on time series analysis according to claim 5, characterized in that, The KPSS test statistic is based on the variance estimate of the cumulative sum of the series, and the formula is: ; In the formula, Representative error term Long-term variance estimation; Represents the number of time series observations; The sum of cumulative errors is expressed by the following formula: 。 7. The water quality detection and prediction system based on time series analysis according to claim 4, characterized in that, The dual verification mechanism includes: If the result of the ADF test is contrary to the null hypothesis, and the result of the KPSS test accepts the null hypothesis, the time series is determined to meet the stationarity requirement and passes the test; otherwise, the time series does not meet the stationarity requirement and fails the test. If the test fails, the time series is differentially analyzed until the stationarity requirement is met, and the iteration number is marked.
8. The water quality detection and prediction system based on time series analysis according to claim 7, characterized in that, The key parameters of the ARIMA model consist of three parts, including: the autoregressive order. Difference order and moving average order ; The difference order The number of iterations marked in the test where the dual verification mechanism failed; The autoregressive order and moving average order Determined based on the AIC and BIC criteria, the expression is: ; ; In the formula, The maximum likelihood function value represents the ARIMA model; This represents the total number of model parameters. .
9. The water quality detection and prediction system based on time series analysis according to claim 8, characterized in that, The steps for determining the optimal parameter combination of the ARIMA model are as follows: A1. Set the autoregressive order and moving average order Candidate order ; A2. Iterate through the array from (0,0) to (4,4) and construct the corresponding ARIMA model for each combination. ,in The number of iterations marked in the test where the dual verification mechanism failed; A3. Use the built-in `estimate` function to fit the model and obtain the log-likelihood value `logL`. Then, use the built-in `aicbic` function to calculate the corresponding [log-likelihood value] based on the model's log-likelihood value, the total number of model parameters, and the number of valid samples. , Find , Minimum value Combination, in combination with S2 This represents the optimal parameter combination for the ARIMA model.
10. The water quality detection and prediction system based on time series analysis according to claim 9, characterized in that, The model validation module validates the ARIMA model and finds a set of optimal model parameters. Specifically, it includes: B1. Call the built-in estimate function to perform parameter estimation. The built-in estimate function is based on optimization methods such as maximum likelihood estimation. It automatically searches and outputs a set of optimal parameters and returns two main outputs. The first of these is a complete ARIMA model object containing all estimated parameters. This ARIMA model object will be directly used for subsequent predictive analysis. B2. Based on the ARIMA model trained above, call the forecast function to make multi-step predictions of future water quality indicators. This multi-step prediction requires specifying the model object, prediction step size, and historical data sequence as input.