A user behavior prediction method based on time series analysis

By dividing user behavior data by time and encoding feature, oversampling or undersampling the data, selecting timing models and optimizing model hyperparameters, the problem of not being able to fully utilize time series rules and data imbalance in the prior art is solved, and the accuracy of user behavior prediction and model performance are improved.

CN119760542APending Publication Date: 2025-04-04中科天玑数据科技股份有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411840901.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-13
Publication Date
2025-04-04

AI Technical Summary

Technical Problem

Existing user behavior prediction methods cannot fully consider the time series rules implicitly in the data, and face the challenges of data sparsity and imbalance, resulting in insufficient prediction accuracy.

Method used

By dividing user behavior data into fixed-length time windows by time, feature encoding and statistical feature calculations are performed; oversampling a few categories or undersampling a majority of categories, and new samples are generated using data augmentation technology; selecting a timing model, modeling the time dependence of user behavior, and optimizing model hyperparameters through a variety of evaluation indicators and grid searches.

Benefits of technology

It improves the accuracy of user behavior prediction, can more effectively capture the time dependence and potential patterns in user behavior, optimizes model performance, and is suitable for content recommendation, marketing strategies and user participation optimization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119760542A_ABST
    Figure CN119760542A_ABST
Patent Text Reader

Abstract

The present invention relates to the field of user behavior prediction, and discloses a user behavior prediction method based on time series analysis, including dividing user behavior data into time windows of fixed length by time, encoding features according to the periodic characteristics of the data, and calculating statistical features in each time window; oversampling a few categories or undersampling a majority of categories, and using data enhancement technology to generate new samples; selecting a time series model, modeling the time dependency of user behavior, and using different time series analysis methods to capture the changing laws and potential patterns of user behavior in the time dimension; using multiple evaluation indicators to evaluate the prediction ability of the model, and tuning the model hyperparameters through grid search to optimize the performance of the model. The present invention has the advantage of improving prediction accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of user behavior prediction, and in particular to a user behavior prediction method based on time series analysis. Background Art

[0002] With the popularization of the Internet and mobile devices, a large amount of behavioral data generated by users presents obvious time series characteristics, such as the frequency of users visiting websites, the interval between purchase behaviors, and the interaction on social media. These behavioral data not only contain valuable information about user preferences, but also reveal the temporal pattern of behavioral changes. Therefore, user behavior prediction based on time series analysis has become an important research direction.

[0003] Traditional user behavior prediction methods mainly rely on static data analysis or simple statistical models, which cannot fully consider the time series laws implicit in the data. With the development of machine learning and deep learning technologies, time series analysis technology has gradually been applied. Time series analysis can mine the time dependency, periodicity and trend characteristics in user behavior by processing data with time sequence, thereby achieving more accurate behavior prediction.

[0004] However, time series analysis still faces some challenges in user behavior prediction, such as data sparsity and imbalance. Therefore, it is necessary to design a user behavior prediction method based on time series analysis to improve prediction accuracy. Summary of the invention

[0005] In view of the deficiencies in the prior art, the present invention provides a user behavior prediction method based on time series analysis, which has the advantage of improving prediction accuracy and solves the problems in the above-mentioned background technology.

[0006] In order to achieve the above-mentioned purpose of improving prediction accuracy, the present invention provides the following technical solution: a user behavior prediction method based on time series analysis, comprising the following steps: S1: Divide the user behavior data into time windows of fixed length, perform feature encoding based on the periodic characteristics of the data, and calculate statistical features in each time window; Preferably, S1 further includes dividing the user behavior data into time windows of fixed length by time, capturing the changing patterns of user behavior in different time periods, extracting multiple statistical features based on the user's behavior records in each time window, and using periodic coding technology to enhance the model's temporal perception ability based on the periodic characteristics of the data in the time window.

[0007] S2: Oversample the minority category or undersample the majority category, and use data augmentation techniques to generate new samples; Preferably, S2 further includes oversampling the minority category or undersampling the majority category. The core of the oversampling method is to increase the number of samples in the minority category. The SMOTE algorithm generates new samples based on the neighbors of the minority category samples. The undersampling technology balances the data by reducing the number of samples in the majority category. The effect of oversampling or undersampling is evaluated by calculating the balance of the category distribution.

