A shared bicycle demand prediction method, system, device and medium
By optimizing the combination of long short-term memory neural network and random forest model through the sparrow search algorithm and combining it with spatiotemporal cube model, the problem of insufficient model generalization ability in shared bicycle demand forecasting is solved, and high-precision demand forecasting and improved operational management efficiency are achieved.
Patent Information
- Application Number
- CN202510136671.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-07
- Publication Date
- 2025-11-04
- Estimated Expiration
- 2045-02-07
AI Technical Summary
Existing methods for forecasting demand for shared bicycles neglect the generalization ability of the models, which limits the improvement of forecast accuracy. Furthermore, most combined methods fail to fully leverage the forecasting advantages of their respective models, leading to a prominent supply-demand imbalance.
The parameters of the Long Short-Term Memory Neural Network (LSTM) are optimized using the Sparrow Search Algorithm. The LSM and Random Forest model are combined using the least squares method, and the spatiotemporal cube model is used for demand forecasting. The Sparrow Search Algorithm is used to classify sparrows into explorers, followers, and vigilants for parameter optimization. The weights are set using the least squares method, and spatiotemporal analysis is performed using POI data.
It has improved the accuracy and precision of shared bicycle demand forecasting, reduced errors, enhanced operational management efficiency, facilitated people's travel, and optimized vehicle distribution.
Smart Images

