Shared bicycle demand prediction method, system, device and medium
The combination of long and short-term memory neural network and random forest model is optimized through the sparrow search algorithm, and combined with the space-time cube model, the problem of insufficient generalization capabilities in the demand prediction of shared bicycles is solved, achieving higher prediction accuracy and operational efficiency.
Patent Information
- Application Number
- CN202510136671.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-07
- Publication Date
- 2025-08-15
- Estimated Expiration
- 2045-02-07
AI Technical Summary
The existing shared bicycle demand prediction method ignores the generalization ability of the model, resulting in limited improvement in prediction accuracy and failure to fully utilize the advantages of different types of models.
The sparrow search algorithm is used to optimize the parameters of long and short-term memory neural networks, and the long and short-term memory neural network and random forest model are combined by the least squares method, and demand prediction is carried out in combination with the space-time cube model.
It improves the accuracy and accuracy of shared bicycle demand forecasts, reduces errors, and improves operation management efficiency. It is suitable for shared bicycle demand analysis around subway stations.
Smart Images

Figure CN120494877A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of computer application technology, and specifically relates to a method, system, device and medium for predicting demand for shared bicycles. Background Art
[0002] Green transportation is the current trend in urban transportation. While urban rail transit can effectively alleviate urban congestion, it suffers from coverage and flexibility limitations, leading 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 a vital component of urban transportation. However, the imbalance between supply and demand for shared bicycles is prominent, particularly around subway stations, where inaccurate demand forecasts lead to backlogs or shortages. Therefore, accurately forecasting shared bicycle demand is crucial for optimizing vehicle distribution, improving shared bicycle service efficiency, and ultimately urban transportation management.
[0003] When forecasting shared bike demand, most approaches combine multiple models to improve prediction accuracy. This approach, based on diverse research data, applies a variety of combined models, machine learning algorithms, and deep learning techniques to improve the accuracy and precision of shared bike demand. However, this approach often overlooks the model's generalization capabilities. Furthermore, most combination methods simply combine models of the same type, failing to fully leverage the predictive strengths of each model. This simplistic combination not only fails to achieve predictive results but also limits the improvement in the combined model's prediction accuracy. To address this issue, it is necessary to combine different types of models as needed to fully leverage their respective strengths in forecasting. Summary of the Invention
[0004] In order to address the defects of existing methods in predicting the demand for shared bicycles, the present invention provides a method, system, device and medium for predicting the demand for shared bicycles.
[0005] In order to achieve the above object, the present invention provides the following technical solutions:
[0006] A method for predicting demand for shared bicycles includes the following steps:
[0007] Obtain order data for shared bicycles at transportation stations in the target area as a training set;
[0008] Optimizing the parameters of the long short-term memory neural network using a sparrow search algorithm, and combining the optimized long short-term memory neural network and the random forest model by weight setting using the least squares method; inputting the data in the training set into the combined model to train the model and obtain a demand forecasting 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 vigilants 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 represent the upper and lower position boundaries of the population respectively;
[0013] The position update rule of the explorer in the sparrow search algorithm is specifically:
[0014]
[0015] where represents the j-th dimension parameter of the i-th sparrow in the t-th iteration; iter is the maximum number of iterations; α is a random number belonging to (0, 1); ST and AL represent the safety threshold and alarm value respectively; Q is a random number obeying the normal distribution; d is the maximum dimension of the sparrow parameter; L is a 1×d 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 some sparrows have found the predator, 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 vigilante in the sparrow search algorithm is specifically:
[0020]
[0021] in, Indicates the center position of the current population, and the surrounding area is safe; β is the compensation control parameter, which obeys the standard normal distribution; K is a random number between [-1,1]; ε is infinitesimal, used to prevent the denominator from being 0; f i is the current sparrow’s fitness; f g is the fitness of the sparrows in the best position of the population; f w is the fitness of the sparrow in the worst position of the population; when f i >f g When f i =f g When , it means that the sparrows at the center of the population are aware of the danger and begin to move toward other sparrows to reduce the risk of being preyed upon.
[0022] Preferably, the optimized long short-term memory neural network and random forest model are combined by the least squares method, specifically by minimizing the sum of squares of the prediction errors of the combined model to obtain the weight of each model, which is calculated by the following formula:
[0023] The calculation of the combined model results is as follows:
[0024] in, represents the t-th prediction value obtained by the i-th single prediction model; w1,w2,···,w n are the weights of n models respectively, and the sum of the weights of n models is 1;
[0025] e(t) is the error of the combined prediction at time t, y(t) represents the actual observation value, and the calculation formula of 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 calculation formula of the forecast error sum of squares R of the combined forecast model is as follows:
[0029]
[0030] Find the weight w that minimizes the sum of squared prediction errors i , the weights of each model are converted into a combined prediction model with constraints to calculate the weights of each model. The specific calculation formula is:
[0031]
[0032] Preferably, the method also includes using the acquired POI data and a spatio-temporal cube (Spatio-TemporalCube) model to analyze the spatio-temporal information of each station in the prediction area, obtaining variables associated with the shared bicycle usage data attributes in the spatio-temporal cube, and combining the demand forecast data output by the demand forecast model to obtain the spatial distribution of order forecast results for each station in the prediction area; wherein, 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 determination coefficient R 2 Three indicators related to error calculation are used to evaluate the prediction effect of the model.
[0034] The present invention also provides a demand forecasting system for shared bicycles at subway entrances, which specifically includes:
[0035] The data acquisition module is used to obtain the 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 set weights for combining the optimized long short-term memory neural network and the random forest model using the least squares method; the data in the training set is input into the combined model to train the model and obtain a demand forecasting model.
[0037] The demand forecasting module is used to input the order data of shared bicycles in the area to be predicted 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, comprising 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 predicting demand for shared bicycles.
[0039] The present invention also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is loaded by a processor, it can execute the steps described in the method for predicting demand for shared bicycles.
[0040] The method for predicting demand for shared bicycles provided by the present invention has the following beneficial effects:
[0041] The present invention obtains the number of shared bicycle orders in the target area and optimizes the model parameters of the long short-term memory network through the sparrow search algorithm. It can obtain high convergence accuracy and search for the optimal solution of the model parameters in a global range. The least squares method is used to set weights for the long short-term memory network and the random forest model to combine them. The LSTM model has the ability to capture long-term dependencies in time series data and the random forest can handle nonlinear relationships and static features. The advantages of each model are brought into play to improve the ability to analyze and predict demand around the subway, reduce the errors and risks that may be caused by a single model, and greatly improve the prediction ability and accuracy. By training the combined model, a demand forecasting model is obtained. The demand model forecasts demand for stations with significant changes in the use of shared bicycles and high usage in the surrounding area, improves the operational management efficiency of shared bicycles, and facilitates people's travel. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] To more clearly illustrate the embodiments of the present invention and its design, the following briefly introduces the drawings required for this embodiment. The drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be derived from these drawings without inventive effort.
[0043] Figure 1 This is a flow chart of a method for predicting demand for shared bicycles according to the present invention.
[0044] Figure 2 2 is a structural diagram of a long short-term memory network model in an embodiment of the present invention.
[0045] Figure 3 2 is a structural diagram of a random forest model in an embodiment of the present invention.
[0046] Figure 4 This is the fitting effect of the SSA-LSTM model on the training set in an embodiment of the present invention.
[0047] Figure 5 This is the fitting effect of the SSA-LSTM model on the test set in an embodiment of the present invention.
[0048] Figure 6 This is the fitting effect of the SSA-RF model on the training set in the embodiment of the present invention.
[0049] Figure 7 This is the fitting effect of the SSA-RF model on the test set in an embodiment of the present invention.
[0050] Figure 8 This is the fitting effect of the SSA-LSTM-RF model on the training set in an embodiment of the present invention.
[0051] Figure 9This is the fitting effect of the SSA-LSTM-RF model on the test set in an embodiment of the present invention.
[0052] Figure 10 It is the space-time cube of each site in area A in the embodiment of the present invention.
[0053] Figure 11 is the prediction result of the shared bicycle order data of each station in area A in the embodiment of the present invention. 2 Schematic diagram of the space-time cube.
[0054] Figure 12 This is a flowchart of a method for predicting demand for shared bicycles according to an embodiment of the present invention. DETAILED DESCRIPTION
[0055] In order to enable those skilled in the art to better understand the technical solution of the present invention and to be able to implement it, the present invention is 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 solution of the present invention and are not intended to limit the scope of protection of the present invention.
[0056] Example
[0057] The present invention provides a method for predicting demand for shared bicycles. Taking area A as an example, Figure 12 As shown, the specific steps include:
[0058] S1. Obtain a daily order table for shared bicycle companies from the data open platform published by the Transportation Bureau of Region A. Shared bicycle order data fields include the order's start time, start location, user ID, and company ID. Region A generates millions of shared bicycle order data daily. Some orders contain abnormal data due to unstable GPS signals, vehicle failures, mobile network delays, and system errors. This data can affect the accuracy of analysis and prediction results. Therefore, before analyzing the data, it is necessary to clean the data and retain normal order data. The normal order data is divided into a training set and a test set.
[0059] There are 57 subway stations in Area A, which mainly include the latitude and longitude of the subway stations and the subway lines in Area A. In addition, the crawled subway stations in Area A and subway line data are used to extract the subway stations and related lines in a certain district.
[0060] The 600m radius not only meets the walking distance for connecting to subway stations but also covers areas with a high concentration of cycling start destinations. Further data analysis revealed that the number of initial shared bike orders in this area exceeds 60% of the city's total, making it a hotspot for shared bike use. This effectively covers areas with high demand for shared bikes while also being within a convenient walking and cycling distance. Therefore, a buffer zone with a 600m radius, centered around the subway station, was selected as the study area.
[0061] POI data is a crucial component of map products, characterized by large sample sizes, rapid updates, and detailed reliability. It contains extensive attribute information, primarily including name, location, longitude, latitude, and category. Its spatial attributes make it crucial for spatial analysis and visualization.
[0062] S2. Build a combined Sparrow Search Algorithm-Long Short-Term Memory Neural Network-Random Forest (SSA-LSTM-RF) model. This forecasting model is based on the LSTM neural network and random forest. The Sparrow Search Algorithm is used to optimize the hyperparameters of the LSTM model. The optimized LSTM and random forest models are then combined using least squares weighting. The combined model is trained using the data from the training set to produce a demand forecasting model.
[0063] Long Short-Term Memory (LSTM) is a special form of artificial RNN that overcomes the problem of gradient explosion / vanishing. The model consists of three units (the storage part of the LSTM unit): input unit, output unit, and forget gate, such as Figure 2 These cells regulate the flow of information 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 step-by-step process to ensure that important information is added. Thanks to these two operations, the LSTM can retain a memory of recurrent patterns, significantly improving the predictive power of standard RNNs, as shown in Figure 2. Figure 2 shown.
[0064] The calculation of the forget 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] Among them, σ is the sigmoid function; tanh is the tanh function; W f 、W i 、W c 、W o are all weight matrices; b f 、b i 、b C 、b o Both are bias matrices; h t is the output result of the current state; x t is the current state input; C t is the current hidden state.
[0073] Random forest is an ensemble learning method that builds multiple decision trees and introduces randomness in samples and features to make decisions for classification problems or predict 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 This method can improve the performance and robustness of the model, solve the problems of local optimization and overfitting when using a single decision tree for regression, and is suitable for various classification and regression tasks.
[0074] The model parameters of the long short-term memory neural network are optimized using the sparrow search algorithm. The sparrow search algorithm divides the sparrows in the group into explorers, followers, and guards. The specific calculation is based on the following formula:
[0075] The initial position of the population is specifically: X = lb + rand·(ub-lb);
[0076] Among them, ub and lb represent the upper and lower position 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 respectively represent the safety threshold and the alarm value; Q is a random number subject to a 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 are no predators around, and the producers enter the extensive search mode. If AL ≥ ST, it means that some sparrows have discovered predators, 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 approach 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, subject to 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 When , it means that the sparrows at the center of the population are aware of the danger and begin to move toward other sparrows to reduce the risk of being preyed upon.
[0086] Parameters optimized using SSA include the learning rate, number of hidden units, and regularization coefficient for the LSTM model. Due to its high complexity and flexibility, the LSTM model is able to capture subtle features in the training data, including noise. This makes it particularly prone to overfitting when there is insufficient data, prolonged training time, a lack of regularization, an insufficient validation set, or excessive model capacity. To avoid this problem, appropriate regularization techniques, early stopping strategies, and reasonable learning rate scheduling are often employed to improve the model's generalization capabilities.
[0087] The models with optimized parameters are combined through least square weight combination. Specifically, the weight of each single model is determined by minimizing the sum of squares of the prediction errors of the combined model. It is calculated by the following formula:
[0088] The calculation of the combined model results is as follows:
[0089] in, represents the t-th prediction value obtained by the i-th single prediction model; w1,w2,···,w n are the weights of n models respectively, and the sum of the weights of n models is 1;
[0090] If e(t) is the error of the combined forecast at time t; y(t) represents the actual observation value, then the calculation formula of e(t) is:
[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 squares of the prediction errors of the combined prediction model, the calculation formula is:
[0094]
[0095] Find the weight w that minimizes the sum of squared prediction errors i Therefore, the problem of the weight of each model can be transformed into a combined prediction model with constraints to calculate the weight of each model. The calculation formula is as follows:
[0096]
[0097] In order to judge the prediction effect of the hybrid model and each single model, common evaluation indicators are selected for model comparison. The generalization ability of the prediction model is usually used as the main evaluation indicator. The generalization ability refers to the degree of model fitting. When the degree of fitting is too high or too low, the actual value produced is greatly different from the model prediction value. This phenomenon is called overfitting or underfitting. Both phenomena will cause deviations in the model prediction accuracy and are the main criteria for investigation. Therefore, MAE, RMSE, R 2 Three indicators related to error calculation are used to evaluate the model prediction effect.
[0098] Mean absolute error (MAE) is a common metric used to evaluate the performance of a forecasting model. It measures the average absolute difference between the model's predictions and the actual observed values, i.e., the average absolute distance between the predicted values and the true values. MAE is calculated as follows:
[0099]
[0100] A smaller MAE indicates a smaller model's prediction error and better model performance. One advantage of MAE is that it is insensitive to outliers because it uses absolute differences rather than squared differences to measure prediction errors. 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 forecasting model. It is the square root of the ratio of the square of the deviation between the predicted value and the true value to the number of observations n. Compared with MAE, RMSE is more sensitive to outliers because it is calculated by summing the squares of the errors and then taking the square root. The calculation formula is as follows:
[0102]
[0103] Because RMSE sums the squared errors and then takes the square root, it focuses more on large deviations between the predicted values and the true values, making it more sensitive to outliers.
[0104] R 2 The Coefficient of Determination (COD) indicates how well the model explains the variance of the observed data. It measures how well the model fits the data and is calculated as follows:
[0105]
[0106] Among them, the numerator represents the sum of the squared differences between the true value and the predicted value, similar to the mean square error MSE; the denominator represents the sum of the squared differences between the true value and the mean, similar to the variance Var. 2The value range is between 0 and 1. The closer it is to 1, the better the model fits the data.
[0107] Use the training set data to train the SSA optimized LSTM model, such as Figure 4 The figure shows the fitting effect of the SSA-LSTM model on the training set. The SSA-optimized LSTM model is used to predict the test set, and the prediction results of the model on the test set are as follows: Figure 5 As shown in the figure, the model has a good peak prediction effect on the test set, which proves that the model performs well on the test set.
[0108] Use the training set to predict the random forest model after SSA optimization, and get the model fitting results for the training set and test set as follows Figure 6 and Figure 7 As shown in the figure, the model has a good fitting effect as a whole, but the fitting effect of some peaks in the training set is improved compared with the SSA-LSTM model. However, the local peaks have not yet reached the ideal effect and need to be improved. However, the true values of some peaks in the test set are higher than the predicted values.
[0109] The SSA-LSTM and SSA-RF models are used to fit the training set of shared bicycle order data. According to the fitting results of the two models, the weight of the LSTM model is calculated to be 0.40685 and the weight of the random forest model is 0.59127. The two models are fused and the SSA-LSTM-RF model is obtained. The fitting results of the training set and the prediction results of the test set are as follows: Figure 8 and Figure 9 As shown. The model has an R 2 Both are higher than the LSTM and random forest models, while the MAE and RMSE are lower than the two single models, indicating that the combined model has better goodness of fit and lower fitting error.
[0110] In order to compare the difference between the SSA-LSTM-RF model and the common shared bicycle prediction model, the SARIMA model and the LightGBM model were used to predict the Zhuguang Station shared bicycle order data, and the MAE, RMSE, and R of the prediction results of each model on the test set were obtained. 2 As shown in Table 1, the prediction results show that both the SSA-LSTM and RF models exhibit smaller prediction errors and greater goodness-of-fit than the SARIMA and LightGBM models, demonstrating the rationale behind the selection of a hybrid model combining LSTM and random forest. The SSA-LSTM-RF model's overall performance surpasses that of any single model, achieving a goodness-of-fit of 99.43% on the order data. (See Table 1.)
[0111] Table 1 Prediction results parameters of each model 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 at 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 to analyze and visualize spatiotemporal data. This model combines spatial and temporal dimensions, so that spatial data that changes over time can be better understood and analyzed. The prediction of each site requires an analysis of the spatiotemporal cube. By analyzing the characteristics of the spatiotemporal cube and its changing patterns, its potential structural similarities are measured and grouped, revealing the organizational relationship of the shared bicycle usage data attributes within the spatiotemporal cube. The acquired POI data is input into the spatiotemporal cube model, and the correlation between each variable and the demand for shared bicycle use is analyzed, and variables with more obvious influence are selected for filling. With the help of ArcGIS Pro's geoprocessing toolbox, a spatiotemporal cube is constructed for shared bicycle orders around each site. The filling form settings of each variable are shown in Table 2, and the spatiotemporal cube of each site is obtained, as shown in Table 2. Figure 10 As shown, each site has accumulated 1,344 layers of structures, each layer has different information, and each layer represents a sample.
[0115] Table 2 Cube variable filling form
[0116] variable name Filling form Shared bicycle usage around the station Time Trend Is it a holiday? Time Trend Population living around the site spatial elements Employed population around the site spatial elements Number of dining spots around the station spatial elements Number of commercial areas around the site spatial elements Number of office buildings around the site spatial elements Number of schools around the site spatial elements Number of hospitals around the site spatial elements Number of bus stops around the station spatial elements
[0117] The SSA-LSTM-RF model is used to predict the space-time cube of each subway station. The first 1152 samples of each station are selected as the training set, and the last 192 samples are selected as the test set. The R of the prediction results of the shared bicycle order data of each station is obtained. 2 like Figure 11 As shown, check the R of Zhuguang Station 2 The values are 0.9951 and 0.9882 respectively, indicating that the SSA-LSTM-RF model does not reduce the prediction performance due to the addition of other subway station data and subway station built environment attribute data. By looking at the number of orders for each station, we can see that the goodness of fit R 2 Areas with a value less than 0.8 are mostly concentrated in subway stations where the number of shared bicycle users is less than 500 during peak hours.
[0118] The present invention also provides a demand forecasting system for shared bicycles at subway entrances, which specifically includes:
[0119] The data acquisition module is used to obtain the 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 set the weights of the optimized long short-term memory neural network and the random forest model through the least squares method to combine them; the data in the training set is input into the combined model to train the model and obtain the demand forecasting model.
[0121] The demand forecasting module is used to input the order data of shared bicycles in the forecasted area into the demand forecasting model to obtain the demand forecast data of shared bicycles in the target area within a set time period.
[0122] Each module in the aforementioned subway entrance shared bicycle demand forecasting system can be implemented in whole or in part through software, hardware, or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in hardware form, or stored in a computer device's memory in software form, so that the processor can call and execute the corresponding operations of each module.
[0123] The present invention also provides a computer device comprising a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps of an embodiment of a method for predicting demand for shared bicycles. The specific implementation method can be found in the method embodiment and will not be repeated here.
[0124] Furthermore, the present invention also provides a non-temporary computer-readable storage medium containing instructions, on which a computer program is stored. For example, a memory containing instructions, the instructions can be executed by a processor of a computer device to complete the above method. For example, the non-temporary computer-readable storage medium can be a ROM, random access memory (RAM), CD-ROM, magnetic tape, floppy disk, and optical data storage device. When the computer program is executed by the processor, it can implement the steps in an embodiment of a method for predicting demand for shared bicycles. The specific implementation method can be found in the method embodiment, which will not be repeated here.
[0125] Those skilled in the art will appreciate that embodiments of the present invention may provide methods, systems, or computer program products. Thus, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0126] The present invention is described with reference to flowcharts and / or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowcharts and / or block diagrams, as well as combinations of processes and / or blocks in the flowcharts 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, a special-purpose computer, an embedded processor or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowcharts and / or block diagrams. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0127] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.
[0128] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0129] It should be pointed out that the specific implementation methods described above can enable those skilled in the art to understand the invention more comprehensively, but do not limit the invention in any way. Therefore, although the present specification and examples have described the invention in detail, those skilled in the art should understand that the invention can still be modified or replaced by equivalents; and all technical solutions and improvements that do not deviate from the spirit and scope of the invention are included in the scope of protection of the patent for the invention. Any figure mark in the claims should not be regarded as limiting the claims involved. Any simple change or equivalent replacement of the technical solution that can be obviously obtained by any person familiar with the art within the technical scope disclosed in the present invention falls within the scope of protection of the present invention.
Claims
1. A method for predicting demand for shared bicycles, characterized in that: The following steps are involved: Obtain order data for shared bicycles at transportation stations in the target area as a training set; Optimizing the parameters of the long short-term memory neural network using a sparrow search algorithm, and combining the optimized long short-term memory neural network and the random forest model by weight setting using the least squares method; inputting the data in the training set into the combined model to train the model and obtain a demand forecasting model; 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 method for predicting demand for shared bicycles according to claim 1, characterized in that: The sparrow search algorithm is used to optimize the parameters of the long short-term memory neural network. Specifically, the sparrows in the group are divided into explorers, followers, and guards by the sparrow search algorithm, and the optimal parameters are output by calculating the following formula: The initial position of the population is specifically: X = lb + rand·(ub-lb); Among them, ub and lb represent the upper and lower position boundaries of the population respectively; The explorer position update rules in the sparrow search algorithm are 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 subject to a 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 rules in the sparrow search algorithm are as follows: Where n is the total number of sparrow populations; X p is the position of the sparrow with the best position in the current population; X uorst is the position of the sparrow with the worst position in the current population; A is a sparrow that satisfies A + =A T (AA T )-1 1×d matrix; the elements in A are randomly 1 or -1; if i is greater than It means that the current sparrow needs to fly farther to find food; if i is less than or equal to This means that the current sparrow needs to move closer to the sparrow with the best position; The specific rules for updating the position of the sentinel in the sparrow search algorithm are: in, Indicates the center position of the current population, and the surrounding area is safe; β is the compensation control parameter, which obeys the standard normal distribution; K is a random number between [-1,1]; ε is infinitesimal, used to prevent the denominator from being 0; f i is the current sparrow’s fitness; f g is the fitness of the sparrows in the best position of the population; f w is the fitness of the sparrow in the worst position of the population; when f i >f g When f i =f g When , it means that the sparrows at the center of the population are aware of the danger and start to move to reduce the risk of being preyed upon.
3. The method for predicting demand for shared bicycles according to claim 1, characterized in that: The optimized long short-term memory neural network and random forest model are combined by the least squares method. Specifically, the weight of each model is obtained by minimizing the sum of squares of the prediction errors of the combined model, which is calculated by the following formula: The calculation of the combined model results is as follows: in, represents the t-th prediction value obtained by the i-th single prediction model; w1,w2,···,w n are the weights of n models respectively, and the sum of the weights of n models is 1; e(t) is the error of the combined prediction at time t, y(t) represents the actual observation value, and the calculation formula of 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 calculation formula of the forecast error sum of squares R of the combined forecast model is as follows: Find the weight w that minimizes the sum of squared prediction errors i , the weights of each model are converted into a combined prediction model with constraints to calculate the weights of each model. The specific calculation formula is:
4. The method for predicting demand for shared bicycles according to claim 1, characterized in that: It also includes inputting the acquired POI data into the space-time cube model, analyzing the space-time information of each station in the prediction area, obtaining variables associated with the shared bicycle usage data attributes in the space-time cube, and combining the demand forecast data output by the demand forecast model to obtain the spatial distribution of order forecast results for each station in the prediction area; among them, POI data refers to geographic information point data.
5. The method for predicting demand for shared bicycles according to claim 1, characterized in that: It also includes the selection of mean absolute error MAE, root mean square error RMSE, and determination coefficient R 2 Three indicators related to error calculation are used to evaluate the prediction effect of the model.
6. A demand forecasting system for shared bicycles at subway entrances, characterized in that: include: A data acquisition module is used to obtain order data of shared bicycles at transportation stations in the target area as a training set; A model building module is used to optimize the parameters of the long short-term memory neural network using a sparrow search algorithm, and to set weights for combining the optimized long short-term memory neural network and the random forest model using the least squares method; input the data in the training set into the combined model to train the model and obtain a demand forecasting model; The demand forecasting module is used to input the order data of shared bicycles in the area to be predicted into the demand forecasting model to obtain the demand forecast data of shared bicycles in the target area within a set time period.
7. 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 5.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is loaded into a processor, it can execute the steps of the method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Short-term explosion passenger flow prediction method based on long-term and short-term memory network and random forest
CN110929926A
Power transmission line icing thickness prediction method based on VMD-SSA-LSTM
CN117592592A
Household appliance demand prediction method and device, computer equipment and storage medium
CN117851781A
Short-term offshore wind power prediction method based on improved sparrow search algorithm
CN118199050A
Public building cold load prediction method, system, equipment and medium
CN119154269A