[0008] S3: Select a time series model to model the time dependency of user behavior and use different time series analysis methods to capture the changing rules and potential patterns of user behavior in the time dimension; Preferably, S3 further includes processing the timestamp of user behavior data, extracting time features, using different time series analysis methods, and deep learning methods such as long short-term memory networks or gated recurrent units, and further considering the influence of external factors or social networks through multivariate time series modeling. The model predicts the user's future behavior and provides data support for content recommendation, marketing strategy and user engagement optimization.

[0009] S4: Use multiple evaluation indicators to evaluate the predictive ability of the model, and perform model hyperparameter tuning through grid search to optimize the performance of the model.

[0010] Preferably, S4 further includes evaluating the predictive ability of the model, using a variety of evaluation indicators to comprehensively measure the performance of the model, and optimizing the hyperparameters of the model through grid search. The grid search finds the hyperparameter combination by traversing the preset hyperparameter range and combining the cross-validation method. In this way, the performance of the model on different data sets and different tasks is maximized.

[0011] Compared with the prior art, the present invention provides a user behavior prediction method based on time series analysis, which has the following beneficial effects: The present invention divides user behavior data into time windows of fixed length by time, performs feature encoding according to the periodic characteristics of the data, and calculates statistical features in each time window; oversamples a few categories or undersamples the majority categories, and uses data enhancement technology to generate new samples; selects a time series model to model the time dependency of user behavior, and uses different time series analysis methods to capture the changing laws and potential patterns of user behavior in the time dimension; uses multiple evaluation indicators to evaluate the prediction ability of the model, and performs model hyperparameter tuning through grid search to optimize the performance of the model. It has the advantage of improving prediction accuracy. BRIEF DESCRIPTION OF THE DRAWINGS

[0012] Figure 1 Schematic diagram of the method of the present invention. DETAILED DESCRIPTION

[0013] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention. Example

[0014] The present invention provides a technical solution: a user behavior prediction method based on time series analysis, comprising the following steps: S1: Divide the user behavior data into time windows of fixed length, perform feature encoding based on the periodic characteristics of the data, and calculate statistical features in each time window; Dividing user behavior data into time windows of fixed length is to capture the changing patterns of user behavior in different time periods. For example, the data can be divided by hours, days, weeks, or months, and the specific time window length is determined by the changing cycle of the behavior. If the prediction is daily activity, a 1-hour or 1-day window can be used; if it is monthly consumption behavior, a 1-month window may be used. In each time window, multiple statistical features will be extracted based on the user's behavior records to quantify the regularity of user behavior.

[0015] Within the time window, based on the periodic characteristics of the data, periodic encoding techniques can be used to enhance the model's temporal perception. Common periodic feature encoding methods include: Sine and cosine transforms: by mapping information such as date, time, day of the week, month, etc. into continuous sine and cosine values.

[0016] One-hot encoding: One-hot encoding is performed on some discrete periodic features so that the model can recognize periodic changes.

[0017] Statistical features: In each time window, multiple statistical features of user behavior are calculated to capture the user's activity status during that time. These features include: Basic statistics: such as mean, standard deviation, maximum value, and minimum value. These statistics can describe the central tendency and dispersion of behavior.

[0018] Time-shift features: For example, the average time between actions, which helps capture the frequency of user activities.

[0019] Skewness and Kurtosis: Skewness measures the skewness of the behavior distribution, while kurtosis describes the sharpness of the behavior distribution, which helps capture abnormal behavior.

[0020] Behavior change rate: Calculates the speed at which a user's behavior changes within a window, such as the growth rate of purchase frequency, changes in activity, etc. This is very important for predicting user behavior trends.

[0021] Lag features: Introducing behavioral data from previous time windows as features helps the model capture the historical dependencies of user behaviors. For example, the total purchase amount, browsing time, etc. from the previous hour, day, or week can be used as features of the current time window.

[0022] S2: Oversample the minority category or undersample the majority category, and use data augmentation techniques to generate new samples; Oversampling the minority class or undersampling the majority class is an important technical means to solve the problem of data imbalance. It can prevent the model from being overly biased towards the majority class during training, thereby improving prediction accuracy. The core of the oversampling method is to increase the number of samples in the minority class. The commonly used technology is SMOTE, which balances the category distribution by generating synthetic data points for minority class samples in the feature space. Specifically, the SMOTE algorithm generates new samples based on the neighbors of minority class samples.

