User position prediction method and system based on double-branch network
Through the dual-branch network architecture and dynamic adapter design, the problem of neglecting the characteristics of inactive users in the prior art is solved, the prediction accuracy of inactive users is improved, and the accurate prediction of active users and effective attention to inactive users is achieved.
Patent Information
- Application Number
- CN202510737919.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-04
- Publication Date
- 2025-07-18
AI Technical Summary
Existing user location prediction technology performs well when dealing with active users, but is easily ignored for inactive user characteristics, resulting in prediction bias, and the attention cannot be adjusted dynamically during training, affecting the prediction performance of inactive users.
The dual-branch network architecture is adopted, the main branch network processes all users, the sampling branch network focuses on inactive users, and realizes feature migration through encoder sharing weights, and adjusts the attention of each branch during the training process in combination with the dynamic adapter to improve the prediction accuracy of inactive users.
On the basis of maintaining the prediction accuracy of active users, the prediction accuracy of inactive users is significantly improved, and the overall prediction performance is balanced by dynamic adapters, and effective attention to inactive users is achieved.
Smart Images

Figure CN120343504A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical fields of artificial intelligence and location-based services, and particularly to a user location prediction method and system based on a dual-branch network. Background Art
[0002] With the deep integration of mobile Internet technology and location-aware devices, location-based social networks (LBSNs) have penetrated into all fields of social life. The wide application of platforms such as Foursquare, WeChat, and Douyin integrated with location service functions has generated a vast amount of user movement trajectory data. These data not only record the geographical location changes of users but also imply deep information such as individual behavior patterns, interest preferences, and social relationships. In this context, user location prediction technology, as the core technology supporting applications such as personalized recommendation, urban traffic planning, and commercial site selection analysis, has received extensive attention in recent years.
[0003] Existing user location prediction technologies mainly rely on deep learning models, including a user location prediction method based on a dual-branch network using a recurrent neural network (RNN), a user location prediction method based on a dual-branch network using an attention mechanism, and a user location prediction method based on a dual-branch network combining a graph neural network (GNN) and an attention mechanism. Existing methods have the following defects in practical applications: (1) Data long-tail problem: The proportion of active user trajectory data is high, and existing methods tend to ignore the characteristics of inactive users, resulting in prediction bias; (2) Weak dynamic adaptability: Existing methods fix their attention on all users during the training process and cannot adjust the attention to inactive users. Therefore, there is an urgent need for a solution that can not only ensure the prediction accuracy of active users but also effectively improve the prediction performance of inactive users. Summary of the Invention
[0004] Based on the defects existing in the above-mentioned prior art, the present invention provides a user location prediction method and system based on a dual-branch network, which solves the problems that existing methods tend to ignore the characteristics of inactive users, resulting in prediction bias, and that existing methods fix their attention on all users during the training process and cannot gradually adjust the attention to inactive users.
[0005] The present invention adopts the following technical solutions: In a first aspect, the present invention provides a user location prediction method based on a dual-branch network, including the following steps: Extract the historical trajectory sequences of all users based on the historical location data of users on different social platforms, where all users include inactive users and active users; divide multiple trajectory points in the historical trajectory sequences of all users according to the check-in time interval to obtain multiple divided trajectory sequences; regard the users corresponding to the divided trajectory sequences with a quantity less than a set value as inactive users; Map the historical trajectory sequences of all users to obtain trajectory sequence embeddings; Construct a two-branch network model, including a main branch network and a sampling branch network. The main branch network includes a first encoder and a hierarchical decoder, and the sampling branch network includes a second encoder and a single-layer decoder; the first encoder and the second encoder share weights; Train the two-branch network model with multiple trajectory sequence embeddings to obtain a location prediction model. Among them, use the first encoder to perform feature learning on the trajectory sequence embeddings of all users, and use the hierarchical decoder to perform location semantic category prediction and location prediction on the trajectory sequence embeddings after feature learning to obtain the next check-in location prediction results of all users; oversample the trajectory sequence embeddings of inactive users and then input them into the second encoder for feature learning, and use the single-layer decoder to perform location prediction on the trajectory sequence embeddings after feature learning to obtain the next check-in location prediction results of inactive users; Map the current trajectory sequence of all users and input it into the location prediction model, and predict the next check-in location of all users through the main branch network.
[0006] Preferably, the process of using the first encoder to perform feature learning on the trajectory sequence embeddings of all users specifically includes the following steps: Calculate the output of multi-head self-attention: ; In the formula, is the output of multi-head self-attention, m is the total number of attention heads, head i represents the i th output of an attention head, , , are the feature transformation matrices corresponding to the i th attention head, is the finally output feature transformation matrix, D is the dimension, h is the trajectory sequence embedding of all users; Perform residual connection and layer normalization in the multi-head self-attention sublayer: ; In the formula, h sub1 is the trajectory sequence embedding updated by the multi-head self-attention sublayer; Calculate the output of the feed-forward neural network: ; In the formula, is the output of the feed-forward neural network, W 1 and W2 is the first parameter matrix and the second parameter matrix, b 1 and b 2 are the first bias vector and the second bias vector; Residual connection and layer normalization are performed in the feed-forward neural network sublayer: ; In the formula, hs ub2 is the trajectory sequence embedding updated by the feed-forward neural network sublayer; Taking as the input of the next coding layer and performing the same processing flow again. After all coding layers are processed, the trajectory sequence embedding after feature learning is obtained.
[0007] Preferably, the hierarchical decoder is used to perform position semantic category prediction and position prediction on the trajectory sequence embedding after feature learning, specifically expressed as: ; In the formula, and are the semantic category embedding and the position embedding obtained by the hierarchical decoder respectively, is the trajectory sequence embedding after feature learning, is the non-linear activation function.
[0008] Preferably, the single-layer decoder is used to perform position prediction on the trajectory sequence embedding after feature learning, specifically expressed as: ; In the formula, is the position embedding decoded by the single-layer decoder, W 3 is the third parameter matrix, b 3 is the third bias vector.
[0009] Preferably, the dynamic adapter is used to dynamically weight the prediction losses of the main branch network and the sampling branch network as the total loss of the dual-branch network model to guide the training of the dual-branch network model; the total loss is shown as follows: ; In the formula, is the sampling branch network loss weight generated by the adapter, t is the current training epoch, is the predefined total number of training epochs, is the regularization rate, L is the total loss, and are the prediction losses of the main branch network and the sampling branch network respectively.
[0010] Preferably, the location data includes user ID, location ID, latitude and longitude coordinates of the location, semantic category of the location, and timestamp.
[0011] Preferably, mapping the historical trajectory sequences of all users to obtain trajectory sequence embeddings specifically includes the following steps: Construct a heterogeneous location graph and a hierarchical graph based on multiple trajectory points in multiple historical trajectory sequences; Construct a trajectory sequence embedding generation module, which includes an embedding layer, a time encoding layer, an update layer, a hierarchical information extraction layer, a splicing layer, and a trajectory point embedding layer; Input the location ID and user ID of all users into the embedding layer to obtain initial location embeddings and user embeddings; Input the timestamp into the time encoding layer to obtain time embeddings; Input the initial location embeddings into the update layer, and update the initial location embeddings based on the heterogeneous location graph to obtain updated location embeddings; Input the updated location embeddings into the hierarchical information extraction layer to extract hierarchical information embeddings based on the hierarchical graph; Input the user embeddings, hierarchical information embeddings, and time embeddings into the splicing layer to obtain trajectory point embeddings; arrange the trajectory point embeddings in the historical trajectory sequences and add sequence position encodings to each trajectory point to obtain corresponding trajectory sequence embeddings.
[0012] Preferably, constructing a heterogeneous location graph and a hierarchical graph based on multiple trajectory points in multiple historical trajectory sequences includes the following steps: Use the locations corresponding to the trajectory points as location nodes. If the Haversine distance between two location nodes is less than 1000m, establish a geospatial connection edge between the two location nodes; establish a location transition connection edge between two consecutive trajectory points to obtain a heterogeneous location graph; Use the semantic category of the location as a semantic node, and establish a subordination connection edge between the semantic node and each location node it encompasses to obtain a hierarchical graph.
[0013] Preferably, dividing multiple trajectory points in the historical trajectory sequences of all users according to the check-in time interval to obtain multiple divided trajectory sequences includes the following steps: If the time interval between two check-ins of two adjacent trajectory points exceeds 24 hours, split these two trajectory points into different divided trajectory sequences; Filter out the divided trajectory sequences that contain only 1 trajectory point.
[0014] In a second aspect, the present invention provides a user location prediction system, including: An acquisition module, configured to extract the historical trajectory sequences of all users based on the historical location data of users on different social platforms, where all users include inactive users and active users; divide multiple trajectory points in the historical trajectory sequences of all users according to the check-in time interval to obtain multiple divided trajectory sequences; use the users corresponding to the divided trajectory sequences with a quantity less than a set value as inactive users; A mapping module, configured to map the historical trajectory sequences of all users to obtain trajectory sequence embeddings; A construction module, configured to construct a dual-branch network model, including a main branch network and a sampling branch network. The main branch network includes a first encoder and a hierarchical decoder, and the sampling branch network includes a second encoder and a single-layer decoder; the first encoder and the second encoder share weights; A training module, configured to train the dual-branch network model through multiple trajectory sequence embeddings to obtain a location prediction model. Among them, feature learning is performed on the trajectory sequence embeddings of all users through the first encoder, and location semantic category prediction and location prediction are performed on the trajectory sequence embeddings after feature learning through the hierarchical decoder to obtain the next check-in location prediction results of all users; after oversampling the trajectory sequence embeddings of inactive users, input them into the second encoder for feature learning, and perform location prediction on the trajectory sequence embeddings after feature learning through the single-layer decoder to obtain the next check-in location prediction results of inactive users; A prediction module, configured to map the current trajectory sequence of all users and input it into the location prediction model, and predict the next check-in location of all users through the main branch network.
[0015] Compared with the prior art, at least one of the above technical solutions adopted by the present invention can achieve the following beneficial effects: The present invention first collects the historical trajectory sequences of all users and identifies inactive users and active users. Then, a dual-branch network model including a main branch network and a sampling branch network is designed. Both branch networks adopt an encoder-decoder architecture, and the two encoders share weights to exchange information of the user features learned by each branch, so as to achieve mutual complementation and enhancement. The decoders operate independently. Among them, the main branch network combines an independent hierarchical decoder to process all the trajectory sequences of all users, and its main goal is to extract the user's movement behavior pattern from the original data distribution. The sampling branch network only processes inactive users and oversamples them, aiming to improve the prediction ability for them by increasing the exposure rate of inactive users in the training data. In the training stage, the latent features learned by the sampling branch will be effectively transmitted to the main branch through the design of sharing weights by the encoder. Therefore, in the actual application stage, only the main branch of the present invention needs to be used. The present invention improves the attention to inactive users in the training stage and effectively improves the prediction accuracy for inactive users on the basis of maintaining the prediction accuracy of active users. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art. Obviously, the drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0017] Figure 1 It is a flowchart of a user location prediction method based on a dual-branch network according to the present invention; Figure 2 It is a structural diagram of a user location prediction method based on a dual-branch network according to the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0018] The following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the drawings in the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, rather than all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.
[0019] The present invention proposes a user location prediction method based on a dual-branch network. By designing a dual-branch network architecture, where the main branch models the common behaviors of all users, and the sampling branch focuses on the behavioral characteristics of inactive users, knowledge transfer is achieved through a shared encoder. At the same time, a dynamic adapter is introduced to adaptively adjust the attention of each branch based on the training cycle, balancing the prediction performance of inactive users and the overall prediction performance, thus solving the problems existing in the prior art. Refer to Figure 1 and Figure 2 , specifically including the following steps:
[0020] S1: Extract the historical trajectory sequences of all users based on the historical location data of users on different social platforms.
[0021] The location data includes user ID, location ID, longitude and latitude coordinates of the location, semantic category of the location, and timestamp.
[0022] First, filter out locations and users with less than 10 check-ins. Proactive social behaviors with location information can be regarded as check-ins. For example, when posting a moment, sometimes location information will be attached. Then, in chronological order, divide the filtered data set into a training set (the first 80% of check-in records), a validation set (the middle 10% of check-in records), and a test set (the remaining 10% of check-in records). Secondly, in the divided training set, validation set, and test set, extract the historical trajectory sequences of each user. If the time interval between two check-ins of two consecutive trajectory points exceeds 24 hours, then these two check-ins are split into different divided trajectory sequences, and the divided trajectory sequences containing only 1 trajectory point are filtered out; sort according to the number of divided trajectory sequences of each user, and take the least 15% of users as inactive users and mark them.
[0023] S2: Map the historical trajectory sequence of each user to obtain multiple trajectory sequence embeddings. It includes the following steps:
[0024] S21: Construct a heterogeneous location graph, a hierarchical graph of locations and their semantic categories based on the training set.
[0025] This heterogeneous location graph contains one type of node and two types of edges; each node directly corresponds to a unique location, and the edge types include geospatial edges and location transfer edges; the specific construction processes of the two types of edges are as follows: If the Haversine distance between any two locations is less than 1000m, then establish a geospatial edge between them. The geospatial edge is undirected and unweighted.
[0026] Establish a location transfer edge between two consecutive trajectory points in each historical trajectory sequence. The location transfer edge is directed and weighted, and its direction represents the transfer from one location to another location. Its weight calculation is shown as follows: ; Among them, is the weight of the edge transferred from position to position . is the frequency transferred from position to position . is the frequency transferred from any position in the position set to position .
[0027] Construct a hierarchical graph of positions and their semantic categories based on the training set, use the semantic categories of positions as semantic nodes, and then establish membership edges between semantic nodes and each position node included therein.
[0028] S22: Construct a trajectory sequence embedding generation module, which includes an embedding layer, a time encoding layer, an update layer, a hierarchical information extraction layer, a splicing layer, and a trajectory point embedding layer.
[0029] S23: Generate a user trajectory sequence embedding through the trajectory sequence embedding generation module, which specifically includes: inputting the user's position ID and user ID into the embedding layer to obtain an initial position embedding and a user embedding, specifically expressed as: ; Among them, and respectively represent the user embedding matrix and the position embedding matrix, both of which are trainable parameter matrices, is the total number of users, is the total number of positions, and are the dimensions of the user embedding and the position embedding respectively, i is the i th user, j is the j th position.
[0030] S24: Generate time embeddings at the weekly scale and daily scale through the time encoding layer. The specific steps include:
[0031] Extract the week index from the timestamp, that is, Monday to Sunday are represented as 1 - 7; each half hour is taken as a time period, and the 24 hours of a day are divided into 48 time periods, and then extract the time period index from the timestamp, that is, 1 - 48.
[0032] Use the position encoding technology in Transformer to generate time embeddings at the weekly scale and daily scale, specifically expressed as: ; Among them, is the dimension of the time embedding,i is the dimension index. Substituting pos in the formula with the week index and the time period index, the time embeddings at the week scale and the daily scale can be obtained, and then adding the two as the final time embedding, denoted as .
[0033] S25: Input the initial position embedding into the update layer, and update the position embedding based on the heterogeneous position graph. The specific steps include:
[0034] Update the position embedding based on the geospatial connection, specifically expressed as: ; where g represents the geospatial connection, is the normalized adjacency matrix under the geospatial connection, N is the number of graph convolution layers, is the initial position embedding, is the position embedding updated at the n th layer under the geospatial connection.
[0035] Update the position embedding based on the position transfer connection, specifically expressed as: ; where t represents the position transfer connection, is the weight of the edge transferring from position to position , is the set of neighbor nodes of the position node , is the embedding of the j th position updated at the nth layer under the position transfer connection.
[0036] Adopt the semantic attention mechanism to fuse the features of the position embedding updates under the above two position connections as the final updated position embedding, specifically expressed as: ; where is the updated position embedding at the n th layer, is the update weight of the position embedding for different position connections, is the feature transformation matrix, is the semantic attention vector, and are both learnable parameters, is the exponential function.
[0037] S26: Embed the updated location into the hierarchical information extraction layer, and extract the hierarchical information embedding based on the hierarchical graph. Specifically, it is expressed as:
[0038] ; Among them, is the semantic embedding generated from the location embeddings under the same semantic category, is the non-linear activation function, represents the summation operation, is the learnable feature transformation matrix, represents the concatenation operation, is the extracted hierarchical information embedding.
[0039] S27: Concatenate the user embedding, time embedding, and hierarchical information embedding as the embedding of a single trajectory point, then arrange the trajectory point embeddings corresponding to each timestamp in the historical trajectory sequence, and add the sequence position encoding to each trajectory point, thus obtaining the embedding of this trajectory sequence.
[0040] Taking a single historical trajectory sequence as an example, the specific steps are as follows: Concatenate the user embedding, time embedding, and hierarchical information embedding as the embedding of a single trajectory point. Specifically, it is expressed as: ; Among them, is the dimension of the single trajectory point embedding.
[0041] Generate the position encoding for sorting the trajectory point in the current trajectory sequence (denoted as ), and the specific calculation is as follows: ; Among them, is the dimension of the single trajectory point embedding, i is the dimension index, pos represents the sorting position of the trajectory point in the current trajectory sequence.
[0042] Add and as the final embedding of this trajectory point.
[0043] Arrange the trajectory point embeddings of each trajectory point in order to obtain the embedding of this trajectory sequence, denoted as .
[0044] S3: Construct a dual-branch network model.
[0045] The dual-branch network model includes a main branch network and a sampling branch network. Both the main branch network and the sampling branch network adopt an encoder-decoder architecture, where the encoders share weights to achieve feature migration. The main branch processes the full set of user trajectories and uses a hierarchical decoder, while the sampling branch focuses on the trajectories of inactive users and adopts an oversampling strategy and a single-layer decoder. During the training phase, the weighted sum of the prediction losses of the two branches is used as the total loss of the model, and the respective weights are determined by a dynamic adapter. During the inference phase, only the main branch is used. The full set of users includes active users and inactive users.
[0046] S4: Update and iterate the prediction model parameters using the historical trajectory sequences extracted from the training set, tune the prediction model parameters by calculating them using the trajectory sequences extracted from the validation set, and evaluate the performance of the prediction model using the trajectory sequences extracted from the test set.
[0047] Its training process includes the following steps: Embed the batch of trajectory sequences and send them into the dual-branch network for training, which specifically includes: The main branch performs feature learning on the input trajectory sequence embeddings in the hidden high-dimensional space through a Transformer encoder. Specifically, it includes the following steps:
[0048] Calculate the output of the multi-head self-attention : ; Among them, m is the total number of attention heads, head i represents the output of the i th attention head, , , are the feature transformation matrices corresponding to the i th attention head, is the finally output feature transformation matrix.
[0049] Perform residual connection and layer normalization in the multi-head self-attention sublayer: ; In the formula, h sub1 is the trajectory sequence embedding updated through the multi-head self-attention sublayer.
[0050] Calculate the output of the feed-forward neural network : ; In the formula, W 1 and W 2 are the first parameter matrix and the second parameter matrix, b 1 and b2 is the first bias vector and the second bias vector.
[0051] Perform residual connection and layer normalization in the feedforward neural network sublayer: ; Take as the input of the next encoding layer and perform the same processing flow again. After all encoding layers are processed, the trajectory sequence embedding after feature learning is obtained .
[0052] Then, the hierarchical decoder first performs position semantic category prediction on the trajectory sequence embedding after feature learning, and then further predicts the specific position; specifically expressed as: ; Among them, and are the semantic category embedding and position embedding decoded by the main branch hierarchical decoder respectively, and are parameter-learnable feature transformation matrices, and are the number of positions and their semantic categories in the dataset respectively.
[0053] The sampling branch first extracts the trajectory sequence embedding of inactive users from the batch trajectory sequence embedding, then performs 4-fold random oversampling to increase the exposure rate of inactive users during network training, and then performs feature learning on the input trajectory sequence embedding in the latent high-dimensional space through the Transformer encoder (shared with the main branch). Finally, the specific position is directly predicted through a single-layer decoder for the trajectory sequence embedding after feature learning; specifically expressed as: ; Among them, is the position embedding decoded by the single-layer decoder of the sampling branch, is the parameter-learnable feature transformation matrix.
[0054] Dynamically weight the prediction losses of the two branches through the dynamic adapter as the total loss of the model to guide the training of the model; specifically expressed as: Calculate the prediction loss of the main branch: ; Calculate the prediction loss of the sampling branch: ; and are the prediction losses of the main branch and the sampling branch respectively.
[0055] The adapter adjusts the weights of the two branches to obtain the final predicted loss, which is specifically expressed as: ; wherein, t is the current training epoch, is the predefined total number of training epochs, is the regularization rate, is the sampling branch loss weight generated by the adapter.
[0056] In the inference stage, the current location trajectory of the user is input into the trained prediction model to predict the possible locations that the user may visit next; only the main branch is used in the inference stage. In specific applications, only the main branch is adopted. Both branch networks adopt an encoder-decoder architecture. Among them, the encoder shares weights between branches to exchange information of the user features learned by each branch, so as to achieve mutual complementation and enhancement, and the decoders run independently. The main branch network combines an independent hierarchical decoder to process all the trajectory sequences of all users, and its main goal is to extract the movement behavior patterns of users from the original data distribution. The sampling branch network only processes inactive users and oversamples them, aiming to improve the prediction ability for them by increasing the exposure rate of inactive users in the training data. Generally speaking, in the training stage, the potential features learned by the sampling branch will be effectively transmitted to the main branch through the design of sharing weights by the encoder. Therefore, in the actual inference stage, only the main branch needs to be used.
[0057] The dual-branch network consists of two different branch networks, namely the main branch and the sampling branch. Both branch networks adopt an encoder-decoder architecture. Among them, the encoder shares weights between branches to exchange information of the user features learned by each branch, so as to achieve mutual complementation and enhancement, and the decoders run independently. The main branch network combines an independent hierarchical decoder to process all the trajectory sequences of all users, and its main goal is to extract the movement behavior patterns of users from the original data distribution. The sampling branch network only processes inactive users and oversamples them, aiming to improve the prediction ability for them by increasing the exposure rate of inactive users in the training data.
[0058] The design of the adapter imposes two key constraints on the training dynamics of the model. One is that it ensures that the model continuously focuses on the main branch to ensure in-depth learning of the user behavior patterns. Secondly, as the training progresses, especially after a comprehensive understanding of the original data distribution has been established in the initial stage, the model gradually shifts its attention to the sampling branch. This strategic focus shift aims to improve the prediction accuracy for inactive users.
[0059] Based on the same concept, the present invention also provides a user location prediction system, including an acquisition module, a mapping module, a construction module, a training module, and a prediction module.
[0060] The acquisition module is used to extract the historical trajectory sequences of all users based on the historical location data of users on different social platforms, where all users include inactive users and active users; divide multiple trajectory points in the historical trajectory sequences of all users according to the check-in time interval to obtain multiple divided trajectory sequences; and regard the users corresponding to the divided trajectory sequences with a quantity less than the set value as inactive users.
[0061] The mapping module is used to map the historical trajectory sequences of all users to obtain trajectory sequence embeddings.
[0062] The construction module is used to construct a double-branch network model, including a main branch network and a sampling branch network. The main branch network includes a first encoder and a hierarchical decoder, and the sampling branch network includes a second encoder and a single-layer decoder; the first encoder and the second encoder share weights.
[0063] The training module is used to train the double-branch network model through multiple trajectory sequence embeddings to obtain a location prediction model. Among them, feature learning is performed on the trajectory sequence embeddings of all users through the first encoder, and location semantic category prediction and location prediction are performed on the trajectory sequence embeddings after feature learning through the hierarchical decoder to obtain the next check-in location prediction results of all users; the trajectory sequence embeddings of inactive users are oversampled and then input into the second encoder for feature learning, and location prediction is performed on the trajectory sequence embeddings after feature learning through the single-layer decoder to obtain the next check-in location prediction results of inactive users.
[0064] The prediction module is used to map the current trajectory sequence of all users and input it into the location prediction model, and predict the next check-in location of all users through the main branch network.
[0065] Although the preferred embodiments of the present invention have been described, those skilled in the art can make additional changes and modifications once they know the basic creative concept. Therefore, the appended claims are intended to be construed as including the preferred embodiments and all changes and modifications falling within the scope of the present invention.
[0066] Obviously, those skilled in the art can make various changes and deformations to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and deformations of the present invention fall within the scope of the claims of the present invention and their equivalent technologies, the present invention is also intended to include these modifications and deformations.
Claims
1. A user location prediction method based on a dual-branch network, characterized in that, Including the following steps: Extract the historical trajectory sequences of all users based on the historical location data of users on different social platforms, where all users include inactive users and active users; divide multiple trajectory points in the historical trajectory sequences of all users according to the check-in time interval to obtain multiple divided trajectory sequences; regard the users corresponding to the divided trajectory sequences with a quantity less than the set value as inactive users; Map the historical trajectory sequences of all users to obtain trajectory sequence embeddings; Construct a dual-branch network model, including a main branch network and a sampling branch network. The main branch network includes a first encoder and a hierarchical decoder, and the sampling branch network includes a second encoder and a single-layer decoder; the first encoder and the second encoder share weights; Train the dual-branch network model through multiple trajectory sequence embeddings to obtain a location prediction model. Among them, perform feature learning on the trajectory sequence embeddings of all users through the first encoder, and perform location semantic category prediction and location prediction on the trajectory sequence embeddings after feature learning through the hierarchical decoder to obtain the predicted result of the next check-in location of all users; oversample the trajectory sequence embeddings of inactive users and then input them into the second encoder for feature learning, and perform location prediction on the trajectory sequence embeddings after feature learning through the single-layer decoder to obtain the predicted result of the next check-in location of inactive users; Map the current trajectory sequence of all users and input it into the location prediction model, and predict the next check-in location of all users through the main branch network.
2. The user location prediction method based on a dual-branch network according to claim 1, wherein The performing feature learning on the trajectory sequence embeddings of all users through the first encoder specifically includes the following steps: Calculate the multi-head self-attention output: ; In the formula, is the output of the multi-head self-attention, m is the total number of attention heads, head i represents the i -th output of the attention head, , , are the feature transformation matrices corresponding to the i -th attention head, is the final output feature transformation matrix, D is the dimension, h is the trajectory sequence embedding of all users; Perform residual connection and layer normalization in the multi-head self-attention sublayer: ; In the formula, h sub1 is the trajectory sequence embedding updated by the multi-head self-attention sublayer; Calculate the feed-forward neural network output: ; In the formula, is the output of the feedforward neural network, W 1 and W 2 are the first parameter matrix and the second parameter matrix, b 1 and b 2 are the first bias vector and the second bias vector; Perform residual connection and layer normalization in the feed-forward neural network sublayer: ; In the formula, hs ub2 is the trajectory sequence embedding updated by the feed-forward neural network sub-layer; Take as the input of the next encoding layer and perform the same processing flow again. After all encoding layers are processed, a trajectory sequence embedding after feature learning is obtained.
3. The user location prediction method based on a dual-branch network according to claim 2, characterized in that, The performing location semantic category prediction and location prediction on the trajectory sequence embeddings after feature learning through the hierarchical decoder is specifically expressed as: ; In the formula, and are the semantic category embedding and the position embedding obtained through the hierarchical decoder respectively, is the trajectory sequence embedding after feature learning, is the non-linear activation function.
4. The user location prediction method based on a dual-branch network according to claim 3, wherein, The performing location prediction on the trajectory sequence embeddings after feature learning through the single-layer decoder is specifically expressed as: ; In the formula, is the position embedding obtained by decoding through a single-layer decoder, W 3 is the third parameter matrix, b 3 is the third bias vector.
5. A user location prediction method based on a dual-branch network according to claim 1, characterized in that Dynamically weight the prediction losses of the main branch network and the sampling branch network through a dynamic adapter as the total loss of the dual-branch network model to guide the training of the dual-branch network model; the total loss is as follows: ; In the formula, is the sampling branch network loss weight generated by the adapter, t is the current training epoch, is the predefined total number of training epochs, is the regularization rate, and L is the total loss, and are the prediction losses of the main branch network and the sampling branch network, respectively.
6. The user location prediction method based on a dual-branch network according to claim 1, wherein The location data includes user ID, location ID, longitude and latitude coordinates of the location, semantic category of the location, and timestamp.
7. The user location prediction method based on a dual-branch network according to claim 6, characterized in that, The mapping the historical trajectory sequences of all users to obtain trajectory sequence embeddings specifically includes the following steps: Construct a heterogeneous location graph and a hierarchical graph based on multiple trajectory points in multiple historical trajectory sequences; Construct a trajectory sequence embedding generation module, which includes an embedding layer, a time encoding layer, an update layer, a hierarchical information extraction layer, a splicing layer, and a trajectory point embedding layer; Input the location ID and user ID of all users into the embedding layer to obtain an initial location embedding and a user embedding; Input the timestamp into the time encoding layer to obtain a time embedding; Input the initial location embedding into the update layer, and update the initial location embedding based on the heterogeneous location graph to obtain an updated location embedding; Embed the updated location into the input and feed it into the hierarchical information extraction layer to extract the hierarchical information embedding based on the hierarchical graph; Feed the user embedding, hierarchical information embedding, and time embedding into the concatenation layer to obtain the trajectory point embedding; Arrange the trajectory point embeddings in the historical trajectory sequence and add sequence position encoding to each trajectory point to obtain the corresponding trajectory sequence embedding.
8. The user location prediction method based on a dual-branch network according to claim 7, characterized in that Constructing the heterogeneous location graph and hierarchical graph based on multiple trajectory points in multiple historical trajectory sequences includes the following steps: Take the location corresponding to the trajectory point as the location node. If the Haversine distance between two location nodes is less than 1000m, establish a geospatial edge between the two location nodes; Establish a location transfer edge between two consecutive trajectory points to obtain the heterogeneous location graph; Take the semantic category of the location as the semantic node and establish a membership edge between the semantic node and each location node it encompasses to obtain the hierarchical graph.
9. The user location prediction method based on a dual-branch network according to claim 1, wherein Divide the multiple trajectory points in the historical trajectory sequence of all users according to the check-in time interval to obtain multiple divided trajectory sequences, including the following steps: If the time interval between two check-ins of two adjacent trajectory points exceeds 24 hours, split these two trajectory points into different divided trajectory sequences; Filter out the divided trajectory sequences that contain only 1 trajectory point.
10. A user location prediction system, characterized in that, Include: An acquisition module for extracting the historical trajectory sequence of all users based on the historical location data of users on different social platforms, where all users include inactive users and active users; Divide the multiple trajectory points in the historical trajectory sequence of all users according to the check-in time interval to obtain multiple divided trajectory sequences; Consider the users corresponding to the divided trajectory sequences with a quantity less than the set value as inactive users; A mapping module for mapping the historical trajectory sequence of all users to obtain the trajectory sequence embedding; A construction module for constructing a two-branch network model, including a main branch network and a sampling branch network. The main branch network includes a first encoder and a hierarchical decoder, and the sampling branch network includes a second encoder and a single-layer decoder; The first encoder and the second encoder share weights; A training module for training the two-branch network model through multiple trajectory sequence embeddings to obtain a location prediction model. Among them, use the first encoder to perform feature learning on the trajectory sequence embedding of all users, and use the hierarchical decoder to perform location semantic category prediction and location prediction on the trajectory sequence embedding after feature learning to obtain the next check-in location prediction result of all users; Oversample the trajectory sequence embedding of inactive users and then input it into the second encoder for feature learning, and use the single-layer decoder to perform location prediction on the trajectory sequence embedding after feature learning to obtain the next check-in location prediction result of inactive users; A prediction module for mapping the current trajectory sequence of all users and inputting it into the location prediction model, and predicting the next check-in location of all users through the main branch network.