Figure CN120494877B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of computer application technology, and specifically relates to a method, system, device and medium for predicting the demand of shared bicycles. Background Technology
[0002] Green transportation is a current trend in urban transportation development. While urban rail transit can effectively alleviate urban congestion, its limitations in coverage and flexibility lead to the "last mile" problem. Shared bicycles, with their convenience and environmental friendliness, fill this gap, improving the efficiency of short-distance travel and becoming an important part of urban transportation. However, the imbalance between supply and demand for shared bicycles is becoming increasingly prominent, especially around subway stations, where inaccurate demand forecasting leads to either bicycle accumulation or shortages. Therefore, accurate forecasting of shared bicycle demand is crucial for optimizing bicycle distribution, improving service efficiency, and enhancing urban traffic management.
[0003] When forecasting demand for shared bicycles, most methods combine multiple models to improve prediction accuracy. This approach, based on different research data, utilizes various combined models, machine learning algorithms, and deep learning techniques to enhance the accuracy and precision of shared bicycle demand forecasts. However, it often overlooks the generalization ability of the models. Furthermore, most combination methods simply combine similar models, failing to fully leverage the predictive strengths of each individual model. This simplistic approach not only fails to achieve predictive results but also limits the improvement in the accuracy of the combined model. To address this issue, it is necessary to combine different types of models as needed to fully utilize their predictive advantages. Summary of the Invention
[0004] To address the shortcomings of existing methods in forecasting demand for shared bicycles, this invention provides a method, system, device, and medium for forecasting demand for shared bicycles.
[0005] To achieve the above objectives, the present invention provides the following technical solution:
[0006] A method for demand forecasting of shared bicycles includes the following steps:
[0007] Obtain order data of shared bicycles at transportation stations in the target area as a training set;
[0008] The parameters of the Long Short-Term Memory Neural Network (LSTM) are optimized using the Sparrow Search algorithm, and the optimized LSTM and the Random Forest model are combined by setting weights using the least squares method. The data in the training set is then input into the combined model to train the model, resulting in a demand prediction model.
[0009] Input the order data of shared bicycles in the area to be predicted into the demand prediction model to obtain the demand prediction data of shared bicycles in the target area within a set time period.
[0010] Preferably, the sparrow search algorithm is used to optimize the parameters of the long short-term memory neural network. Specifically, the sparrows in the population are divided into explorers, followers, and guardians by the sparrow search algorithm, and the optimal parameters are output through the following formula:
[0011] The initial position of the population is specifically: X = lb + rand·(ub - lb);
[0012] where ub and lb respectively represent the upper and lower position boundaries of the population;
[0013] The position update rule of the explorer in the sparrow search algorithm is specifically:
[0014]
[0015] where represents the jth dimension parameter of the ith sparrow in the tth iteration; iter max is the maximum number of iterations; α is a random number belonging to (0, 1); ST and AL respectively represent the safety threshold and alarm value; Q is a random number obeying the normal distribution; d is the maximum dimension of the sparrow parameter; L is a 1×d-dimensional matrix with all elements being 1; when AL < ST, it means that there are no predators around, and the producers enter the extensive search mode. If AL ≥ ST, it means that some sparrows have found predators, and all sparrows need to quickly transfer to other safe areas;
[0016] The position update rule of the follower in the sparrow search algorithm is specifically:
[0017]
[0018] where n is the total number of the current sparrow population; X p is the position of the sparrow occupying the best position in the current population; X uorst is the position of the sparrow occupying the worst position in the current population; A is a 1×d matrix satisfying A + = A T (AA T )-1; the elements in A are randomly taken as 1 or -1; if i is greater than it means that the current sparrow position needs to fly to a farther place to forage. If i is less than or equal to it means that the current sparrow position needs to approach the sparrow with the best position;
[0019] The position update rule of the guardian in the sparrow search algorithm is specifically:
[0020]
[0021] in, This indicates the current center position of the population, where the surrounding area is safe; β is a compensation control parameter that follows a standard normal distribution; K is a random number between [-1, 1]; ε is an infinitesimal used to prevent the denominator from being 0; f i It is the current fitness level of the sparrow; f g It is the fitness of sparrows in optimal position; f w It is the fitness of sparrows in the worst position of the population; when f i >f g When f indicates that the sparrow is currently on the edge of the population and is extremely vulnerable to attack, i =f g This indicates that the sparrow in the center of the population has realized the danger and has begun to move towards other sparrows to reduce the risk of being preyed upon.
[0022] Preferably, the optimized Long Short-Term Memory Neural Network and the Random Forest model are combined using the least squares method. Specifically, the weights of each model are obtained by minimizing the sum of squared prediction errors of the combined models, calculated using the following formula:
[0023] The specific calculation of the combined model results is as follows:
[0024] in, Let w1, w2, ..., wt represent the t-th predicted value obtained by the i-th single prediction model; n These are the weights of the n models, and the sum of the weights of the n models is 1.
[0025] e(t) represents the error of the combined prediction at time t, and y(t) represents the actual observed value. The specific formula for calculating e(t) is as follows:
[0026]
[0027] Among them, e i (t) represents the prediction error of the i-th single model at time t, and
[0028] The formula for calculating the sum of squared prediction errors R of the combined prediction model is as follows:
[0029]
[0030] Find the weight w of the minimum sum of squared prediction errors. i The weights of each model are transformed into a constrained combined prediction model to calculate the weights of each model. The specific calculation formula is as follows:
[0031]
[0032] Preferably, the method further includes analyzing the spatio-temporal information of each station in the area to be predicted using the acquired POI data and a spatio-temporal cube model to obtain variables associated with the shared bicycle usage data attributes within the spatio-temporal cube. Combined with the demand prediction data output by the demand prediction model, the spatial distribution of order prediction results for each station in the area to be predicted is obtained. Here, POI data refers to geographic information point data.
[0033] Preferably, it also includes selecting the mean absolute error (MAE), root mean square error (RMSE), and coefficient of determination (R²). 2 Evaluation of the model's predictive performance using three indicators related to error calculation.
[0034] This invention also provides a demand forecasting system for shared bicycles at subway entrances, specifically including:
[0035] The data acquisition module is used to acquire order data of shared bicycles at transportation stations in the target area as a training set.
[0036] The model building module is used to optimize the parameters of the long short-term memory neural network using the sparrow search algorithm, and to combine the optimized long short-term memory neural network and the random forest model by setting weights using the least squares method; the data in the training set is input into the combined model to train the model and obtain the demand prediction model.
[0037] The demand forecasting module is used to input the order data of shared bicycles in the area to be forecasted into the demand forecasting model to obtain the demand forecast data of shared bicycles in the target area within a set time period.
[0038] The present invention also provides a computer device, including a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps described in the method for demand forecasting of shared bicycles.
[0039] The present invention also provides a computer-readable storage medium storing a computer program that, when loaded by a processor, can execute the steps described in the shared bicycle demand forecasting method.
[0040] The demand forecasting method for shared bicycles provided by this invention has the following beneficial effects:
[0041] This invention obtains the number of shared bicycle orders in a target area and optimizes the model parameters of a Long Short-Term Memory (LSTM) network using a sparrow search algorithm. This achieves high convergence accuracy and finds the optimal solution for the model parameters globally. The least squares method is used to combine the LSM network and the Random Forest model by setting weights. The LSTM model has the ability to capture long-term dependencies in time-series data, and the Random Forest model can handle nonlinear relationships and static features. By leveraging the advantages of each model, the analysis and prediction capabilities for demand around subway stations are improved, reducing the errors and risks that may arise from a single model. Furthermore, the prediction ability and accuracy are significantly improved. A demand prediction model is obtained by training the combined model. This demand model predicts demand at stations with significant changes in shared bicycle usage and high usage, improving the operational management efficiency of shared bicycles and facilitating people's travel. Attached Figure Description
[0042] To more clearly illustrate the embodiments and design schemes of the present invention, the accompanying drawings required for this embodiment will be briefly described below. The drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0043] Figure 1 This is a flowchart of a demand forecasting method for shared bicycles according to the present invention.
[0044] Figure 2 This is a structural diagram of the long short-term memory network model in an embodiment of the present invention.
[0045] Figure 3 This is a structural diagram of the random forest model in an embodiment of the present invention.
[0046] Figure 4 This is an example of the SSA-LSTM model fitting the training set in this embodiment of the invention.
[0047] Figure 5 This shows the fitting effect of the SSA-LSTM model on the test set in this embodiment of the invention.
[0048] Figure 6 This shows the fitting effect of the SSA-RF model on the training set in this embodiment of the invention.
[0049] Figure 7 This shows the fitting effect of the SSA-RF model on the test set in this embodiment of the invention.
[0050] Figure 8 This is the fitting effect of the SSA-LSTM-RF model on the training set in this embodiment of the invention.
[0051] Figure 9This shows the fitting effect of the SSA-LSTM-RF model on the test set in this embodiment of the invention.
[0052] Figure 10 This is a spatiotemporal cube representing each station in region A in this embodiment of the invention.
[0053] Figure 11 R represents the predicted results of shared bicycle order data for various stations in region A in this embodiment of the invention. 2 Schematic diagram of a spacetime cube.
[0054] Figure 12 This is a flowchart of a demand forecasting method for shared bicycles according to an embodiment of the present invention. Detailed Implementation
[0055] To enable those skilled in the art to better understand and implement the technical solutions of the present invention, the present invention will be described in detail below with reference to the accompanying drawings and specific embodiments. The following embodiments are only used to more clearly illustrate the technical solutions of the present invention and should not be construed as limiting the scope of protection of the present invention.
[0056] Example
[0057] This invention provides a method for forecasting the demand for shared bicycles. Taking region A as an example, for instance... Figure 12 As shown, the specific steps include:
[0058] S1. Obtain the daily order table of shared bicycle companies from the data open platform released by the Transportation Bureau of Region A. The shared bicycle order data fields include the start time, start location, user ID, and company ID. Region A generates millions of shared bicycle order data every day. Some orders contain abnormal data due to unstable GPS signals, vehicle malfunctions, mobile network delays, and system errors. These abnormal data can interfere with the accuracy of analysis and prediction results. Therefore, before analyzing the data, it is necessary to clean the data and retain the normal order data. Divide the normal order data into training set and test set.
[0059] Region A has a total of 57 subway stations. The data includes the latitude and longitude of each station and the subway lines in Region A. Additionally, the intersection tool in ArcGIS was used to extract subway stations and related lines for a specific district from the crawled data on subway stations and lines in Region A.
[0060] The 600m radius not only meets the convenient walking distance to the subway station but also covers areas where cycling originates and terminates in concentrated quantities. Further data analysis revealed that the number of shared bike orders originating in this area exceeds 60% of the city's total orders, making it a hotspot for shared bike usage. This effectively covers areas with high demand for shared bikes while also meeting the convenient walking and cycling distance requirements. Therefore, a buffer zone with a radius of 600m centered on the subway station is considered the research scope surrounding the subway station.
[0061] POI data is an important component of map products, characterized by a large sample size, rapid update speed, and detailed and reliable information, containing a wealth of attribute information. This primarily includes name, location, longitude, latitude, and category. Due to its spatial attributes, it plays a crucial role in spatial analysis and visualization.
[0062] S2. Establish a Sparrow Search Algorithm-Long Short-Term Memory Neural Network-Random Forest combined model (SSA-LSTM-RF). The prediction model is based on the Long Short-Term Memory Neural Network and Random Forest. The Sparrow Search Algorithm is used to optimize the hyperparameters of the Long Short-Term Memory Neural Network (LSTM) model. Then, least squares weight combination is used to combine the optimized Long Short-Term Memory Neural Network and Random Forest models. Data from the training set is input into the combined model to train it, resulting in the demand prediction model.
[0063] Long Short-Term Memory (LSTM) networks are a special form of artificial RNNs that overcomes the gradient explosion / vanishing problem. This model consists of three units (the storage portion of the LSTM unit): an input unit, an output unit, and a forget gate, as shown below. Figure 2 As shown. These cells regulate the information flow within the LSTM. The forget gate (often called the memory vector) is responsible for removing information that no longer supports the learning process. The input gate, also called the save vector, is responsible for adding information to the cell state (long-term memory) through a stepwise process to ensure that important information is added. Due to these two operations, LSTM can retain the memory of recurrent patterns, significantly improving the predictive ability of standard RNNs, such as... Figure 2 As shown.
[0064] The calculation for the forgetting gate is as follows:
[0065] f t =σ(W f ·[h t-1 ,x t ]+b f );
[0066] The calculation of the input gate is as follows:
[0067] i t =σ(Wi ·[h t-1 ,x t ]+b i );
[0068]
[0069] Output gate: The output gate determines the output of the current state. The calculation is as follows:
[0070] O t =σ(W O ·[h t-1 ,x t ]+b O );
[0071] h t =σ t [tanh(C t )];
[0072] Where σ is the sigmoid function; tanh is the tanh function; W f W i W c W o Both are weight matrices; b f b i b C b o All are bias matrices; h t This is the output of the current state; x t This is the current state input; C t It is currently in a hidden state.
[0073] Random forest is an ensemble learning method that constructs multiple decision trees and introduces randomness in samples and features to make decisions for classification problems or predict outcomes for regression problems using a voting mechanism. Each decision tree is trained on a randomly sampled subset, and the final result is an ensemble of multiple decision trees, such as... Figure 3 As shown in the figure. This method can improve the performance and robustness of the model, solve the problems of local optimization and overfitting that exist when using a single decision tree for regression, and is suitable for various classification and regression tasks.
[0074] The sparrow search algorithm is used to optimize the model parameters of the Long Short-Term Memory Neural Network. The sparrow search algorithm divides the sparrows in the group into explorers, followers, and watchdogs, which is specifically calculated using the following formula:
[0075] The initial position of the population is: X = lb + rand·(ub - lb);
[0076] Where ub and lb represent the upper and lower boundaries of the population, respectively;
[0077] The position update rule of the explorer in the sparrow search algorithm is specifically as follows:
[0078]
[0079] Where: represents the j - dimensional parameter of the i - th sparrow in the t - th iteration; iter max is the maximum number of iterations; α is a random number belonging to (0, 1); ST and AL represent the safety threshold and the alarm value respectively; Q is a random number obeying the normal distribution; d is the maximum dimension of the sparrow parameters; L is a 1×d - dimensional matrix with all elements being 1; when AL < ST, it means there is no predator around, and the producer enters the extensive search mode. If AL ≥ ST, it means that some sparrows have found the predator, and all sparrows need to quickly transfer to other safe areas;
[0080] The position update rule of the follower in the sparrow search algorithm is specifically as follows:
[0081]
[0082] Where, n is the total number of the current sparrow population; X p is the position of the sparrow that occupies the best position in the current population; X uorst is the position of the sparrow that occupies the worst position in the current population; A is a 1×d - dimensional matrix that satisfies A + =A T (AA T ) - 1; the elements in A are randomly taken as 1 or - 1; if i is greater than it means that the current sparrow's position is not good and it needs to fly to a farther place to forage. If i is less than or equal to it means that the current sparrow's position is acceptable and it needs to move closer to the sparrow with the best position;
[0083] The position update rule of the vigilant in the sparrow search algorithm is specifically as follows:
[0084]
[0085] Where, represents the central position of the current population and the surrounding is safe; β is the compensation control parameter, obeying the standard normal distribution; K is a random number between [-1, 1]; ε is an infinitesimal used to prevent the denominator from being 0; f i is the fitness of the current sparrow; f g is the fitness of the sparrow in the best position in the population; f w is the fitness of the sparrow in the worst position in the population; when f i >f g it means that the current sparrow is at the edge of the population and is extremely vulnerable to attack. When fi =f g This indicates that the sparrow in the center of the population has realized the danger and has begun to move towards other sparrows to reduce the risk of being preyed upon.
[0086] Optimizing LSTM model parameters using SSA includes the learning rate, the number of hidden layer units, and the regularization coefficient. LSTM models, due to their high complexity and flexibility, can capture subtle features in training data, including noise. However, they are prone to overfitting, especially under conditions of insufficient data, excessively long training times, lack of regularization, insufficient validation sets, or excessively large model sizes. To avoid this problem, appropriate regularization techniques, early stopping strategies, and reasonable learning rate scheduling are typically employed to improve the model's generalization ability.
[0087] The optimized models are combined using least squares weighted combination. Specifically, the weight of each individual model is determined by minimizing the sum of squared prediction errors of the combined models, calculated using the following formula:
[0088] The specific calculation of the combined model results is as follows:
[0089] in, Let w1, w2, ..., wt represent the t-th predicted value obtained by the i-th single prediction model; n These are the weights of the n models, and the sum of the weights of the n models is 1.
[0090] If e(t) is the error of the combined prediction at time t, and y(t) represents the actual observed value, then the specific formula for calculating e(t) is as follows:
[0091]
[0092] Among them, e i (t) represents the prediction error of the i-th single model at time t, and
[0093] If R is the sum of squared prediction errors of the combined prediction model, the specific calculation formula is as follows:
[0094]
[0095] Find the weight w of the minimum sum of squared prediction errors. i Therefore, the problem of calculating the weights of each model can be transformed into calculating the weights of each model using a constrained combined prediction model. The specific calculation formula is as follows:
[0096]
[0097] To evaluate the predictive performance of the mixture model and individual models, common evaluation metrics are selected for model comparison. The generalization ability of the predictive model is usually used as the main evaluation metric. Generalization ability refers to the degree of model fit; overfitting or underfitting occurs when the actual values differ significantly from the model's predictions. Both of these phenomena can deviate from the model's prediction accuracy and are the main criteria for evaluation. Therefore, MAE, RMSE, and R-squared are chosen. 2 Three metrics related to error calculation are used to evaluate the model's predictive performance.
[0098] Mean Absolute Error (MAE) is a common metric used to evaluate the performance of predictive models. It measures the average absolute difference between the model's predictions and the actual observed values; in other words, the average absolute distance between the predicted and actual values. The calculation of MAE is as follows:
[0099]
[0100] A smaller MAE indicates a smaller prediction error and better model performance. One advantage of MAE is its insensitivity to outliers because it uses absolute differences to measure prediction error, rather than squared differences. MAE is an intuitive and easy-to-understand evaluation metric that is widely used in many practical applications.
[0101] RMSE is a common metric for measuring the performance of a predictive model. It is the square root of the ratio of the square of the deviation between the predicted and actual values to the number of observations, n. Compared to MAE, RMSE is more sensitive to outliers because it sums the squares of the errors and then takes the square root. The formula is as follows:
[0102]
[0103] Because RMSE sums the squares of the errors and then takes the square root, it pays more attention to large deviations between the predicted and actual values, making it more sensitive to outliers.
[0104] R 2 The coefficient of determination (COD) represents the extent to which the model explains the variance of the observed data. It measures how well the model fits the data, and is calculated using the following formula:
[0105]
[0106] The numerator represents the sum of the squared differences between the true and predicted values, similar to the mean squared error (MSE); the denominator represents the sum of the squared differences between the true and predicted values, similar to the variance (Var). R 2The value of is between 0 and 1, and the closer it is to 1, the better the model fits the data.
[0107] The SSA-optimized LSTM model is trained using the training set data, such as... Figure 4 The image shows the fitting performance of the SSA-LSTM model on the training set. The prediction results of the model on the test set, obtained by predicting on the SSA-optimized LSTM model, are shown below. Figure 5 As shown, the model performs well in predicting peak values on the test set, proving that the model performs well on the test set.
[0108] The training set was used to make predictions on the SSA-optimized random forest model, and the model's fitting results on the training and test sets were obtained as follows: Figure 6 and Figure 7 As shown, the model has a good overall fit, but the fit of some peak values in the training set is better than that of the SSA-LSTM model. However, the local peak values have not yet reached the ideal effect and need to be improved. The true values of some peak values in the test set are higher than the predicted values.
[0109] The training set of shared bicycle order data was fitted using SSA-LSTM and SSA-RF models respectively. Based on the fitting results of the two models, the weights of the LSTM model were calculated to be 0.40685 and the random forest model to be 0.59127. The two models were then fused, and the resulting SSA-LSTM-RF model showed the following fitting results for the training set and prediction results for the test set: Figure 8 and Figure 9 As shown. The model performs well on the test set R. 2 Both are higher than LSTM and random forest models, while MAE and RMSE are lower than the two individual models, indicating that the combined model has better fit and lower fit error.
[0110] To compare the SSA-LSTM-RF model with common shared bicycle prediction models, the SARIMA model and the LightGBM model were used to predict shared bicycle order data at Zhuguang Station. The MAE, RMSE, and R-values of each model on the test set were obtained. 2 As shown in Table 1, the prediction results show that the SSA-LSTM and RF models have smaller prediction errors and greater goodness of fit than the SARIMA and LightGBM models, demonstrating the scientific validity of selecting the hybrid model combining LSTM and Random Forest. The overall performance of the SSA-LSTM-RF model is superior to any single model, and it shows a goodness of fit of 99.43% on the order data. (See Table 1 for details.)
[0111] Table 1 Prediction Results Parameters for Each Model on the Test Set
[0112] Model MAE RMSE <![CDATA[R 2 ]]> SARIMA 23.1467 48.0842 0.9331 LightGBM 12.6983 20.9346 0.9873 SSA-LSTM 9.8125 14.3970 0.9921 SSA-RF 9.0461 15.3594 0.9932 SSA-LSTM-RF 8.9631 14.0067 0.9943
[0113] S3. Input the order data of shared bicycles from the other subway stations in area A into the demand forecasting model to obtain the demand forecast data of shared bicycles in the entire area A within a set time period.
[0114] S4. The Spatio-Temporal Cube model is a multidimensional data model used for analyzing and visualizing spatio-temporal data. This model combines spatial and temporal dimensions, allowing for better understanding and analysis of spatial data that changes over time. Predictions for each site require analysis of the spatio-temporal cube. By analyzing the characteristics and changing patterns of the spatio-temporal cube, its potential structural similarities are measured and grouped, revealing the organizational relationships of shared bicycle usage data attributes within the spatio-temporal cube. The acquired POI data is input into the spatio-temporal cube model, and correlation analysis is performed on each variable with shared bicycle usage demand. Variables with the most significant impact are selected for filling. The spatio-temporal cubes of shared bicycle orders around each site are constructed using the ArcGIS Pro geoprocessing toolbox. The filling format settings for each variable are shown in Table 2, resulting in the spatio-temporal cubes for each site. Figure 10 As shown, each site has 1344 layers of stacked structure, with each layer containing different information, and each layer representing a sample.
[0115] Table 2 Cube Variable Filling Forms
[0116] Variable name Fill form Shared bike usage around the station Time trend Is it a holiday? Time trend Residents around the station Spatial elements Employed population around the station Spatial elements Number of restaurants around the station Spatial elements Number of commercial areas around the station Spatial elements Number of office buildings around the station Spatial elements Number of schools near the station Spatial elements Number of hospitals near the station Spatial elements Number of bus stops around the station Spatial elements
[0117] The SSA-LSTM-RF model was used to predict the spatiotemporal cubes of each subway station. The first 1152 samples from each station were selected as the training set, and the last 192 samples were selected as the test set. The R-squared values of the prediction results for shared bicycle order data at each station were obtained. 2 like Figure 11 As shown, view the R of Zhuguang Station 2 The values were 0.9951 and 0.9882 respectively, indicating that the SSA-LSTM-RF model did not suffer a decrease in predictive performance despite the inclusion of other subway station data and subway station built-up environment attribute data. By examining the order numbers for each station, the goodness-of-fit R-value was found to be... 2 Areas with a value less than 0.8 are mostly concentrated around subway stations where the number of shared bicycles used during peak hours is less than 500.
[0118] This invention also provides a demand forecasting system for shared bicycles at subway entrances, specifically including:
[0119] The data acquisition module is used to acquire order data of shared bicycles at transportation stations in the target area as a training set.
[0120] The model building module is used to optimize the parameters of the Long Short-Term Memory Neural Network using the Sparrow Search algorithm, and to combine the optimized Long Short-Term Memory Neural Network and the Random Forest model by setting weights using the least squares method; the data in the training set is input into the combined model to train the model and obtain the demand prediction model.
[0121] The demand forecasting module is used to input the order data of shared bicycles in the area to be forecasted into the demand forecasting model to obtain the demand forecast data of shared bicycles in the target area within a set time period.
[0122] The various modules in the aforementioned demand forecasting system for shared bicycles at subway entrances can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the computer device's memory as software, so that the processor can call and execute the corresponding operations of each module.
[0123] The present invention also provides a computer device, including a memory, a processor, and a computer program stored in the memory. The processor executes the computer program to implement the steps in an embodiment of a demand forecasting method for shared bicycles. Specific implementation methods can be found in the method embodiments, and will not be repeated here.
[0124] Furthermore, the present invention also provides a non-transitory computer-readable storage medium containing instructions on which a computer program is stored. For example, a memory containing instructions that can be executed by a processor of a computer device to perform the above-described method. For example, the non-transitory computer-readable storage medium may be a ROM, random access memory (RAM), CD-ROM, magnetic tape, floppy disk, and optical data storage device, etc. When the computer program is executed by the processor, it can implement the steps in an embodiment of a demand forecasting method for shared bicycles. Specific implementation methods can be found in the method embodiments, which will not be repeated here.
[0125] Those skilled in the art will understand that embodiments of the present invention can provide methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0126] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, as well as combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0127] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0128] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0129] It should be noted that the specific embodiments described above enable those skilled in the art to more fully understand the present invention, but do not limit the present invention in any way. Therefore, although the present invention has been described in detail in this specification and embodiments, those skilled in the art should understand that modifications or equivalent substitutions can still be made to the present invention; and all technical solutions and improvements that do not depart from the spirit and scope of the present invention are covered within the protection scope of the present invention patent. No reference numerals in the claims should be construed as limiting the scope of the claims. Any simple variations or equivalent substitutions of technical solutions that can be readily obtained by those skilled in the art within the scope of the technology disclosed in the present invention are within the protection scope of the present invention.
Claims
1. A method for demand forecasting of shared bicycles, characterized in that, Includes the following steps: Obtain order data of shared bicycles at transportation stations in the target area as a training set; The parameters of the Long Short-Term Memory Neural Network (LSTM) and Random Forest model are optimized using the Sparrow Search algorithm. The optimized LSTM and Random Forest models are then combined by assigning weights using the least squares method. Data from the training set is input into the combined model, and the model is trained to obtain a demand prediction model. Specifically, the weights of each model are obtained by minimizing the sum of squared prediction errors of the combined models, calculated using the following formula: The specific calculation of the combined model results is as follows: in, Let w1, w2, ... w represent the t-th predicted value obtained by the i-th single prediction model; i ···,w n These are the weights of the n models, and the sum of the weights of the n models is 1. e(t) represents the error of the combined prediction at time t, and y(t) represents the actual observed value. The specific formula for calculating e(t) is as follows: Among them, e i (t) represents the prediction error of the i-th single model at time t, and The formula for calculating the sum of squared prediction errors R of the combined prediction model is as follows: Find the weight w of the minimum sum of squared prediction errors. i The weights of each model are transformed into a constrained combined prediction model to calculate the weights of each model. The specific calculation formula is as follows: The order data of shared bicycles in the area to be predicted is input into the demand prediction model to obtain the demand prediction data of shared bicycles in the target area within a set time period.
2. The demand forecasting method for shared bicycles according to claim 1, characterized in that, The method of optimizing the parameters of the Long Short-Term Memory Neural Network and Random Forest model using the sparrow search algorithm involves dividing the sparrows in the group into explorers, followers, and vigilants, and then calculating and outputting the optimal parameters using the following formula: The initial position of the population is: X = lb + rand·(ub - lb); Where ub and lb represent the upper and lower boundaries of the population, respectively; The explorer position update rule in the sparrow search algorithm is as follows: Among them, represents the j-th dimensional parameter of the i-th sparrow in the t-th iteration; iter max is the maximum number of iterations; α is a random number belonging to (0, 1); ST and AL represent the safety threshold and the alarm value respectively; Q is a random number obeying the normal distribution; d is the maximum dimension of the sparrow parameters; L is a 1×d dimensional matrix with all elements being 1; when AL < ST, it means there is no predator around, and the producers enter the extensive search mode. When AL ≥ ST, it means the sparrows have found a predator, and all sparrows need to quickly transfer to a safe area; The follower position update rule in the sparrow search algorithm is as follows: Where n is the current total number of sparrows; X p The position of the sparrow that currently occupies the best spot in the population; X worst A is the position of the sparrow that occupies the worst position in the current population; A is a condition that satisfies A. + =A T (AA T A 1×d matrix of size i, where i is a random number of elements (1 or -1). This means the sparrow needs to fly further to find food; if i is less than or equal to This means the current sparrow needs to move closer to the sparrow in the best position; The specific rules for updating the position of the watcher in the sparrow search algorithm are as follows: in, This indicates the current center position of the population, where the surrounding area is safe; β is a compensation control parameter that follows a standard normal distribution; K is a random number between [-1, 1]; ε is an infinitesimal used to prevent the denominator from being 0; f i It is the current fitness level of the sparrow; f g It is the fitness of sparrows in the optimal position of the population; f w It is the fitness of sparrows in the worst position of the population; when f i >f g When f indicates that the sparrow is on the edge of the population and will be attacked, i =f g This indicates that the sparrows in the center of the population are aware of danger and begin to move to reduce their risk of being preyed upon.
3. The demand forecasting method for shared bicycles according to claim 1, characterized in that, It also includes inputting the acquired POI data into a spatiotemporal cube model, analyzing the spatiotemporal information of each station in the area to be predicted, obtaining variables related to the shared bicycle usage data attributes within the spatiotemporal cube, and combining the demand prediction data output by the demand prediction model to obtain the spatial distribution of order prediction results for each station in the area to be predicted; where POI data refers to geographic information point data.
4. The demand forecasting method for shared bicycles according to claim 1, characterized in that, This also includes selecting the mean absolute error (MAE), root mean square error (RMSE), and coefficient of determination (R²). 2 Evaluation of the model's predictive performance using three indicators related to error calculation.
5. A demand forecasting system for shared bicycles at subway entrances, characterized in that, include: The data acquisition module is used to acquire order data of shared bicycles at transportation stations in the target area as a training set; The model building module optimizes the parameters of the Long Short-Term Memory Neural Network (LSTM) and Random Forest models using the Sparrow Search algorithm, and combines the optimized LSTM and Random Forest models by assigning weights using the least squares method. Data from the training set is input into the combined model, and the model is trained to obtain the demand prediction model. Specifically, the weights of each model are obtained by minimizing the sum of squared prediction errors of the combined models, calculated using the following formula: The specific calculation of the combined model results is as follows: in, Let w1, w2, ... w represent the t-th predicted value obtained by the i-th single prediction model; i ···,w n These are the weights of the n models, and the sum of the weights of the n models is 1. e(t) represents the error of the combined prediction at time t, and y(t) represents the actual observed value. The specific formula for calculating e(t) is as follows: Among them, e i (t) represents the prediction error of the i-th single model at time t, and The formula for calculating the sum of squared prediction errors R of the combined prediction model is as follows: Find the weight w of the minimum sum of squared prediction errors. i The weights of each model are transformed into a constrained combined prediction model to calculate the weights of each model. The specific calculation formula is as follows: The demand forecasting module is used to input the order data of shared bicycles in the area to be forecasted into the demand forecasting model to obtain the demand forecast data of shared bicycles in the target area within a set time period.
6. A computer device, comprising a memory, a processor, and a computer program stored in the memory, characterized in that, The processor executes the computer program to implement the steps of the method according to any one of claims 1 to 4.
7. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is loaded by the processor, it is able to perform the steps of the method according to any one of claims 1 to 4.
Citation Information
Patent Citations
Power transmission line icing thickness prediction method based on VMD-SSA-LSTM
CN117592592A
Short-term offshore wind power prediction method based on improved sparrow search algorithm
CN118199050A