[0023] Undersampling technology balances data by reducing the number of samples in the majority class. Common undersampling methods include randomly deleting majority class samples, or clustering the majority class using clustering methods and selecting representative samples as the final training set. Undersampling can effectively reduce training time, but may result in the loss of some useful majority class information, so it should be used with caution.

[0024] Use data enhancement techniques to further generate new samples. For example, in image data, new image data can be generated by rotation, translation, scaling, etc.; in text data, it can be enhanced by synonym replacement, random word deletion, etc. For time series data, common enhancement methods include time window perturbation, noise injection, and time series slice reorganization. Through these methods, more training samples can be provided to the model, thereby improving the generalization ability of the model.

[0025] The effect of oversampling or undersampling can be evaluated by calculating the balance of the class distribution. For example, the class balance can be measured by the ratio of the number of samples in the class, and the ideal balance is 1. The enhanced dataset can verify the quality of the generated samples through statistics to ensure that the synthesized samples have similar statistical properties to the original data. In addition, when using model training, the effect of the data balancing method can also be evaluated by monitoring the performance of the model on the validation set.

[0026] S3: Select a time series model to model the time dependency of user behavior and use different time series analysis methods to capture the changing rules and potential patterns of user behavior in the time dimension; The time series model is selected to model the time dependency of user behavior, aiming to reveal the changing rules and potential patterns of user behavior in the time dimension, so as to accurately predict future behavior. According to the characteristics of the data and the prediction goals, different time series analysis methods can effectively capture different levels of time dependency.

[0027] Traditional ARIMA and SARIMA are suitable for capturing linear trends and seasonal changes in user behavior. The ARIMA model models the temporal relationship of user behavior through autoregression and sliding average components. For seasonal patterns, SARIMA adds seasonal differences and seasonal autoregression terms on the basis of ARIMA to help the model identify periodic changes, such as daily or weekly fluctuations in user activity. Quantitatively, the performance of ARIMA can be evaluated by AIC or BIC, and lower AIC / BIC values ​​usually indicate better model fit.

[0028] For complex nonlinear patterns and long-term dependencies, deep learning time series models can better capture the long-term and short-term dependencies in the data. By introducing a gating mechanism, LSTM can effectively solve the gradient vanishing and explosion problems of traditional RNN when processing long time series, and is suitable for modeling long-term dependencies in user behavior, such as users' continued interest in specific products. GRU is a simplified version of LSTM, which is more computationally efficient while maintaining similar effects. Quantitatively, the performance of such models is usually evaluated by indicators such as mean square error, accuracy, recall, F1 score, etc., and cross-validation is often used to select the most appropriate hyperparameters in time series tasks.

[0029] The Transformer model's advantages in capturing long-term dependencies and parallel computing enable it to perform well in processing large-scale user behavior data. Through the self-attention mechanism, the Transformer model can capture the interrelationships between user behaviors on a global scale, which is particularly suitable for complex, multi-level user behavior prediction tasks. Quantitatively, attention scores can be used to measure the model's attention to different time points, thereby evaluating whether the model has correctly captured important time dependencies.

[0030] In practical applications, choosing an appropriate time series model and combining it with the characteristics of the data can significantly improve the prediction accuracy. For example, using LSTM to model the long-term trend of user interest changes, combined with ARIMA to capture short-term behavioral fluctuations, and finally further optimizing the prediction results through ensemble learning or model fusion. When evaluating the model, you can use mean square error or mean absolute error to quantify the prediction error, and combine R² to evaluate the model fitting effect.

[0031] S4: Use multiple evaluation indicators to evaluate the predictive ability of the model, and perform model hyperparameter tuning through grid search to optimize the performance of the model.

[0032] Using a variety of evaluation metrics to evaluate the predictive ability of the model is a key step to ensure that the model performs well in practical applications. Different evaluation metrics can measure the performance of the model from different perspectives, helping us to fully understand the strengths and weaknesses of the model, thereby providing a basis for further optimization. When evaluating, commonly used metrics include mean square error, root mean square error, mean absolute error, R², precision, recall, and F1 score.

