Neural network-based multi-dimensional portrait analysis method and system for user consumption behavior
By using neural network technology, key temporal features of user consumption behavior are extracted and scene bias is eliminated, enabling efficient multi-dimensional user profile analysis. This solves the problems of low computational efficiency and poor scene adaptability in existing technologies, and supports real-time analysis and precision marketing of large-scale user data.
Patent Information
- Application Number
- CN202510920694.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-04
- Publication Date
- 2025-12-05
- Estimated Expiration
- 2045-07-04
AI Technical Summary
Existing user consumption behavior profiling technologies are computationally inefficient when processing long-sequence data, struggle to identify key features, are unsuitable for large-scale user data analysis, and fail to accurately map behavioral patterns across different consumption scenarios, affecting the consistency and stability of the profiles and lacking real-time update capabilities.
A neural network-based approach is adopted to extract key temporal features through feature engineering and subsequence dynamic pruning algorithms. Bidirectional long short-term memory networks and multi-task adversarial feature extraction networks are used to eliminate scene bias. Feature fusion is performed by combining multilayer perceptrons, and user profiles are generated through discrete coding and hierarchical clustering algorithms.
It improves the accuracy and stability of user consumption behavior feature extraction, enhances the model's generalization ability across scenarios, supports real-time analysis and dynamic updates of large-scale user data, and meets the needs of modern e-commerce and precision marketing.
Smart Images