[0033] MSE and RMSE can measure the error size of the model in continuous numerical prediction tasks. MSE is the average of the sum of squares of the differences between the predicted value and the actual value. The smaller it is, the better the model fits. RMSE is the square root of MSE, which is consistent with the dimension of the original data and is therefore more intuitive. MAE reflects the absolute difference between the model's predicted value and the true value, measuring the model's prediction error, but it is less sensitive to outliers. R² is used to evaluate the goodness of fit of the model and indicates the proportion of variance that the model can explain. The range of R² values ​​is 0 to 1, and the closer the value is to 1, the better the model fits. For classification tasks, precision, recall, and F1 scores are commonly used evaluation indicators, especially when dealing with unbalanced data, these indicators can provide a more realistic model performance. Precision reflects how many of the samples predicted by the model as positive are truly positive, and recall measures the proportion of all positive samples correctly predicted by the model. F1 score is the harmonic mean of precision and recall, which is suitable for unbalanced classification problems.

[0034] After the evaluation is completed, grid search can be used to tune model hyperparameters. By performing an exhaustive search in the specified hyperparameter space, grid search can find the optimal hyperparameter combination to optimize the performance of the model. For example, for LSTM models, you can tune hyperparameters such as learning rate, number of layers, number of neurons, batch size, etc.; for XGBoost models, you can adjust the depth of the tree, learning rate, minimum number of sample splits, etc. Grid search systematically traverses all possible combinations by specifying multiple possible values ​​of hyperparameters, and uses cross-validation to evaluate the effect of each set of hyperparameters to select the optimal combination.

[0035] Grid search usually uses the average performance of cross-validation to evaluate the effect of each set of hyperparameters. For example, using 5-fold cross-validation, the training data is divided into 5 subsets, 4 subsets are used for training each time, and the remaining subset is used for validation. Finally, the average of the 5 validation results is taken as the evaluation indicator of the hyperparameter combination. Through grid search and cross-validation, the robustness and predictive ability of the model can be improved, the risk of overfitting can be reduced, and better performance can be achieved in practical applications.

[0036] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device.

[0037] Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the appended claims and their equivalents.

Claims

1. A user behavior prediction method based on time series analysis, characterized in that: The following steps are involved: S1: Divide the user behavior data into time windows of fixed length, perform feature encoding based on the periodic characteristics of the data, and calculate statistical features in each time window; S2: Oversample the minority category or undersample the majority category, and use data augmentation techniques to generate new samples; S3: Select a time series model to model the time dependency of user behavior and use different time series analysis methods to capture the changing rules and potential patterns of user behavior in the time dimension; S4: Use multiple evaluation indicators to evaluate the predictive ability of the model, and perform model hyperparameter tuning through grid search to optimize the performance of the model.

2. The user behavior prediction method based on time series analysis according to claim 1 is characterized in that: The S1 further includes dividing the user behavior data into time windows of fixed length by time, capturing the changing patterns of user behavior in different time periods, extracting multiple statistical features based on the user's behavior records in each time window, and using periodic coding technology to enhance the model's temporal perception capability based on the periodic characteristics of the data in the time window.

3. The user behavior prediction method based on time series analysis according to claim 1 is characterized in that: The S2 further includes oversampling the minority class or undersampling the majority class. The core of the oversampling method is to increase the number of samples in the minority class. The SMOTE algorithm generates new samples based on the neighbors of the minority class samples. The undersampling technology balances the data by reducing the number of samples in the majority class. The effect of oversampling or undersampling is evaluated by calculating the balance of the class distribution.

4. The user behavior prediction method based on time series analysis according to claim 1 is characterized in that: The S3 further includes processing the timestamps of user behavior data, extracting time features, using different time series analysis methods, and deep learning methods such as long short-term memory networks or gated recurrent units, and further considering the influence of external factors or social networks through multivariate time series modeling. The model predicts the user's future behavior and provides data support for content recommendation, marketing strategy and user engagement optimization.

5. The user behavior prediction method based on time series analysis according to claim 1 is characterized in that: The S4 further includes evaluating the predictive ability of the model, using a variety of evaluation indicators to comprehensively measure the performance of the model, and optimizing the hyperparameters of the model through grid search. The grid search traverses the preset hyperparameter range and combines the cross-validation method to find the hyperparameter combination. In this way, the performance of the model on different data sets and different tasks is maximized.