Figure CN120744523B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of data analysis, and in particular to a user consumption behavior multi-dimensional portrait analysis method and system based on a neural network. BACKGROUND
[0002] With the rapid development of e-commerce and mobile payment, user consumption behavior data is growing explosively, and analyzing user consumption behavior and constructing accurate user portraits have become key technologies for precise marketing and personalized recommendation of enterprises. Traditional user portrait technology is mainly based on static attribute features and simple statistical models, which cannot fully mine the complex time sequence patterns and scene-dependent characteristics contained in user consumption behavior.
[0003] In recent years, user portrait technology based on machine learning has gradually emerged, mainly through feature engineering and classification algorithms to construct a user label system. Common methods include rule-based label extraction, clustering-based user grouping, and classification-based user attribute prediction. With the development of deep learning technology, neural network models have shown significant advantages in user behavior sequence modeling, and technologies such as long short-term memory networks and attention mechanisms can effectively capture long-term dependencies in user behavior.
[0004] However, the existing user consumption behavior portrait technology still has deficiencies. The existing technology has low computational efficiency when processing long sequence consumption behavior data, and cannot effectively identify and extract key behavior features, resulting in high model complexity and limited generalization ability, which cannot adapt to large-scale user data analysis requirements. The existing method does not consider the difference in behavior under different consumption scenarios, and cannot effectively eliminate the influence of scene bias, resulting in inaccurate mapping of user behavior patterns in different consumption environments, affecting the consistency and stability of the portrait. The existing technology has bottlenecks in multi-dimensional feature fusion and real-time updating, lacks efficient feature indexing and similarity calculation mechanisms, and cannot support real-time calculation and updating of large-scale user portraits, making it difficult to meet the real-time decision-making requirements in dynamic business scenarios. SUMMARY
[0005] The embodiments of the present application provide a user consumption behavior multi-dimensional portrait analysis method and system based on a neural network, which can solve the problems in the prior art.
[0006] In a first aspect, the embodiments of the present application provide a user consumption behavior multi-dimensional portrait analysis method based on a neural network, comprising:
[0007] Obtain user historical consumption behavior data, construct an initial feature vector through feature engineering, and obtain a basic feature vector;
[0008] Based on the basic feature vector, a sub-sequence dynamic pruning algorithm is used for feature decomposition, the sequence similarity is calculated based on the entropy value weighted local sensitive mapping, the minimum feature unit is identified through the iterative compression reconstruction process, and the key timing feature is determined;
[0009] Based on the key timing feature, a pre-trained bidirectional long short-term memory neural network is used to extract the timing dependence relationship to obtain the consumption behavior sequence feature;
[0010] According to the consumption behavior sequence feature, a multi-task adversarial feature extraction network is constructed, the scene bias is eliminated through joint optimization and contrast loss function, and a scene invariant feature is obtained;
[0011] Based on the key timing feature, the consumption behavior sequence feature and the scene invariant feature, a multi-layer perceptron is used for nonlinear feature fusion to obtain a multi-dimensional combined feature;
[0012] According to the multi-dimensional combined feature, a feature index tree is constructed by using discrete coding, combined with bitmap filtering and asynchronous update mechanism, and the similarity relationship between users is obtained;
[0013] According to the multi-dimensional combined feature and the similarity relationship, a hierarchical clustering algorithm is used for user grouping to obtain the consumption behavior portrait result of the user.
[0014] In an optional embodiment, based on the basic feature vector, a sub-sequence dynamic pruning algorithm is used for feature decomposition, the sequence similarity is calculated based on the entropy value weighted local sensitive mapping, the minimum feature unit is identified through the iterative compression reconstruction process, and the key timing feature is determined, including:
[0015] The basic feature vector is segmented according to a preset window size to obtain a plurality of feature sub-sequences;
[0016] The difference between the sequence overall entropy value and the conditional entropy of the feature sub-sequence is calculated to obtain the information gain of the feature sub-sequence;
[0017] Based on the information gain of the feature sub-sequence, the historical pruning results are updated by an exponential moving average method to obtain a dynamic threshold for feature retention;
[0018] The information gain of the feature sub-sequence is compared with the dynamic threshold, and the feature sub-sequences that do not meet the threshold requirement are removed according to the comparison result to obtain a retained sequence; the feature entropy value of the retained sequence is calculated, and the feature weight is obtained through normalization processing;
[0019] Based on the feature weight, the retained sequence is locally sensitive mapped by constructing a random projection vector group, and the weighted Hamming distance in the mapping space is calculated to obtain a sequence similarity matrix;
[0020] According to the sequence similarity matrix, the reserved sequence is compressed and coded by a self-encoder to obtain compressed features; the compressed features are reconstructed to calculate the error value of the reconstructed sequence and the reserved sequence, and a reconstruction deviation is obtained;
[0021] Based on the comparison result of the reconstruction deviation and the preset deviation threshold, the target compression coefficient is determined by iterative optimization of adjusting the compression coefficient, and the minimum feature unit is extracted from the compressed features according to the target compression coefficient to obtain the key time sequence feature.
[0022] In an alternative embodiment, based on the feature weight, the reserved sequence is locally sensitive mapped by constructing a random projection vector group, and the weighted Hamming distance in the mapping space is calculated to obtain a sequence similarity matrix, including:
[0023] A weight matrix is constructed according to the feature weight of each feature in the reserved sequence, and the diagonal elements of the weight matrix are normalized feature weights;
[0024] A random projection vector group is constructed, each random projection vector in the random projection vector group has the same dimension as the feature dimension of the reserved sequence, and the elements follow a standard normal distribution;
[0025] The reserved sequence is represented as a sequence matrix, and the sequence matrix is weighted and transformed by the weight matrix to obtain a weighted sequence matrix;
[0026] The weighted sequence matrix is multiplied by each random projection vector in the random projection vector group, respectively, and a sign function transformation is performed to obtain a binary hash code;
[0027] According to the projection weight coefficient corresponding to the random projection vector group, the weighted Hamming distance between the binary hash codes corresponding to any two sequences in the reserved sequence is calculated;
[0028] The weighted Hamming distance is substituted into an exponential function for distance conversion, and the exponential function includes a smoothing factor for adjusting the similarity sensitivity to obtain the similarity value between sequences;
[0029] The similarity value between any two sequences in the reserved sequence is calculated to construct a sequence similarity matrix.
[0030] In an alternative embodiment, a multi-task adversarial feature extraction network is constructed according to the consumption behavior sequence feature, and scene bias is eliminated by joint optimization and contrastive loss function to obtain a scene invariant feature, including:
[0031] A double-branch feature extraction network is constructed to perform multi-layer nonlinear transformation on the consumption behavior sequence feature to obtain a first feature representation, and to perform attention encoding on the scene information to obtain a second feature representation.
[0032] The first feature representation and the second feature representation are input into a feature fusion layer to obtain a fused feature representation, and the fused feature representation is input into a scene discriminator to perform scene classification;
[0033] Based on the classification results of the scene discriminator, the adversarial loss value is calculated. From the consumption behavior sequence features, a pair of behavior sequences of the same user is selected, and the cosine similarity value between the fusion feature representations corresponding to the pair of behavior sequences is calculated.
[0034] The contrast loss value is calculated based on the cosine similarity value, and the adversarial loss value and the contrast loss value are weighted and combined to obtain the total loss value.
[0035] Backpropagation is performed based on the total loss value to update the parameters of the dual-branch feature extraction network, resulting in a feature extraction model. Scene-invariant features are then extracted using this feature extraction model.
[0036] In one optional embodiment, based on multi-dimensional combined features, a feature index tree is constructed using discrete encoding. Combined with bitmap filtering and asynchronous update mechanisms, the similarity relationships between users are obtained, including:
[0037] The multi-dimensional combined features are divided into discrete intervals according to quantiles, and the discrete intervals are mapped to discrete coded values, thus converting the multi-dimensional combined features into discrete coded features.
[0038] A feature index tree is constructed based on the discrete coding features. Each node layer of the feature index tree corresponds to a feature dimension, and each node stores the discrete coding value of the corresponding dimension. A bitmap storage structure is set in each node of the feature index tree.
[0039] The discrete coding features of the target user are obtained, the feature path of the target user is located in the feature index tree, and a set of candidate users is obtained by filtering through the bitmap storage structure.
[0040] The first similarity component is obtained by performing Euclidean distance calculation on the feature vectors of each user in the candidate user set, and the second similarity component is obtained by performing standardized mutual information calculation. The first similarity component and the second similarity component are weighted and combined to obtain the comprehensive similarity.
[0041] Changes in user characteristics are written to a cache queue. The number of changes in the cache queue is periodically checked. When the number of changes reaches a preset threshold, the feature index tree is updated asynchronously.
[0042] Recalculate the overall similarity of each user in the candidate user set corresponding to the changed user to obtain the similarity relationship between users.
[0043] In an alternative embodiment, according to the multi-dimensional combined features and the similarity relationship, a hierarchical clustering algorithm is used to group users, and the user consumption behavior portrait result includes:
[0044] A user similarity matrix is constructed according to the multi-dimensional combined features and the similarity relationship of the users;
[0045] Each user in the user similarity matrix is taken as a user node, and a hierarchical clustering algorithm is used to cluster and calculate the user similarity matrix, and each user node is initialized as an independent clustering unit;
[0046] The distance between each clustering unit is calculated based on the user similarity matrix, and the distance corresponds to the similarity degree of the users in different clustering units; the two clustering units with the smallest distance are selected for merging to generate a new clustering unit;
[0047] The distance between the merged clustering unit and other clustering units is recalculated based on the average linkage criterion, and the average linkage criterion is the average distance between all user pairs in the clustering units;
[0048] The process is repeated until a preset threshold of the number of clustering units is reached, and a user grouping result is obtained;
[0049] The importance score of each feature in each user group is calculated, and the importance score is the product of the feature information gain and the feature contrast;
[0050] The importance scores are sorted in descending order, and according to a preset number of preferred features, the corresponding features are selected as a feature set for user grouping, and a user consumption behavior portrait result is generated based on the feature set.
[0051] In an alternative embodiment, the hierarchical clustering algorithm used to cluster and calculate the user similarity matrix includes:
[0052] Based on the user similarity matrix, a preset threshold of the most similar number is used to select a corresponding number of most similar user nodes for a user node to establish a connection relationship, and a neighborhood relationship graph is constructed;
[0053] The similarity distance between each user node and the adjacent nodes in the neighborhood relationship graph is calculated to obtain a local density value, and the distance from each user node to all nodes with a local density value greater than itself is calculated, and the minimum value is selected as the relative distance value of the user node;
[0054] The local density value and the relative distance value of each user node are multiplied to obtain a core metric value sequence, a difference sequence is obtained by difference operation on the core metric value sequence, a core set threshold is calculated through the mutation point of the difference sequence, and the core set is filtered out;
[0055] Calculate the connection path between the non-core centralized user nodes and each core centralized user node, select the maximum value of the local density value of all user nodes on the connection path, and divide the corresponding non-core centralized user node to the cluster unit where the corresponding core centralized user node is located;
[0056] The product ratio of the number of edges between adjacent cluster units and the scale is calculated as the connectivity, and a cluster unit hierarchical tree is constructed;
[0057] The product of the density reachability and the average connectivity of the boundary nodes of the cluster unit is calculated as the stability value, the boundary nodes lower than the preset stability threshold are re-divided into the cluster unit with the highest stability, and finally the optimized user grouping result is output.
[0058] In a second aspect of the embodiment of the application, a user consumption behavior multi-dimensional portrait analysis system based on a neural network is provided, comprising:
[0059] The first unit is configured to obtain user historical consumption behavior data, construct an initial feature vector through feature engineering, and obtain a basic feature vector;
[0060] The second unit is configured to perform feature decomposition on the basic feature vector based on a sub-sequence dynamic pruning algorithm, calculate sequence similarity based on entropy value weighted local sensitive mapping, identify the minimum feature unit through an iterative compression reconstruction process, and determine key time sequence features;
[0061] The third unit is configured to extract time sequence dependency based on the key time sequence features by using a pre-trained bidirectional long short-term memory neural network, and obtain consumption behavior sequence features;
[0062] The fourth unit is configured to construct a multi-task adversarial feature extraction network based on the consumption behavior sequence features, eliminate scene bias through joint optimization and contrastive loss function, and obtain scene invariant features;
[0063] The fifth unit is configured to perform nonlinear feature fusion through a multilayer perceptron based on the key time sequence features, the consumption behavior sequence features and the scene invariant features, and obtain multi-dimensional combined features;
[0064] The sixth unit is configured to construct a feature index tree by using discrete coding based on the multi-dimensional combined features, combine bitmap filtering and asynchronous update mechanism, and obtain the similarity relationship between users;
[0065] The seventh unit is configured to perform user grouping by using a hierarchical clustering algorithm based on the multi-dimensional combined features and the similarity relationship, and obtain the consumption behavior portrait result of the user.
[0066] In a third aspect of the embodiment of the application, an electronic device is provided, comprising:
[0067] A processor;
[0068] A memory for storing processor-executable instructions;
[0069] The processor is configured to invoke the instructions stored in the memory to execute the aforementioned method.
[0070] In a fourth aspect of the embodiments of the present application, a computer readable storage medium is provided, which stores computer program instructions, and the computer program instructions are executed by a processor to implement the aforementioned method.
[0071] In the embodiments of the present application, the user consumption behavior data is processed by feature engineering and sub-sequence dynamic pruning algorithm, and the sequence similarity is calculated by combining entropy weighted local sensitive mapping, which can accurately identify the minimum feature unit and key timing feature, effectively capture the time evolution law and key turning point in user consumption behavior, and improve the accuracy and representativeness of feature extraction. The pre-trained bidirectional long short-term memory neural network and the multi-task adversarial feature extraction network are combined, and the data bias in different consumption scenarios is effectively eliminated by joint optimization and contrastive loss function, so as to extract user consumption features with scene invariance, enhance the stability and generalization ability of the model in cross-scene application, and avoid the performance decline problem of traditional methods in complex environment. The multi-layer perceptron is used for nonlinear feature fusion, and the feature index tree and bitmap filtering mechanism constructed by discrete coding are combined to significantly improve the multi-dimensional analysis efficiency of user portrait, realize the accurate portrait of user consumption behavior, support real-time analysis and dynamic update of large-scale user data, meet the high requirements of modern electronic commerce and precision marketing on user portrait, and have high engineering application value. BRIEF DESCRIPTION OF DRAWINGS
[0072] Figure 1 FIG. 1 is a flowchart of a user consumption behavior multi-dimensional portrait analysis method based on a neural network according to an embodiment of the present application.
[0073] Figure 2 FIG. 5 is a diagram for comparing the performance of a user portrait method based on hierarchical clustering with a traditional clustering algorithm. DETAILED DESCRIPTION
[0074] In order to make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme of the embodiments of the present application will be described clearly and completely below with reference to the drawings of the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all the embodiments. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without creative labor are within the scope of protection of the present application.
[0075] The technical solutions of the present application will be described in detail below with specific examples. The following specific examples can be combined with each other, and the same or similar concepts or processes may not be described in detail in some examples.
[0076] Figure 1 The flowchart of the embodiment of the present application based on the neural network user consumption behavior multi-dimensional portrait analysis method is shown in Figure 1 The method comprises the following steps:
[0077] Obtain the user historical consumption behavior data, construct the initial feature vector through feature engineering, and obtain the basic feature vector;
[0078] Based on the basic feature vector, the feature is decomposed by using the sub-sequence dynamic pruning algorithm, the sequence similarity is calculated based on the entropy value weighted local sensitive mapping, the minimum feature unit is identified through the iterative compression reconstruction process, and the key time sequence feature is determined;
[0079] Based on the key time sequence feature, the time sequence dependent relationship is extracted by using the pre-trained bidirectional long short-term memory neural network, and the consumption behavior sequence feature is obtained;
[0080] According to the consumption behavior sequence feature, a multi-task adversarial feature extraction network is constructed, scene bias is eliminated through joint optimization and contrastive loss function, and scene invariant feature is obtained;
[0081] Based on the key time sequence feature, the consumption behavior sequence feature and the scene invariant feature, the multi-dimensional combined feature is obtained through the nonlinear feature fusion of the multilayer perception machine;
[0082] According to the multi-dimensional combined feature, the feature index tree is constructed by using discrete coding, combined with bitmap filtering and asynchronous updating mechanism, and the similarity relationship between users is obtained;
[0083] According to the multi-dimensional combined feature and the similarity relationship, the user group is obtained by using the hierarchical clustering algorithm, and the consumption behavior portrait result of the user is obtained.
[0084] In an optional implementation, based on the basic feature vector, the feature is decomposed by using the sub-sequence dynamic pruning algorithm, the sequence similarity is calculated based on the entropy value weighted local sensitive mapping, the minimum feature unit is identified through the iterative compression reconstruction process, and the key time sequence feature is determined, which comprises:
[0085] The basic feature vector is segmented according to the preset window size, and a plurality of feature sub-sequences are obtained;
[0086] The difference between the sequence overall entropy value and the conditional entropy of the feature sub-sequence is calculated, and the information gain of the feature sub-sequence is obtained;
[0087] Based on the information gain of the feature subsequence, the pruning results of the history are updated by an exponential moving average method to obtain a dynamic threshold of feature retention;
[0088] The information gain of the feature subsequence is compared with the dynamic threshold, and the feature subsequence that does not meet the threshold requirement is removed according to the comparison result to obtain a retained sequence. The feature entropy value of the retained sequence is calculated, and the feature weight is obtained through normalization processing;
[0089] Based on the feature weight, the retained sequence is locally sensitive mapped by constructing a random projection vector group, and the weighted Hamming distance in the mapping space is calculated to obtain a sequence similarity matrix;
[0090] According to the sequence similarity matrix, the retained sequence is compressed and encoded by a self-encoder to obtain compressed features. The compressed features are reconstructed, the error value of the reconstructed sequence and the retained sequence is calculated, and the reconstruction deviation is obtained.
[0091] Based on the comparison result of the reconstruction deviation and the preset deviation threshold, the compression coefficient is iteratively optimized by adjusting the compression coefficient to determine the target compression coefficient, and the minimum feature unit is extracted from the compressed features according to the target compression coefficient to obtain key time sequence features.
[0092] In a specific embodiment, after obtaining the basic feature vector of user consumption behavior, the basic feature vector is segmented according to a preset window size to obtain multiple feature subsequences. The preset window size can be adjusted according to the actual application scenario. For example, in user consumption behavior analysis, 30 days can be set as a window, and the user's three months of consumption data can be divided into 3 feature subsequences. The basic feature vector contains multi-dimensional features such as consumption amount, consumption frequency, and consumption category of the user at different time points.
[0093] The difference between the sequence overall entropy value and the conditional entropy of each feature subsequence is calculated to obtain the information gain of the feature subsequence. The sequence overall entropy value reflects the uncertainty of the feature subsequence, and the conditional entropy reflects the uncertainty of other features under the condition of known part of the features. By calculating the difference between the two, the amount of effective information contained in the feature subsequence can be evaluated. For example, for the feature subsequence of user consumption amount, if its information gain is 0.75, it indicates that the sequence contains a high amount of effective information.
[0094] Based on the information gain of the feature subsequence, the pruning results of the history are updated by an exponential moving average method to obtain a dynamic threshold for feature retention. The exponential moving average gives recent data a higher weight and far-term data a lower weight, enabling the threshold to adapt to changes in data distribution. The dynamic threshold calculation uses a decay factor of 0.9, and the initial threshold is set to 0.5, which is constantly updated with the newly calculated information gain. For example, if the information gain of the first feature subsequence is 0.75, the updated dynamic threshold is 0.5 x 0.9 + 0.75 x 0.1 = 0.525.
[0095] The information gain of the feature subsequence is compared with the dynamic threshold, and the feature subsequence that does not meet the threshold requirement is removed according to the comparison result to obtain the retained sequence. If the information gain of the feature subsequence is greater than or equal to the dynamic threshold, the subsequence is retained; otherwise, it is removed. The feature entropy value is calculated for the retained sequence, and the feature weight is obtained through normalization processing. The feature entropy value is calculated based on the distribution of each dimension feature in the retained sequence, and the normalization processing ensures that the sum of all feature weights is 1. For example, the retained sequence contains three dimensions of consumption amount, consumption frequency, and consumption category, and the calculated feature entropy values are 2.1, 1.8, and 1.5, respectively. The normalized feature weights are 0.39, 0.33, and 0.28, respectively.
[0096] Based on the feature weight, a set of random projection vectors is constructed to perform local sensitive mapping on the retained sequence, and the weighted Hamming distance in the mapping space is calculated to obtain the sequence similarity matrix. The dimension of the set of random projection vectors is twice the dimension of the retained sequence, and it is generated through a random Gaussian distribution. Local sensitive mapping maps high-dimensional features to low-dimensional space, preserving the relative distance relationship between data points. The weighted Hamming distance takes into account the weight difference of each dimension feature, improving the accuracy of distance calculation. For example, the Hamming distance between two feature vectors in the mapping space is 5, and the weighted Hamming distance considering the feature weight is 4.2, indicating that the similarity between them is high.
[0097] According to the sequence similarity matrix, the retained sequence is compressed and encoded by a self-encoder to obtain compressed features. The self-encoder consists of an encoder and a decoder, the encoder compresses the input data to a low-dimensional latent space, and the decoder attempts to reconstruct the original data from the latent space. The encoder and decoder are both three-layer neural network structures, with ReLU as the activation function, and the number of nodes in the middle layer is 2 / 3 and 1 / 3 of the input dimension, respectively. The initial compression coefficient is set to 0.5, i.e., the dimension of the compressed feature is half of the dimension of the retained sequence.
[0098] The compressed features are reconstructed, the error value between the reconstructed sequence and the retained sequence is calculated, and the reconstruction deviation is obtained. The reconstruction deviation is calculated using mean square error, reflecting the degree of information loss in the compression process. If the reconstruction deviation is 0.15, it means that the compressed features can retain 85% of the information of the original data.
[0099] Based on the comparison result of the reconstruction deviation and the preset deviation threshold, the target compression coefficient is determined by adjusting the compression coefficient for iterative optimization. The preset deviation threshold is set to 0.2. If the reconstruction deviation is less than the preset deviation threshold, the compression coefficient is reduced to further compress the feature. If the reconstruction deviation is greater than the preset deviation threshold, the compression coefficient is increased to reduce the compression degree. The adjustment step of the compression coefficient is initially set to 0.1 and gradually decreases as the number of iterations increases. For example, if the current compression coefficient is 0.5 and the reconstruction deviation is 0.15, which is less than the preset deviation threshold 0.2, the compression coefficient is updated to 0.5 - 0.1 = 0.4 to further compress the feature.
[0100] After multiple rounds of iterative optimization, when the reconstruction deviation approaches but does not exceed the preset deviation threshold, or reaches the maximum number of iterations (set to 10), the target compression coefficient is determined. According to the target compression coefficient, the minimum feature unit is extracted from the compressed feature to obtain the key timing feature. The minimum feature unit is determined by principal component analysis method, which retains the feature component with the largest contribution to reconstruction. For example, if the target compression coefficient is 0.3 and the original reserved sequence dimension is 10, the key timing feature dimension is 3, which contains the most representative features in the original data.
[0101] Exemplarily, the consumption data of a certain user for three months is analyzed, and the original feature includes 6 dimensions such as consumption amount, consumption frequency, consumption category, consumption time, payment method and promotion response. According to a 30-day window, it is divided into 3 feature subsequences, and the information gain is 0.82, 0.65 and 0.71 respectively. The dynamic threshold calculation result is 0.63, and the three subsequences are all reserved. The feature weight calculation result is consumption amount 0.25, consumption frequency 0.2, consumption category 0.22, consumption time 0.15, payment method 0.08 and promotion response 0.1. After compression by the autoencoder, the target compression coefficient is determined to be 0.33, and the key timing feature dimension obtained is 2, which contains the combined features of consumption amount and consumption category. This feature can better reflect the user's consumption preference and consumption ability, and provides effective support for user portrait analysis.
[0102] In an optional implementation, based on the feature weight, a local sensitive mapping of the reserved sequence is performed by constructing a random projection vector group, and a weighted Hamming distance in the mapping space is calculated to obtain a sequence similarity matrix, comprising:
[0103] A weight matrix is constructed according to the feature weight of each feature in the reserved sequence, and the diagonal elements of the weight matrix are normalized feature weights;
[0104] A random projection vector group is constructed, and each random projection vector in the random projection vector group has the same dimension as the feature dimension of the reserved sequence, and the elements thereof follow a standard normal distribution.
[0105] The reserved sequence is represented as a sequence matrix, and the sequence matrix is subjected to a weighted transformation by the weight matrix to obtain a weighted sequence matrix;
[0106] The weighted sequence matrix is subjected to a product operation with each random projection vector in the random projection vector group, and a sign function transformation is performed to obtain a binary hash code;
[0107] According to the projection weight coefficients corresponding to the random projection vector group, the weighted Hamming distance between the binary hash codes corresponding to any two sequences in the reserved sequence is calculated;
[0108] The weighted Hamming distance is substituted into an exponential function for distance conversion, and the exponential function includes a smoothing factor for adjusting the sensitivity of the similarity, to obtain a similarity value between sequences;
[0109] The similarity value between any two sequences in the reserved sequence is calculated to construct a sequence similarity matrix.
[0110] In a specific embodiment, a similarity matrix is constructed based on sequence feature weights, and the process is realized by local sensitive mapping and weighted Hamming distance calculation. According to the feature weight of each feature in the reserved sequence, a weight matrix W is constructed, which is a diagonal matrix, and the diagonal elements are the normalized feature weights. For example, for a user consumption behavior reserved sequence containing 10 features, the feature weights may be [0.25, 0.15, 0.1, 0.1, 0.08, 0.08, 0.07, 0.07, 0.05, 0.05], and after normalization, a diagonal matrix W is formed, where W[1, 1]=0.25 represents the consumption amount feature, W[2, 2]=0.15 represents the consumption frequency feature, and so on.
[0111] Next, a random projection vector group R is constructed, each random projection vector has the same dimension as the feature dimension of the reserved sequence, and the elements follow a standard normal distribution. For example, for a 10-dimensional consumption behavior feature space, 128 random projection vectors can be constructed, each vector containing 10 random numbers following a standard normal distribution. In specific implementation, a random number generator can be used to generate values conforming to a standard normal distribution to form a matrix R, where the dimension of R is 10x128, i.e., each column is a random projection vector.
[0112] The reserved sequence is denoted as a sequence matrix X. Assuming there are 100 user consumption behavior sequences, each sequence has 10 features, then X is a 100x10 matrix. The sequence matrix X is transformed by a weight matrix W to obtain a weighted sequence matrix X'=X·W. For each row in matrix X (representing a user's consumption behavior sequence), each feature value of the sequence is multiplied by the corresponding weight after multiplication with matrix W. For example, for the sequence X[1]=[3.2, 1.5, 4.7, 2.1, 3.5, 1.8, 2.2, 3.0, 2.5, 1.9], representing a user's consumption amount, consumption frequency, and other 10 feature values, after weighting, it becomes X'[1]=[0.8, 0.225, 0.47, 0.21, 0.28, 0.144, 0.154, 0.21, 0.125, 0.095].
[0113] The weighted sequence matrix X' is multiplied by each random projection vector in the random projection vector group R respectively, and a sign function transformation is performed to obtain a binary hash code. Specifically, the matrix H' is obtained by calculating X'·R, and then the sign function is applied to each element in H': if the element is greater than 0, it is mapped to 1; otherwise, it is mapped to 0 to obtain a binary hash code matrix H. For example, for the product of the user consumption sequence X'[1] and the first random vector R[1], if the result is 0.35, the corresponding hash code is 1; if the product with the second random vector R[2] is -0.12, the corresponding hash code is 0. In this way, each user consumption sequence is mapped to a 128-bit binary hash code, effectively reducing the data dimension.
[0114] According to the projection weight coefficients corresponding to the random projection vector group, the weighted Hamming distance between the binary hash codes corresponding to any two sequences in the reserved sequence is calculated. The projection weight coefficients can be set according to the importance of each random projection vector, for example, they can be set as equal weights, i.e. the weight of each bit is 1 / 128. For the binary hash codes H[i] and H[j] of the consumption sequences of users i and j, the weighted Hamming distance d(i,j) is calculated as follows: first, the exclusive OR result of H[i] and H[j] is calculated to obtain a new binary sequence, where the bits with value 1 indicate that the two hash codes are different at that bit; then the number of bits with value 1 in the binary sequence is calculated and multiplied by the corresponding projection weight coefficient to obtain the weighted Hamming distance d(i,j).
[0115] The weighted Hamming distance is substituted into an exponential function for distance conversion, and the exponential function includes a smoothing factor a for adjusting the sensitivity of the similarity. The similarity calculation formula is: s(i, j)=exp(-d(i, j) / a), where a is the smoothing factor, which can be adjusted according to actual application, and can generally be set to a value between 0.1 and 1. For example, if the consumption sequence weighted Hamming distance of user i and user j is 32 / 128=0.25, and the smoothing factor a is 0.5, then their consumption behavior similarity is exp(-0.25 / 0.5)=exp(-0.5)≈0.607, indicating that the consumption habits of the two users have some similarity.
[0116] The similarity values between any two sequences in the reserved sequence are calculated to construct a sequence similarity matrix S. For a data set containing 100 user consumption sequences, the similarity matrix S is a 100x100 matrix, where S[i, j] represents the consumption behavior similarity of user i and user j. Since the similarity is symmetric, i.e. S[i, j]=S[j, i], and the similarity of a sequence with itself is 1, i.e. S[i, i]=1, only the elements of the upper or lower triangular matrix need to be calculated in practice.
[0117] The traditional user consumption behavior similarity calculation method is mainly based on Euclidean distance or cosine similarity. These methods have high computational complexity when dealing with high-dimensional feature data, and do not consider the importance difference of different features. Although the existing local sensitive hashing technology can reduce the dimension and speed up the calculation, it usually uses equal weight to process all features, ignoring the difference in feature importance, resulting in insufficient accuracy of similarity calculation. For example, the traditional local sensitive hashing method gives the same weight to user consumption amount and promotion response features, but in fact, consumption amount often reflects user consumption ability and habits better than promotion response.
[0118] The method of the present embodiment introduces a feature entropy-based weight calculation mechanism, which adaptively assigns weights according to the information content of the features, so that features containing more information (such as consumption amount and consumption frequency) obtain higher weights; a weight matrix is integrated into the local sensitive hashing process, and the feature weights are preserved in the dimension reduction process through the multiplication operation of the weighted sequence matrix and the random projection vector; at the same time, a projection weight coefficient is introduced in the Hamming distance calculation, and an adjustable smoothing factor is used to adapt to the similarity sensitivity requirements of different application scenarios. The starting point of these improvements is to improve the accuracy and efficiency of user consumption behavior similarity calculation, and to more accurately capture the key feature differences in user consumption patterns.
[0119] Compared with the traditional equal-weight local sensitive hashing method, the method improves the clustering accuracy of user consumption behavior and the precision of similar user recommendation. In terms of computing efficiency, for 100,000 users and 20-dimensional feature consumption data, the traditional method needs about 3 hours to complete the similarity matrix construction, while the method only needs about 25 minutes, with a speed-up of about 7 times. At the same time, by reasonably setting the smoothing factor, the method can flexibly adjust the similarity distribution to better meet the needs of different business scenarios, such as precision marketing and personalized recommendation. In addition, the robustness of the method to sparse data and noisy data is also significantly improved, and it can better adapt to the complexity and variability of actual user consumption data.
[0120] In an optional implementation, a multi-task adversarial feature extraction network is constructed according to the consumption behavior sequence feature, scene bias is eliminated through joint optimization and contrastive loss function, and a scene invariant feature is obtained, including:
[0121] A double-branch feature extraction network is constructed, a multi-layer nonlinear transformation is performed on the consumption behavior sequence feature to obtain a first feature representation, and attention encoding is performed on the scene information to obtain a second feature representation;
[0122] The first feature representation and the second feature representation are input into a feature fusion layer to obtain a fused feature representation, and the fused feature representation is input into a scene discriminator to perform scene classification;
[0123] An adversarial loss value is calculated according to the classification result of the scene discriminator, a pair of behavior sequences of the same user is selected from the consumption behavior sequence feature, and a cosine similarity value between the fused feature representations corresponding to the pair of behavior sequences is calculated;
[0124] A contrastive loss value is calculated based on the cosine similarity value, the adversarial loss value and the contrastive loss value are weighted and combined to obtain a total loss value;
[0125] The parameters of the double-branch feature extraction network are updated according to the total loss value through back propagation to obtain a feature extraction model, and a scene invariant feature is extracted through the feature extraction model.
[0126] In one specific implementation, a double-branch feature extraction network is constructed, which includes a first branch for processing consumption behavior sequence features and a second branch for processing scenario information. In the first branch, the input consumption behavior sequence features, which can be the consumption records of a user at different time points, including purchase amount, purchase frequency, purchase category, etc. information, are processed through multi-layer nonlinear transformation to obtain the first feature representation. Specifically, a three-layer fully connected neural network is used, with the number of neurons in each layer being 256, 128, and 64 respectively, and the ReLU function is used as the activation function, and a batch normalization layer is added after each layer to speed up network convergence. For example, the consumption behavior sequence features of user A are [100 yuan of food category purchase, 200 yuan of clothing category purchase, 50 yuan of daily necessities purchase], and after processing by the first branch, a 64-dimensional first feature representation is obtained.
[0127] In the second branch, scenario information such as online mall, physical store, holiday promotion, etc. is input. Attention encoding is performed on the scenario information to obtain the second feature representation. Specifically, the scenario information is converted into a 32-dimensional embedding vector, and then the relevance between different scenarios is calculated through a self-attention mechanism. The implementation of the self-attention mechanism includes calculating the query vector, key vector and value vector, calculating the attention weight through the dot product of the query vector and the key vector, and then weighting and summing the value vector to obtain the attention output. Finally, a fully connected layer is used to convert the attention output into a 32-dimensional second feature representation. For example, for the scenario information of "online mall", after processing by the second branch, a 32-dimensional second feature representation is obtained.
[0128] The first feature representation and the second feature representation are input into the feature fusion layer to obtain the fusion feature representation. The feature fusion layer uses a gating mechanism to control the fusion ratio of the two features through trainable parameters. Specifically, a fully connected layer is used to generate a gating signal, which takes a value in the range of 0 to 1, to control the retention degree of the first feature representation. Then, the gated first feature representation and the second feature representation are spliced, and a fully connected layer is used to map them to a 64-dimensional space to obtain the fusion feature representation. In the above example, the 64-dimensional first feature representation of user A and the 32-dimensional second feature representation are fused to obtain a 64-dimensional fusion feature representation.
[0129] The fusion feature representation is input into the scenario discriminator to perform scenario classification. The scenario discriminator is composed of two fully connected networks, the first layer contains 32 neurons, uses the ReLU activation function, and the second layer has the same number of neurons as the number of scenario categories, uses the Softmax activation function to output the probability distribution of each scenario. For example, assuming there are three scenarios: online mall, physical store, and holiday promotion, the output of the scenario discriminator is a 3-dimensional vector representing the probability of the sample belonging to each scenario.
[0130] The adversarial loss value is calculated according to the classification result of the scene discriminator. The adversarial loss adopts a cross-entropy loss function to calculate the difference between the predicted scene probability distribution and the real scene label. In order to realize adversarial learning, the goal of the feature extraction network is to maximize the adversarial loss, while the goal of the scene discriminator is to minimize the adversarial loss. Through such adversarial training, the feature extraction network gradually learns to extract scene-independent features. For the above example, if the real scene is "online mall" and the predicted probability is [0.2, 0.7, 0.1], the cross-entropy loss value is large, indicating that the features still contain scene-related information.
[0131] Cosine similarity values between the fusion feature representations corresponding to the behavior sequence pairs of the same user are calculated from the consumption behavior sequence features. Specifically, two consumption behavior sequences of the same user in different scenes are randomly selected for each user, and the fusion feature representations are obtained through the feature extraction network, and the cosine similarity between the two fusion feature representations is calculated. For example, the consumption behavior sequence of user A in the online mall and the consumption behavior sequence in the physical store are represented by vectors v1 and v2 respectively after the feature extraction network, and the dot product of v1 and v2 is calculated, and the cosine similarity value is obtained by dividing the norm product.
[0132] The contrast metric loss value is calculated based on the cosine similarity value. The contrast metric loss aims to make the feature representations of the same user in different scenes similar, while the feature representations of different users are far apart. Specifically, for a pair of behavior sequences of the same user, the contrast metric loss is 1 minus the cosine similarity value; for a pair of behavior sequences of different users, the contrast metric loss is the maximum value between the cosine similarity value and the boundary value 0.3. In actual implementation, a similarity matrix can be constructed for each batch of data, and the diagonal elements of the matrix correspond to different scenes of the same user, and the non-diagonal elements correspond to different users.
[0133] The total loss value is obtained by weighted combination of the adversarial loss value and the contrast metric loss value. The weighting coefficients can be adjusted according to actual needs, for example, the adversarial loss weight is 0.7 and the contrast metric loss weight is 0.3. By adjusting these weights, the emphasis degree of the feature extraction network on scene invariance and user consistency can be controlled. The total loss value is calculated as the adversarial loss value multiplied by 0.7 plus the contrast metric loss value multiplied by 0.3.
[0134] The parameters of the double-branch feature extraction network are updated by back propagation according to the total loss value, and a feature extraction model is obtained. An Adam optimizer is used, the learning rate is set to 0.001, the batch size is 128, and the training rounds are 100. In each training round, the parameters of the feature extraction network and the scene discriminator are updated alternately. The feature extraction network learns to extract scene-invariant features by maximizing the adversarial loss and minimizing the contrastive metric loss. After training is completed, the double-branch feature extraction network can be used to extract scene-invariant features of the consumption behavior sequence. These features can be used for downstream tasks such as user preference prediction and consumption behavior analysis.
[0135] In an optional implementation, a feature index tree is constructed according to multi-dimensional combined features by using discrete coding, and a similarity relationship between users is obtained by combining a bitmap filtering and an asynchronous updating mechanism, including:
[0136] The multi-dimensional combined features are divided into discrete intervals according to quantile numbers, the discrete intervals are mapped to discrete coding values, and the multi-dimensional combined features are converted into discrete coding features;
[0137] A feature index tree is constructed based on the discrete coding features. Each node layer of the feature index tree corresponds to a feature dimension, each node stores a discrete coding value of the corresponding dimension, and a bitmap storage structure is set at each node of the feature index tree;
[0138] Discrete coding features of a target user are obtained, a feature path of the target user is located in the feature index tree, and a candidate user set is obtained by filtering through the bitmap storage structure;
[0139] Euclidean distance calculation is performed on feature vectors of each user in the candidate user set to obtain a first similarity component, and standardized mutual information calculation is performed to obtain a second similarity component. The first similarity component and the second similarity component are combined to obtain a comprehensive similarity;
[0140] Change information of user features is written into a cache queue, and the number of change information in the cache queue is periodically detected. When the number of change information reaches a preset number threshold, asynchronous updating of the feature index tree is performed;
[0141] The comprehensive similarity of each user in the candidate user set corresponding to the changed user is recalculated to obtain a similarity relationship between users.
[0142] In one specific implementation, the multi-dimensional features of the users are preprocessed. The user features include continuous features such as consumption frequency, browsing duration, click conversion rate, and categorical features such as gender, occupation, and interest preference. For continuous features, quantile method is used for discretization, for example, the consumption amount of a user is divided into five intervals of 0-20%, 20%-40%, 40%-60%, 60%-80%, and 80%-100%, which are mapped to discrete encoding values of 1, 2, 3, 4, and 5, respectively. For a user with a consumption amount of 500 yuan, if the value falls within the interval of 40%-60%, the discrete encoding value is 3. For categorical features, integer encoding is directly used, for example, "male" in the gender feature is encoded as 1 and "female" is encoded as 2. In this way, the multi-dimensional features of the users are converted into a discrete encoding feature vector, for example, the feature vector of user A can be represented as [3, 2, 4, 1, 5], corresponding to the discrete encoding values of the five different dimensions.
[0143] Based on the discrete encoding features, a feature index tree is constructed. The feature index tree is a multi-level tree structure, and each level corresponds to a feature dimension. The root node of the tree represents the set of all users, the first level node represents different discrete values of the first feature dimension, the second level node represents different discrete values of the second feature dimension, and so on. In actual implementation, each node of the feature index tree contains three key information: the discrete encoding value of the current dimension, the pointer set pointing to the child nodes, and the bitmap storage structure. The bitmap storage structure is a binary array with a length equal to the total number of users in the system, and each position corresponds to a user ID. A value of 1 indicates that the user has the feature combination represented by the current node path, and a value of 0 indicates that the user does not have it. For example, for the node corresponding to the feature dimension [consumption frequency = 3, gender = 2, activity level = 4], the 100th bit in the bitmap is 1, indicating that the user with ID 100 has this feature combination.
[0144] When it is necessary to find similar users for a target user, the discrete encoding feature vector of the target user is first obtained. Assuming that the feature vector of the target user B is [3, 2, 4, 2, 3], starting from the root node in the feature index tree, the values of each dimension in the feature vector are sequentially traversed downward. For example, the node with a value of 3 in the first level is first accessed, then the node with a value of 2 in the child node of the node is accessed, and then the node with a value of 4 is accessed, and so on. Finally, the leaf node that completely matches the feature of the target user or the closest intermediate node is found. Through the bitmap storage structure, the candidate user set with the same or similar feature combination can be quickly filtered out. If it is necessary to find users that completely match the target user in the first three dimensions, only the bitmap corresponding to the node of the path [3, 2, 4] needs to be obtained, and the user ID corresponding to the position with a value of 1 in the bitmap is the candidate set.
[0145] For each user in the candidate user set, the comprehensive similarity between the user and the target user is calculated. The comprehensive similarity is composed of two parts: the Euclidean distance similarity and the standardized mutual information similarity. The Euclidean distance similarity reflects the distance relationship between users in the continuous feature space, and is calculated by calculating the Euclidean distance between the original feature vectors of the two users, and then converting the distance value into a similarity component through a certain conversion function (such as an exponential decay function). For example, the Euclidean distance between the original feature vectors of user B and user C is 2.5, and the similarity component obtained by the conversion function is 0.7. The standardized mutual information similarity reflects the correlation between users in the category feature, which is obtained by calculating the mutual information of the category feature distribution of the two users and standardizing the calculation result. For example, the standardized mutual information calculation result of user B and user C in the category feature is 0.6. The final comprehensive similarity is obtained by weighted combination of the two similarity components, and the weight can be adjusted according to business requirements, such as setting the Euclidean distance similarity weight to 0.4 and the standardized mutual information similarity weight to 0.6, then the comprehensive similarity is 0.4 x 0.7 + 0.6 x 0.6 = 0.64.
[0146] In order to cope with the dynamic changes of user features, the asynchronous update mechanism is adopted. When the user feature changes, the change information is written into the cache queue, including the user ID and the changed feature vector. The system periodically detects the number of change information in the cache queue, and when the number reaches a preset threshold (such as 1000), the update operation of the feature index tree is triggered. The update process includes: removing the mark of the changed user in the original feature path node bitmap (setting the corresponding position to 0), and adding the mark in the new feature path node bitmap (setting the corresponding position to 1). At the same time, the comprehensive similarity between the changed user and each user in its candidate user set is recalculated. For example, if the feature of user D changes from [2, 3, 1, 4, 2] to [2, 3, 3, 4, 2], the system will remove user D from the bitmap corresponding to the feature path [2, 3, 1] and add it to the bitmap corresponding to the feature path [2, 3, 3], and then recalculate the comprehensive similarity between user D and each user in the candidate user set.
[0147] In this embodiment, by constructing the feature index tree and using the bitmap storage structure, the feature path of the target user is quickly located, and the screening efficiency of the candidate user is significantly improved; the dual similarity components of Euclidean distance and standardized mutual information are adopted and weighted combined, which improves the accuracy and robustness of similarity calculation; the feature index tree is asynchronously updated through the cache queue, which reduces the computational overhead caused by frequent changes and ensures the real-time and stability of the system; the multi-dimensional combined feature is discretely encoded, which effectively handles the discrete representation of continuous features and is beneficial to subsequent index and matching operations.
[0148] In an alternative embodiment, according to the multi-dimensional combined features and the similarity relationship, a hierarchical clustering algorithm is used to group users, and the user consumption behavior portrait result includes:
[0149] A user similarity matrix is constructed according to the multi-dimensional combined features and the similarity relationship of the user;
[0150] Each user in the user similarity matrix is taken as a user node, and a hierarchical clustering algorithm is used to cluster the user similarity matrix, and each user node is initialized as an independent clustering unit;
[0151] The distance between each clustering unit is calculated based on the user similarity matrix, and the distance corresponds to the similarity degree of the users in different clustering units; the two clustering units with the smallest distance are selected for merging to generate a new clustering unit;
[0152] The distance between the merged clustering unit and other clustering units is recalculated based on the average linkage criterion, and the average linkage criterion is the average distance between all user pairs in the clustering units;
[0153] The process is repeated until a preset threshold of the number of clustering units is reached, and a user grouping result is obtained;
[0154] The importance score of each feature in each user group is calculated, and the importance score is the product of the feature information gain and the feature contrast;
[0155] The importance scores are sorted in descending order, and according to a preset number of choices, the corresponding features are selected as a feature set of the user group, and a user consumption behavior portrait result is generated based on the feature set.
[0156] In a specific embodiment, the multi-dimensional combined features of the user are obtained, which include but are not limited to the basic attribute information of the user (such as age, gender, occupation, etc.), behavior data (such as click, browse, purchase record, etc.), preference data (such as category preference, price sensitivity, etc.). For example, for user A, the features may include: 25 years old, female, office worker, browse electronic product page 30 times per month, purchase frequency 2 times per month, medium price sensitivity, preference for cosmetics and clothing categories, etc.
[0157] Based on the acquired multi-dimensional combination features of the users, the similarity between the users is calculated and a user similarity matrix is constructed. The similarity calculation can use cosine similarity, Euclidean distance, or Pearson correlation coefficient, etc. For example, assuming there are 5 users (U1-U5), the constructed user similarity matrix is as follows: the similarity between U1 and U2 is 0.85, the similarity between U1 and U3 is 0.62, the similarity between U1 and U4 is 0.31, and the similarity between U1 and U5 is 0.42; the similarity between U2 and U3 is 0.75, the similarity between U2 and U4 is 0.28, and the similarity between U2 and U5 is 0.35; the similarity between U3 and U4 is 0.53, the similarity between U3 and U5 is 0.40; and the similarity between U4 and U5 is 0.80. The higher the similarity value is, the higher the similarity between the users is.
[0158] Each user in the user similarity matrix is taken as a user node, and a hierarchical clustering algorithm is used for clustering calculation. In the initial stage, each user node is initialized as an independent clustering unit. For example, for the above 5 users, there are 5 clustering units in the initial stage: C1={U1}, C2={U2}, C3={U3}, C4={U4}, and C5={U5}.
[0159] The distance between the clustering units is calculated according to the user similarity matrix, and the distance value represents the similarity degree of the users in different clustering units. Since each clustering unit contains only one user in the initial stage, the distance between the clustering units is the distance between the users (the inverse of the similarity). In this example, the two clustering units with the smallest distance are C1 and C2 (the similarity is 0.85, and the distance is the smallest), so C1 and C2 are merged into a new clustering unit C12={U1, U2}.
[0160] After merging, the distance between the merged clustering unit and other clustering units needs to be recalculated based on the average linkage criterion. The average linkage criterion refers to calculating the average distance between all pairs of users in two clustering units. For example, when calculating the distance between C12 and C3, the distance between (U1 and U3+U2 and U3) / 2, i.e. (1 / 0.62+1 / 0.75) / 2=1.47. Similarly, the distance between C12 and C4 is (1 / 0.31+1 / 0.28) / 2=3.42, and the distance between C12 and C5 is (1 / 0.42+1 / 0.35) / 2=2.56.
[0161] The clustering process continues, and the two cluster units with the smallest distance are selected for merging. In the current state, C3 and C12 have the smallest distance, so C3 and C12 are merged to form a new cluster unit C123 = {U1, U2, U3}. The distances between the new cluster unit and the remaining cluster units are then calculated again. For example, the distance between C123 and C4 is (the distance between U1 and U4 + the distance between U2 and U4 + the distance between U3 and U4) / 3, i.e., (1 / 0.31 + 1 / 0.28 + 1 / 0.53) / 3 = 2.79. Similarly, the distance between C123 and C5 is calculated.
[0162] The above process continues to be repeated until a preset threshold of the number of cluster units is reached. Assuming that the threshold of the number of cluster units is set to 2, the final clustering result can be C123 = {U1, U2, U3} and C45 = {U4, U5}, i.e., the 5 users are divided into two groups.
[0163] For each user group, the importance scores of the features are calculated, which are the products of the feature information gain and the feature contrast. The feature information gain reflects the contribution of the feature to the grouping, and the feature contrast reflects the difference of the feature between different groups. For example, for the C123 group, the information gain of the age feature can be 0.35, and the contrast can be 0.8, so the importance score is 0.28; the information gain of the purchase frequency feature is 0.45, and the contrast is 0.9, so the importance score is 0.405. Similarly, the importance scores of the features in the C45 group are calculated.
[0164] Table 1 is a table of feature importance scores for user grouping:
[0165]
[0166] The importance scores are sorted in descending order, and the corresponding features are selected as the feature set of the user grouping according to a preset number of selected features. Assuming that the number of selected features is 3, for the C123 group, the three features with the highest importance scores can be purchase frequency (0.405), price sensitivity (0.375), and category preference (0.336); for the C45 group, the three features with the highest importance scores can be browsing duration (0.42), purchase frequency (0.385), and age (0.35).
[0167] Based on the selected feature set, the consumer behavior portrait results of the users are generated. For example, the user portrait of the C123 group can be described as "a user group with high purchase frequency, medium price sensitivity, and preference for cosmetics and clothing"; the user portrait of the C45 group can be described as "a user group with long browsing duration, low purchase frequency, and older age". These user portrait results can be used in business scenarios such as personalized recommendation, precision marketing, and product optimization.
[0168] Through the above method, precise grouping based on multi-dimensional characteristics of users is realized, and a user consumption behavior portrait with business value is generated, thereby providing data support for fine operation of an e-commerce platform.
[0169] In an optional implementation, the clustering calculation on the user similarity matrix by using a hierarchical clustering algorithm comprises:
[0170] Based on the user similarity matrix, a connection relationship is established for a user node and a corresponding number of most similar user nodes according to a preset most similar number threshold, and a neighbor relationship graph is constructed;
[0171] The similarity distance between each user node and a neighboring node in the neighbor relationship graph is calculated to obtain a local density value, and the distance from each user node to all nodes with a local density value greater than itself is calculated, and the minimum value is selected as the relative distance value of the user node;
[0172] The local density value and the relative distance value of each user node are multiplied to obtain a core metric value sequence, a difference sequence is obtained by difference operation on the core metric value sequence, a core set threshold is calculated through a mutation point of the difference sequence, and a core set is obtained by screening;
[0173] The connection path between the user nodes in the non-core set and the user nodes in each core set is calculated, the maximum local density value of all user nodes on the connection path is selected, and the corresponding user node in the non-core set is divided into the clustering unit in which the corresponding user node in the core set is located;
[0174] The ratio of the number of edges between adjacent clustering units to the product of the scale is calculated as the connectivity, and a clustering unit hierarchical tree is constructed;
[0175] The product of the density reachability and the average connectivity of the boundary nodes of the clustering unit is calculated as a stability value, the boundary nodes lower than a preset stability threshold are re-divided into the clustering unit with the highest stability, and finally an optimized user grouping result is output.
[0176] In a specific embodiment, based on the user similarity matrix obtained in the foregoing steps, a preset most similar quantity threshold is used to select a corresponding number of most similar user nodes for each user node to establish a connection relationship, and a neighborhood relationship graph is constructed. The most similar quantity threshold can be flexibly adjusted according to the actual application scenario, for example, set to 20, indicating that the 20 user nodes with the highest similarity are selected for each user node to establish a connection. Taking user A as an example, the similarity matrix row vector is [0.85, 0.92, 0.76, 0.68, 0.95, 0.72...], and the first 20 maximum values corresponding to the user nodes are selected to establish a connection relationship with user A. The edge weight in the neighborhood relationship graph is the similarity value between the corresponding nodes, for example, the edge weight between user A and user E is 0.95, indicating that the two have highly similar consumption behaviors.
[0177] The similarity distance between each user node and the adjacent node in the neighborhood relationship graph is calculated to obtain a local density value, and the distance from each user node to all nodes with a local density value greater than itself is calculated, and the minimum value is selected as the relative distance value of the user node. The local density value is calculated by a distance conversion method. For user node i, the local density value is equal to the sum of the similarities of all nodes j connected thereto. The higher the similarity, the smaller the distance, and the greater the contribution of the local density value. For example, the sum of the similarities of user A and the adjacent 20 nodes is 17.5, and the local density value of user A is 17.5. When calculating the relative distance value, for each user node i, find all node sets with a local density value greater than i, calculate the distance (the reciprocal of the similarity) from i to these nodes, and select the minimum value. For example, the local density value of user A is 17.5, and there are three nodes B, C, and D with local density values of 18.2, 19.1, and 17.8, respectively, all of which are greater than the local density value of user A. The distance from user A to these three nodes is 1.25, 1.42, and 1.33, respectively, and the relative distance value of user A is 1.25. If the local density value of the user node is the largest in the entire graph, the relative distance value is set to the maximum distance between all nodes in the graph.
[0178] The local density value of each user node is multiplied by the relative distance value to obtain a core metric value sequence, a difference sequence is obtained by difference operation on the core metric value sequence, the core set threshold is calculated through the mutation point of the difference sequence, and the core set is obtained by screening. The core metric value sequence is arranged in descending order, and the difference value of adjacent elements is calculated to obtain a difference sequence. The mutation point in the difference sequence is manifested as a position where the difference value significantly increases, which can be identified by setting a difference value change rate threshold (such as 50%). The core metric value corresponding to the mutation point is taken as the core set threshold, and the user nodes with a core metric value greater than or equal to the threshold form the core set. For example, the core metric value sequence arranged in descending order is [58.2, 56.9, 55.8, 54.2, 52.7, 34.8, 33.5...], the difference sequence is [1.3, 1.1, 1.6, 1.5, 17.9, 1.3...], a significant difference value 17.9 appears between the 5th and 6th elements, which is much larger than the previous difference values, so the mutation point is identified, the core set threshold is set to 52.7, and the core set includes 5 user nodes with a core metric value greater than or equal to 52.7.
[0179] The connection paths between the user nodes in the non-core set and the user nodes in each core set are calculated, the maximum value of the local density values of all user nodes on the connection path is selected, and the corresponding non-core set user node is divided into the clustering unit where the core set user node is located. The connection path is calculated by a breadth-first search algorithm, starting from the user node in the non-core set, and finding the shortest path to each core set user node. For each path, record the local density values of all nodes on the path, and find the maximum value. Compare the maximum density values of different paths, and divide the non-core set user node into the clustering unit where the core set user node connected by the path with the maximum density value is located. For example, user F belongs to the non-core set, three paths from user F to core set user nodes G, H and I are found by breadth-first search, and the maximum values of the local density values of the nodes on the paths are 15.8, 17.2 and 14.6 respectively, then user F is divided into the clustering unit where user H is located.
[0180] The ratio of the number of edges between adjacent clustering units to the product of the sizes of the two clustering units is calculated as the connectivity, and a clustering unit hierarchy tree is constructed. Adjacent clustering units refer to clustering units that have a direct connection relationship, the number of edges refers to the number of connection edges between two clustering units, and the product of the sizes refers to the product of the number of user nodes contained in the two clustering units. The connectivity is calculated as the number of edges divided by the product of the sizes, and the larger the value, the closer the two clustering units are connected. When constructing the hierarchy tree based on the connectivity, the clustering unit pair with the highest connectivity is merged first, and the hierarchy structure is gradually formed. For example, clustering units C1 and C2 have 30 connection edges between them, C1 contains 50 user nodes, and C2 contains 40 user nodes, so the connectivity between them is 30 / (5040)=0.015; clustering units C2 and C3 have 25 connection edges between them, and C3 contains 45 user nodes, so the connectivity between them is 25 / (4045)=0.0139. Since the connectivity between C1 and C2 is higher, C1 and C2 are preferentially merged.
[0181] The product of the density reachability and the average connectivity of the boundary nodes of the clustering unit is calculated as the stability value, and the boundary nodes below the preset stability threshold are re-divided into the clustering unit with the highest stability, and the optimized user grouping result is finally output. The boundary node refers to a user node connected to multiple clustering units, the density reachability refers to the ratio of the minimum local density value on the path from the core node to the boundary node to the local density value of the core node, and the average connectivity refers to the average connectivity of the boundary node with other nodes in the clustering unit. The higher the stability value, the more stable the boundary node belongs to the current clustering unit. For boundary nodes with a stability value below a preset threshold (such as 0.5), calculate the stability value with each clustering unit and re-divide it to the clustering unit with the highest stability value. For example, user J is a boundary node of clustering unit C4, with a stability value of 0.42, which is lower than the preset threshold of 0.5, and the stability value with adjacent clustering unit C5 is 0.68, so user J is re-divided from C4 to C5.
[0182] Traditional user grouping methods are mainly based on K-means, DBSCAN, and other general clustering algorithms. These methods have the following problems: it is difficult to determine the optimal value of the preset clustering number; sensitive to noise and outliers, easily affected; poor effect on non-convex clustering; and insufficient use of local structural characteristics of user behavior. Existing improved methods such as spectral clustering can handle complex structures, but have high computational complexity and are difficult to apply to large-scale user data; density peak clustering does not require a preset clustering number, but is sensitive to parameters, lacks adaptability in core point selection, and the boundary node attribution is unstable.
[0183] The method of the embodiment introduces a neighbor relationship graph construction method based on a similarity matrix, determines the connection relationship adaptively through a most similar quantity threshold, and avoids the calculation redundancy of a full connection graph; a core measurement mechanism combining a local density value and a relative distance value is adopted, a core set threshold is determined through automatic identification of a mutation point in a difference sequence, and adaptive selection of core points is realized; a non-core point distribution strategy based on a density path is proposed, the density distribution on a connection path is considered, and the continuous change of user behavior characteristics is more accurately captured; a clustering unit connectivity and stability evaluation mechanism is designed, the clustering result is optimized through redistribution of boundary nodes, and the group stability is improved. The adaptability of the traditional clustering method in user consumption behavior analysis is solved, and the accuracy and interpretability of the clustering result are improved.
[0184] Figure 2 For the performance comparison diagram of the user portrait method based on hierarchical clustering and the traditional clustering algorithm, the hierarchical clustering method proposed in the application is significantly better than other algorithms in three dimensions of clustering accuracy (0.87), stability index (0.89) and interpretability score (0.92). Especially in terms of interpretability, the application is 0.15 points higher than the suboptimal algorithm, which reflects its more accurate capture ability of user consumption behavior characteristics. In terms of computational efficiency, although it is 0.77 points lower than K-means (0.84), it is still better than density peak clustering and DBSCAN, and shows good performance balance.
[0185] Density peak clustering performs relatively stably in various indicators, while K-means has the highest computational efficiency, but performs weakly in stability and interpretability. DBSCAN is at a medium level in various indicators, but has the lowest interpretability (0.50).
[0186] The user consumption behavior multi-dimensional portrait analysis system based on the neural network in the embodiment of the application comprises:
[0187] The first unit is configured to obtain user historical consumption behavior data, construct an initial feature vector through feature engineering, and obtain a basic feature vector;
[0188] The second unit is configured to perform feature decomposition on the basic feature vector by using a subsequence dynamic pruning algorithm, calculate sequence similarity based on entropy weighted local sensitive mapping, identify a minimum feature unit through an iterative compression reconstruction process, and determine a key time sequence feature;
[0189] The third unit is configured to extract a time sequence dependency relationship by using a pre-trained bidirectional long short-term memory neural network based on the key time sequence feature, and obtain a consumption behavior sequence feature;
[0190] The fourth unit is configured to construct a multi-task adversarial feature extraction network according to the consumption behavior sequence features, eliminate scene bias through joint optimization and contrastive loss function, and obtain scene invariant features.
[0191] The fifth unit is configured to perform nonlinear feature fusion through a multi-layer perception machine based on the key timing features, the consumption behavior sequence features and the scene invariant features, and obtain multi-dimensional combined features.
[0192] The sixth unit is configured to construct a feature index tree by using discrete coding based on the multi-dimensional combined features, combine a bitmap filtering and an asynchronous updating mechanism, and obtain a similarity relationship between users.
[0193] The seventh unit is configured to perform user grouping by using a hierarchical clustering algorithm based on the multi-dimensional combined features and the similarity relationship, and obtain a consumption behavior portrait result of the user.
[0194] In a third aspect, an electronic device is provided, including:
[0195] a processor;
[0196] a memory for storing processor-executable instructions;
[0197] The processor is configured to invoke the instructions stored in the memory to execute the method described above.
[0198] In a fourth aspect, a computer-readable storage medium is provided, which stores computer program instructions, and the computer program instructions are executed by a processor to implement the method described above.
[0199] The present application can be a method, device, system and / or computer program product. The computer program product can include a computer readable storage medium having computer readable program instructions stored therein, which are used to perform various aspects of the present application.
[0200] Finally, it should be noted that: the above embodiments are only used to illustrate the technical solutions of the present application, and not to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that: it can still modify the technical solutions recorded in the foregoing embodiments, or make equivalent replacement to part or all of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the scope of the technical solutions of the embodiments of the present application.
Claims
1. A multi-dimensional user consumption behavior profiling analysis method based on neural networks, characterized in that, include: Obtain users' historical consumption behavior data, construct initial feature vectors through feature engineering, and obtain basic feature vectors; Based on the basic feature vector, a subsequence dynamic pruning algorithm is used for feature decomposition. Sequence similarity is calculated based on entropy-weighted local sensitivity mapping. The smallest feature unit is identified through an iterative compression and reconstruction process to determine key temporal features, including: The basic feature vector is segmented according to a preset window size to obtain multiple feature subsequences; The information gain of the feature subsequence is obtained by calculating the difference between the overall entropy and the conditional entropy of the feature subsequence. Based on the information gain of the feature subsequence, the historical pruning results are updated using an exponential moving average method to obtain the dynamic threshold for feature retention. The information gain of the feature subsequence is compared with the dynamic threshold. Based on the comparison result, feature subsequences that do not meet the threshold requirements are removed to obtain the retained sequence. The feature entropy value is calculated for the retained sequence, and the feature weight is obtained through normalization. Based on the feature weights, a local sensitive mapping is performed on the retained sequence by constructing a random projection vector group, and the weighted Hamming distance in the mapping space is calculated to obtain the sequence similarity matrix; Based on the sequence similarity matrix, the retained sequence is compressed and encoded using an autoencoder to obtain compressed features; the compressed features are reconstructed, and the error value between the reconstructed sequence and the retained sequence is calculated to obtain the reconstruction deviation; Based on the comparison results between the reconstruction deviation and the preset deviation threshold, the compression coefficient is adjusted for iterative optimization to determine the target compression coefficient, and the smallest feature unit is extracted from the compressed feature according to the target compression coefficient to obtain the key temporal features; Based on key temporal features, a pre-trained bidirectional long short-term memory neural network is used to extract temporal dependencies and obtain consumer behavior sequence features; Based on the characteristics of consumer behavior sequences, a multi-task adversarial feature extraction network is constructed. Scene bias is eliminated through joint optimization and a contrast loss function to obtain scene-invariant features, including: A dual-branch feature extraction network is constructed to perform multi-layer nonlinear transformations on the consumer behavior sequence features to obtain the first feature representation, and to perform attention encoding on the scene information to obtain the second feature representation. The first feature representation and the second feature representation are input into a feature fusion layer to obtain a fused feature representation, and the fused feature representation is input into a scene discriminator to perform scene classification; Based on the classification results of the scene discriminator, the adversarial loss value is calculated. From the consumption behavior sequence features, a pair of behavior sequences of the same user is selected, and the cosine similarity value between the fusion feature representations corresponding to the pair of behavior sequences is calculated. The contrast loss value is calculated based on the cosine similarity value, and the adversarial loss value and the contrast loss value are weighted and combined to obtain the total loss value. Backpropagation is performed based on the total loss value to update the parameters of the dual-branch feature extraction network, thereby obtaining a feature extraction model. Scene-invariant features are then extracted using the feature extraction model. Based on key temporal features, consumer behavior sequence features, and scenario-invariant features, nonlinear feature fusion is performed using a multilayer perceptron to obtain multidimensional combined features. Based on multi-dimensional combined features, a feature index tree is constructed using discrete encoding. Combined with bitmap filtering and asynchronous update mechanisms, the similarity relationship between users is obtained. Based on multi-dimensional combined features and similarity relationships, a hierarchical clustering algorithm is used to segment users, resulting in user consumption behavior profiles, including: Construct a user similarity matrix based on users' multi-dimensional combined characteristics and similarity relationships; Each user in the user similarity matrix is treated as a user node, and a hierarchical clustering algorithm is used to perform clustering calculations on the user similarity matrix, initializing each user node as an independent clustering unit; The distance between each cluster unit is calculated based on the user similarity matrix, and the distance corresponds to the degree of similarity between users in different cluster units; the two cluster units with the smallest distance are selected and merged to generate a new cluster unit; The distance between the merged cluster units and other cluster units is recalculated based on the average linking criterion, which is the average distance between all user pairs among the cluster units. Repeat the process until the preset threshold for the number of clustering units is reached to obtain the user grouping results; Calculate the importance score for each feature in each user group, where the importance score is the product of feature information gain and feature contrast. The importance scores are sorted in descending order, and the corresponding features are selected as the feature set for user segmentation according to a preset number of best features. Based on the feature set, a user consumption behavior profile is generated.
2. The method according to claim 1, characterized in that, Based on the aforementioned feature weights, a local sensitivity mapping is performed on the retained sequences by constructing a set of random projection vectors, and the weighted Hamming distance in the mapping space is calculated to obtain the sequence similarity matrix, which includes: A weight matrix is constructed based on the feature weights of each feature in the retained sequence, wherein the diagonal elements of the weight matrix are normalized feature weights; Construct a set of random projection vectors, wherein the dimension of each random projection vector in the set is the same as the feature dimension of the retained sequence, and the elements follow a standard normal distribution; The retained sequence is represented as a sequence matrix, and the sequence matrix is weighted by the weight matrix to obtain a weighted sequence matrix; The weighted sequence matrix is multiplied by each random projection vector in the random projection vector group, and a sign function transformation is performed to obtain a binary hash code. Based on the projection weight coefficients corresponding to the random projection vector group, calculate the weighted Hamming distance between the binary hash codes of any two sequences in the retained sequence; The weighted Hamming distance is substituted into an exponential function for distance transformation. The exponential function includes a smoothing factor for adjusting the similarity sensitivity to obtain the similarity value between sequences. Calculate the similarity value between any two sequences in the retained sequence, and construct a sequence similarity matrix.
3. The method according to claim 1, characterized in that, Based on multi-dimensional combined features, a feature index tree is constructed using discrete encoding. Combined with bitmap filtering and asynchronous update mechanisms, the similarity relationships between users are obtained as follows: The multi-dimensional combined features are divided into discrete intervals according to quantiles, and the discrete intervals are mapped to discrete coded values, thus converting the multi-dimensional combined features into discrete coded features. A feature index tree is constructed based on the discrete coding features. Each node layer of the feature index tree corresponds to a feature dimension, and each node stores the discrete coding value of the corresponding dimension. A bitmap storage structure is set in each node of the feature index tree. The discrete coding features of the target user are obtained, the feature path of the target user is located in the feature index tree, and a set of candidate users is obtained by filtering through the bitmap storage structure. The first similarity component is obtained by performing Euclidean distance calculation on the feature vectors of each user in the candidate user set, and the second similarity component is obtained by performing standardized mutual information calculation. The first similarity component and the second similarity component are weighted and combined to obtain the comprehensive similarity. Changes in user characteristics are written to a cache queue. The number of changes in the cache queue is periodically checked. When the number of changes reaches a preset threshold, the feature index tree is updated asynchronously. Recalculate the overall similarity of each user in the candidate user set corresponding to the changed user to obtain the similarity relationship between users.
4. The method according to claim 1, characterized in that, The hierarchical clustering algorithm is used to perform clustering calculations on the user similarity matrix, including: Based on the user similarity matrix, according to the preset threshold of the number of most similar users, a connection relationship is established by selecting a corresponding number of the most similar user nodes for a user node, and a nearest neighbor graph is constructed. The similarity distance between each user node and its neighboring nodes in the nearest neighbor graph is calculated to obtain the local density value. The distance from each user node to all nodes with a local density value greater than its own is calculated, and the minimum value is selected as the relative distance value of the user node. The core metric sequence is obtained by multiplying the local density value of each user node by its relative distance value. The core metric sequence is then differentially processed to obtain a difference sequence. The core set threshold is calculated by identifying the mutation points in the difference sequence, and the core set is then selected. Calculate the connection paths between non-core user nodes and each core user node, select the maximum local density value of all user nodes on the connection path, and assign the corresponding non-core user node to the cluster unit where the corresponding core user node is located. The ratio of the product of the number of edges and the size between adjacent cluster units is used as the connectivity to construct a hierarchical tree of cluster units; The product of the density reachability and average connectivity of the boundary nodes of the clustering unit is calculated as the stability value. Boundary nodes that are below the preset stability threshold are reassigned to the clustering unit with the highest stability. Finally, the optimized user grouping result is output.
5. A multi-dimensional user consumption behavior profiling and analysis system based on neural networks, used to implement the method of any one of claims 1-4, characterized in that, include: The first unit is used to acquire users' historical consumption behavior data, and to construct an initial feature vector through feature engineering to obtain the basic feature vector; The second unit is used to perform feature decomposition based on the basic feature vector using the subsequence dynamic pruning algorithm, calculate sequence similarity based on entropy-weighted local sensitivity mapping, identify the smallest feature unit through an iterative compression and reconstruction process, and determine key temporal features. The third unit is used to extract temporal dependencies based on key temporal features using a pre-trained bidirectional long short-term memory neural network, thereby obtaining consumer behavior sequence features; The fourth unit is used to construct a multi-task adversarial feature extraction network based on the characteristics of consumer behavior sequences. Scene bias is eliminated through joint optimization and contrast loss function to obtain scene-invariant features. The fifth unit is used to obtain multi-dimensional combined features by nonlinear feature fusion through a multilayer perceptron based on key temporal features, consumer behavior sequence features, and scenario-invariant features. The sixth unit is used to construct a feature index tree based on multi-dimensional combined features using discrete encoding, and combined with bitmap filtering and asynchronous update mechanisms to obtain the similarity relationship between users; The seventh unit is used to segment users based on multi-dimensional combined features and similarity relationships using a hierarchical clustering algorithm, thereby obtaining user consumption behavior profiles.
6. An electronic device, characterized in that, include: processor; Memory used to store processor-executable instructions; The processor is configured to invoke instructions stored in the memory to execute the method according to any one of claims 1 to 4.
7. A computer-readable storage medium having computer program instructions stored thereon, characterized in that, When the computer program instructions are executed by the processor, they implement the method described in any one of claims 1 to 4.
Citation Information
Patent Citations
Private domain live broadcast user behavior analysis and drainage recommendation method based on deep learning
CN119311952A
User behavior analysis method based on multi-source information
CN119415980A