Trajectory prediction method, device, electronic device and storage medium
By performing feature analysis and weight parameter conversion processing on the elderly's trajectory data, and using the self-attention model to predict where the elderly will go, it solves the management difficulty problem caused by the scattered activity areas of the elderly in community elderly care, and improves management efficiency.
Patent Information
- Application Number
- CN202111359735.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-17
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2041-11-17
AI Technical Summary
In community elderly care, the activity areas of the elderly are numerous and scattered, making elderly care management difficult. How to predict the activity trajectories of the elderly for better management has become an urgent issue.
By obtaining the trajectory data of the target object, performing feature analysis and weight parameter conversion processing, determining the location where the elderly will go based on interest analysis, and using the self-attention model and the continuous bag-of-words model to predict the trajectory, a trajectory prediction method, device, electronic Equipment and storage media.
Knowing in advance where the elderly are going will make it easier for managers to grasp activity trends, reduce management difficulty, and improve management efficiency.
Smart Images

Figure CN114154687B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of health care and elderly care technology, and in particular to a trajectory prediction method, device, electronic device and storage medium. Background Art
[0002] In the field of elderly care, community-based elderly care has become a trend because it allows the elderly to live in a familiar community environment and gives them a greater sense of belonging. However, in community-based elderly care, the elderly have relatively more activity areas and their activity locations are relatively scattered, which brings great difficulties to elderly care management.
[0003] Therefore, how to predict the activity trajectory of the elderly to facilitate nursing home managers to better manage the elderly has become an urgent problem that needs to be solved. Summary of the invention
[0004] The embodiments of the present application provide a trajectory prediction method, device, electronic device, and storage medium, which are used to provide a solution for predicting activity trajectories.
[0005] In a first aspect, an embodiment of the present application provides a trajectory prediction method, comprising:
[0006] Acquire trajectory data of the target object in the current cycle, the trajectory data including locations reached by the target object and the order of arrival of the locations;
[0007] Performing feature analysis on the trajectory data to obtain trajectory features;
[0008] The trajectory feature is converted based on a weight parameter to obtain a conversion feature, wherein the weight parameter is obtained by learning the relationship between the trajectory feature and the conversion feature of the trajectory data of the target object in a historical period;
[0009] Based on the conversion features, analyzing the target object's interest in traveling to each candidate location;
[0010] Based on the interest analysis result, a location where the target object is going to is determined.
[0011] In some embodiments, performing feature analysis on the trajectory data to obtain trajectory features includes:
[0012] Based on predetermined location embedding parameters, generating a location embedding vector for each location reached by the target object;
[0013] generating an order embedding vector for the location based on a predetermined order embedding parameter;
[0014] Fusing the location embedding vector and the order vector to obtain a trajectory vector of the location;
[0015] The trajectory vectors of each location are combined in the order of arrival, and the combined trajectory matrix is used as the trajectory feature.
[0016] In some embodiments, the weight parameters include a first weight matrix, a second weight matrix, and a third weight matrix, and the trajectory features are converted based on the weight parameters to obtain conversion features, including:
[0017] Performing a transformation process on the trajectory matrix based on the first weight matrix to obtain a first transformation matrix;
[0018] Performing a transformation process on the trajectory matrix based on the second weight matrix to obtain a second transformation matrix;
[0019] Performing a transformation process on the trajectory matrix based on the third weight matrix to obtain a third transformation matrix;
[0020] The first conversion matrix, the second conversion matrix and the third conversion matrix are used as the conversion features.
[0021] In some embodiments, based on the conversion feature, analyzing the target object's interest in traveling to each candidate location includes:
[0022] Determining weights of locations reached by the target object based on the first conversion matrix and the second conversion matrix;
[0023] Based on the weights of the locations reached by the target object, a weighted sum is performed on the column vectors in the third transformation matrix to obtain an interest representation vector.
[0024] In some embodiments, the weight w of the i-th location reached by the target object is determined according to the following formula: i :
[0025]
[0026] Among them, q i is the i-th column vector in the first transformation matrix, k i is the i-th column vector in the second transformation matrix, k j is the jth column vector in the second transformation matrix, d is the number of rows in the trajectory matrix, m is the total number of locations reached by the target object, and i and j are both integers.
[0027] In some embodiments, based on the interest analysis result, determining the location to which the target object is going includes:
[0028] Based on the interest representation vector and the embedding vector of each candidate location, determining the probability of the target object going to each candidate location, each candidate location is determined according to the location that the target object has visited in a historical period;
[0029] The candidate location with the highest probability is determined as the location to which the target object will go.
[0030] In some embodiments, the probability p(v) of the target object going to the cth candidate location is determined according to the following formula: c ):
[0031]
[0032] Among them, v c is the cth candidate location, a is the interest representation vector, VE c is the embedding vector of the cth candidate location, VE s is the embedding vector of the sth candidate location, N is the total number of candidate locations, and c and s are both integers.
[0033] In a second aspect, an embodiment of the present application provides a trajectory prediction device, comprising:
[0034] An acquisition module, used to acquire trajectory data of a target object in a current cycle, wherein the trajectory data includes locations reached by the target object and an arrival order of the locations;
[0035] A feature analysis module, used to perform feature analysis on the trajectory data to obtain trajectory features;
[0036] A conversion module, used for converting the trajectory features based on weight parameters to obtain conversion features, wherein the weight parameters are obtained by learning the relationship between the trajectory features and the conversion features of the trajectory data of the target object in a historical period;
[0037] An interest analysis module, used for analyzing the interest of the target object in traveling to each candidate location based on the conversion feature;
[0038] A determination module is used to determine the location where the target object will go based on the interest analysis result.
[0039] In some embodiments, the feature analysis module is specifically used to:
[0040] Based on predetermined location embedding parameters, generating a location embedding vector for each location reached by the target object;
[0041] generating an order embedding vector for the location based on a predetermined order embedding parameter;
[0042] Fusing the location embedding vector and the order vector to obtain a trajectory vector of the location;
[0043] The trajectory vectors of each location are combined in the order of arrival, and the combined trajectory matrix is used as the trajectory feature.
[0044] In some embodiments, the weight parameters include a first weight matrix, a second weight matrix, and a third weight matrix, and the conversion module is specifically used to:
[0045] Performing a transformation process on the trajectory matrix based on the first weight matrix to obtain a first transformation matrix;
[0046] Performing a transformation process on the trajectory matrix based on the second weight matrix to obtain a second transformation matrix;
[0047] Performing a transformation process on the trajectory matrix based on the third weight matrix to obtain a third transformation matrix;
[0048] The first conversion matrix, the second conversion matrix and the third conversion matrix are used as the conversion features.
[0049] In some embodiments, the interest analysis module is specifically used to:
[0050] Determining weights of locations reached by the target object based on the first conversion matrix and the second conversion matrix;
[0051] Based on the weights of the locations reached by the target object, a weighted sum is performed on the column vectors in the third transformation matrix to obtain an interest representation vector.
[0052] In some embodiments, the interest analysis module is specifically used to determine the weight w of the i-th location reached by the target object according to the following formula: i :
[0053]
[0054] Among them, q i is the i-th column vector in the first transformation matrix, k i is the i-th column vector in the second transformation matrix, k j is the jth column vector in the second transformation matrix, d is the number of rows in the trajectory matrix, m is the total number of locations reached by the target object, and i and j are both integers.
[0055] In some embodiments, the determining module is specifically used to:
[0056] Based on the interest representation vector and the embedding vector of each candidate location, determining the probability of the target object going to each candidate location, each candidate location is determined according to the location that the target object has visited in a historical period;
[0057] The candidate location with the highest probability is determined as the location to which the target object will go.
[0058] In some embodiments, the determination module is specifically configured to determine the probability p(v) that the target object goes to the cth candidate location according to the following formula: c ):
[0059]
[0060] Among them, v c is the cth candidate location, a is the interest representation vector, VE c is the embedding vector of the cth candidate location, VE l is the embedding vector of the lth candidate location, N is the total number of candidate locations, and c and l are both integers.
[0061] In a third aspect, an embodiment of the present application provides an electronic device, comprising: at least one processor, and a memory communicatively connected to the at least one processor, wherein:
[0062] The memory stores instructions that can be executed by at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the above-mentioned trajectory prediction method.
[0063] In a fourth aspect, an embodiment of the present application provides a storage medium. When instructions in the storage medium are executed by a processor of an electronic device, the electronic device can execute the above-mentioned trajectory prediction method.
[0064] In the embodiment of the present application, the trajectory data of the target object in the current cycle is obtained, and the trajectory data includes the places reached by the target object and the order of arrival at the places. The trajectory data is subjected to feature analysis to obtain trajectory features, and the trajectory features are converted based on weight parameters to obtain conversion features. Based on the conversion features, the interest of the target object in going to each candidate location is analyzed, and based on the interest analysis results, the location to which the target object is going is determined. The weight parameters are obtained by learning the relationship between the trajectory features and the conversion features of the trajectory data of the target object in the historical cycle. In this way, the location to which the target object is going can be known in advance, which is convenient for managers to grasp the activity trends of the target object, reduce management difficulty, and improve management efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0065] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0066] Figure 1 An application scenario diagram of trajectory prediction provided in an embodiment of the present application;
[0067] Figure 2 A flow chart of a trajectory prediction method provided in an embodiment of the present application;
[0068] Figure 3 A flow chart of performing feature analysis on trajectory data provided in an embodiment of the present application;
[0069] Figure 4 A flowchart for analyzing the interest of a target object in visiting various candidate locations provided in an embodiment of the present application;
[0070] Figure 5 A flowchart for determining a location to which a target object is to go provided in an embodiment of the present application;
[0071] Figure 6 A schematic diagram of the structure of a self-attention model provided in an embodiment of the present application;
[0072] Figure 7 A schematic diagram of the structure of a continuous bag-of-words model provided in an embodiment of the present application;
[0073] Figure 8 A schematic diagram of the structure of a trajectory prediction device provided in an embodiment of the present application;
[0074] Fig. 9 A schematic diagram of the hardware structure of an electronic device for implementing a trajectory prediction method provided in an embodiment of the present application. DETAILED DESCRIPTION
[0075] In order to provide a solution for predicting activity trajectories, embodiments of the present application provide a trajectory prediction method, device, electronic device, and storage medium.
[0076] The preferred embodiments of the present application are described below in conjunction with the drawings in the specification. It should be understood that the preferred embodiments described herein are only used to illustrate and explain the present application, and are not used to limit the present application. In addition, the embodiments and features in the embodiments of the present application may be combined with each other if there is no conflict.
[0077] In community-based elderly care, the elderly generally have multiple activity locations such as dormitories, canteens, squares, parks, libraries, etc. In order to better provide elderly care services, positioning cards can be provided to the elderly. When the positioning cards are enabled, the activity data of the elderly can be obtained, such as which places they have visited, how long they have stayed in these places, etc. The trajectory data of the elderly can be obtained based on the activity data.
[0078] Figure 1 This is an application scenario diagram of a trajectory prediction provided by an embodiment of the present application. In specific implementation, an area ( Figure 1 In this area, there may be multiple locations and multiple objects, such as three objects: object 1, object 2, and object 3, where object 1 has been active in this area, object 2 has entered this area from the outside, and object 3 has stayed in this area. In either case, when an object is located in this area, the positioning card worn by the object can send the trajectory data of the object in this area to the server. Afterwards, the server can generate the trajectory data of the object in the current period based on the activity data.
[0079] After introducing the application scenario of the embodiment of the present application, the trajectory prediction method of the embodiment of the present application is described in conjunction with the flowchart.
[0080] Figure 2 A flow chart of a trajectory prediction method provided in an embodiment of the present application, which can be applied to Figure 1 The method can be applied to the server in the embodiment and can also be applied to other servers, and the method includes the following steps.
[0081] In step S201 , the trajectory data of the target object in the current cycle is obtained, and the trajectory data includes the locations reached by the target object and the order of arrival of the locations.
[0082] The target object may be any resident, such as the elderly living in a retirement community, children living in an ordinary community, etc. The current period may be the current day.
[0083] In step S202, feature analysis is performed on the trajectory data to obtain trajectory features.
[0084] In specific implementation, Figure 3 The process shown performs feature analysis on trajectory data, including the following steps:
[0085] In step S301a, based on predetermined place embedding parameters, a place embedding vector is generated for each place reached by the target object.
[0086] Generally, the location embedding parameters can be expressed in matrix form. In specific implementation, one-hot encoding can be used to encode each location reached by the target object to obtain a sparse vector of the location, and then the dot product of the sparse vector and the matrix is calculated to obtain the location embedding vector of the location.
[0087] In step S302a, an order embedding vector of the place is generated based on predetermined order embedding parameters.
[0088] Generally, the order embedding parameter can be expressed as a vector with the order of the location as a parameter. In specific implementation, the order of arrival of each location arrived by the target object is substituted into this vector to obtain the order embedding vector of the location.
[0089] In step S303a, the location embedding vector and the order vector are fused to obtain the trajectory vector of the location.
[0090] For example, the elements at the same position in the location embedding vector and the order embedding vector are added to obtain the trajectory vector of the location.
[0091] In step S304a, the trajectory vectors of each location are combined in the order of arrival, and the combined trajectory matrix is used as the trajectory feature.
[0092] For example, according to the arrival order from early to late, the trajectory vectors of each location are combined by column, and the combined trajectory matrix is used as the trajectory feature of the trajectory data.
[0093] In step S203, the trajectory features are transformed based on weight parameters to obtain transformation features, where the weight parameters are obtained by learning the relationship between the trajectory features and the transformation features of the trajectory data of the target object in the historical period.
[0094] In specific implementation, the weight parameters may include a first weight matrix, a second weight matrix and a third weight matrix. Therefore, the trajectory matrix can be transformed based on the first weight matrix to obtain a first transformation matrix, the trajectory matrix can be transformed based on the second weight matrix to obtain a second transformation matrix, and the trajectory matrix can be transformed based on the third weight matrix to obtain a third transformation matrix. The first transformation matrix, the second transformation matrix and the third transformation matrix are used as transformation features.
[0095] Among them, the first conversion matrix mainly focuses on the current location in the trajectory data and can be used to characterize the trajectory characteristics of the current location; the second conversion matrix mainly focuses on other locations (i.e., locations other than the current location) and can be used to characterize the trajectory characteristics of other locations; the third conversion matrix is used to characterize the association relationship between the current location and other locations.
[0096] In step S204, based on the conversion features, the target object's interest in traveling to each candidate location is analyzed.
[0097] In specific implementation, Figure 4 The process shown analyzes the interest of the target object in going to each candidate location, including the following steps:
[0098] In step S401a, based on the first conversion matrix and the second conversion matrix, the weights of the locations reached by the target object are determined.
[0099] For example, the weight w of the i-th location reached by the target object can be determined according to the following formula: i :
[0100]
[0101] Among them, q i is the i-th column vector in the first transformation matrix, k i is the i-th column vector in the second transformation matrix, k j is the jth column vector in the second transformation matrix, d is the number of rows in the trajectory matrix, m is the total number of locations reached by the target object, and i and j are both integers.
[0102] In step S402a, based on the weights of the locations reached by the target object, the column vectors in the third transformation matrix are weighted summed to obtain an interest representation vector.
[0103] The interest representation vector is used to represent the target object's interest in each candidate location. Each element in the interest vector corresponds to a candidate location. The larger the value of the element, the higher the target object's interest in the candidate location. The smaller the value of the element, the lower the target object's interest in the candidate location.
[0104] For example, the interest representation vector a is determined according to the following formula:
[0105]
[0106] Among them, u i is the i-th column vector in the third transformation matrix.
[0107] In step S205, based on the interest analysis result, the location where the target object will go is determined.
[0108] In specific implementation, Figure 5 The process shown determines the location where the target object is going to, including the following steps:
[0109] In step S501a, based on the interest representation vector and the embedding vector of each candidate location, the probability of the target object going to each candidate location is determined, and each candidate location is determined according to the location that the target object has visited in the historical period.
[0110] In specific implementation, all places that the target object has visited during the historical period may be determined as candidate places, or some places that the target object has visited during the historical period may be determined as candidate places.
[0111] Then, the probability p(v c ):
[0112]
[0113] in, vc is the cth candidate location, a is the interest representation vector, VE c is the embedding vector of the cth candidate location, VE l is the embedding vector of the lth candidate location, N is the total number of candidate locations, and c and l are both integers.
[0114] In step S502a, the candidate location with the highest probability is determined as the location to which the target object will go.
[0115] The above process is described below in conjunction with specific embodiments.
[0116] In a specific implementation, a self-attention model may be used to predict the location where the target object will go based on the trajectory data of the target object in the current cycle, where the trajectory data includes the locations where the target object will arrive and the order in which the locations will arrive.
[0117] See also Figure 6 The self-attention model includes an input layer, an embedding representation layer, a feature conversion layer, an attention layer, and an output layer. The input layer is used to encode the locations that the target object arrives at in the current cycle to obtain the sparse vectors of each location; the embedding representation layer is used to represent the sparse vectors of each location as location embedding vectors, convert the arrival order of each location into an order embedding vector, fuse the location embedding vector and the order embedding vector of the same location to obtain the trajectory vector of the location, and generate a trajectory matrix based on the trajectory vectors of each location; the feature conversion layer is used to convert the trajectory matrix to obtain a conversion matrix; the attention layer is used to calculate the probability of the target object going to each candidate location based on the conversion matrix; the output layer is used to output the location with the highest probability as the location to be visited by the target object.
[0118] In specific implementation, the above process can be carried out according to the following steps:
[0119] The first step is to embed the locations in the trajectory data.
[0120] The embedding representation of a place includes the place embedding representation and the order embedding representation. The following introduces these two embedding representations respectively.
[0121] 1. Location embedding representation.
[0122] Taking the daily cycle as an example, suppose the trajectory data of the target object in the last three days is:
[0123] Track data 1: A place -> B place -> D place -> E place -> A place;
[0124] Track data 2: A --> B --> C --> D --> E --> A;
[0125] Track data 3: Place A -> Place C -> Place D -> Place E -> Place A.
[0126] The set of all locations of the trajectory data for these three days is: {A, B, C, D, E}, the size of the set is n=5, v1 represents A, v2 represents B, v3 represents C, v4 represents D, and v5 represents E.
[0127] In specific implementation, one-hot encoding can be used to encode these five locations, and the sparse vector of location A is: (1, 0, 0, 0, 0); the sparse vector of location B is: (0, 1, 0, 0, 0); the sparse vector of location C is: (0, 0, 1, 0, 0); the sparse vector of location D is: (0, 0, 0, 1, 0); the sparse vector of location E is: (0, 0, 0, 0, 1). Then, the word-to-vector (Word2Vec) technology is used to represent the n-dimensional sparse vector of each location as a d-dimensional dense vector (i.e., location embedding vector), d < n.
[0128] The following takes the Continuous Bag-of-Words Model (CBOW) as an example to illustrate the process of generating location embedding parameters for converting the sparse vector of a location into a dense vector.
[0129] Assume d = 2, Figure 7 A schematic diagram of the structure of a continuous bag-of-words model provided in the example of this application, wherein W1, B1, W2, B2 are the parameters of the continuous bag-of-words model to be learned, ReLU(x)=max(0,x), m is the number of locations contained in the trajectory data.
[0130] When starting training, the weight matrices W1 and W2 can be initialized to random values, such as:
[0131] Take A -> B as an example, then according to Figure 7 Calculating the formula in gives: in,
[0132] Output of the continuous bag-of-words model based on the initialized weight matrix The error with the actual result Y(B) can be expressed as cross entropy: The training process of the continuous bag of words model is to adjust the model parameters such as the weight matrix so that the sum of the cross entropy of all training samples is less than the preset threshold.
[0133] Taking trajectory data 1: A -> B -> D -> E -> A as an example, the following training samples can be constructed based on trajectory data 1:
[0134] Place A, next place: Place B;
[0135] Place B, next place: Place D;
[0136] D, next location: E;
[0137] Place E, next place: Place A;
[0138] Place A -> Place B, next place: Place D;
[0139] B --> D, next location: E;
[0140] D --> E, next location: A;
[0141] A --> B --> D, next location: E;
[0142] B --> D --> E, next location: A;
[0143] Place A -> Place B -> Place D -> Place E, the next place: Place A;
[0144] The cross entropy loss function of all training samples constructed based on the trajectory data of the target object in each historical period is expressed as:
[0145]
[0146] Among them, S is the total number of samples in all training samples.
[0147] The purpose of the objective function is to minimize the cross entropy loss function of all training samples. By using stochastic gradient descent or optimizers such as Adam to optimize the objective function, the optimal weights and other parameters can be generated, for example,
[0148] Once the objective function is optimized, the weight matrix W1 can be used * Or transpose the weight matrix As a location embed parameter.
[0149] Subsequently, with the help of location embedding parameters, any trajectory data v1→v2→...→v m It can be transformed into a d×m embedding matrix (VE1...VE k ...VE m ), where VE k is the kth location v in the trajectory data k The d-dimensional location embedding vector, and VE k For W1 * With location v k The dot product of the sparse vectors, k∈[1,m].
[0150] 2. Sequential embedding representation.
[0151] Taking the trajectory data v1→v2→v4→v5→v1 as an example, the arrival order of each location in the trajectory data is 1, 2, 3, 4, 5. Then, the d-dimensional order embedding vector of the Posth location in the trajectory data (i.e., the arrival order is Pos) can be expressed as:
[0152]
[0153] Assuming d = 2, the order embedding vector of the first location in the trajectory data is The order embedding vector of the second location is
[0154] Assuming d = 4, the order embedding vector of the first location in the trajectory data is The order embedding vector of the second location is
[0155] In specific implementation, for the Pos-th arrival location v in the trajectory data k , location v k The d-dimensional trajectory vector VP pos It can be expressed as: VP pos =VE k +PE pos , where VE k For location v k The d-dimensional location embedding vector, PE pos For location v kThe corresponding arrival order Pos is the d-dimensional order embedding vector. Then, according to the order of arrival from early to late, the trajectory vectors of each point in the trajectory data are combined by column, and the obtained trajectory matrix V = (VP1, VP2, ..., VP m ) is the trajectory feature of the trajectory data, and m is the total number of locations included in the trajectory data.
[0156] The second step is to analyze the contextual relationships between locations in the trajectory data.
[0157] In specific implementation, the trajectory matrix V = (VP1, VP2, ..., VP m ) and three weight matrices W Q , W K , W U By multiplying these three weight matrices (i.e., conversion parameters) respectively, we can obtain three d×m-dimensional conversion matrices Q=(q1,q2,...,q m )、K=(k1,k2,...,k m )、U=(u1,u2,...,u m ), as shown in the following formula.
[0158]
[0159] Among them, W Q , W K , W U is the d×d dimensional weight parameter to be learned. Q, i.e. the first conversion matrix, can also be called the query matrix, K, i.e. the second conversion matrix, can also be called the key matrix, and U, i.e. the third conversion matrix, can also be called the value matrix.
[0160] Here, Q focuses on the current location in the trajectory data. The query vector corresponding to the current location in Q is multiplied by the key vectors corresponding to other locations in K to obtain the attention scores of other locations relative to the current location. K focuses on other locations, and the key vector is equivalent to the index of each location in the trajectory data. U focuses on the arrival order relationship between the current location and other locations, and the value vector is the true representation of the location. After calculating the attention score, the value vector is used for weighted summation to obtain a vector representing the context information of the current location.
[0161] To learn W Q , W K and W U , the context information of the trajectory data is modeled based on the interaction between queries, keys and values. The interaction between a location and other locations in the trajectory data can be described by the interest representation vector a, and the calculation formula of a is:
[0162]
[0163]
[0164] Among them, w i is the value vector u i The weight, q i (k i ) T For location v i The query vector q i With the key vector k i The dot product of the transpose of i is the i-th column vector in U, q i is the i-th column vector in Q, k i is the i-th column vector in K, k j is the j-th column vector in K, i,j∈[1,m].
[0165] Step 3: Predict the next location the target object will go to.
[0166] In specific implementation, the probability distribution of the target object going to each candidate location can be calculated according to the following formula:
[0167]
[0168] Among them, p(v i ) is the probability of the target object going to the i-th candidate location, a is the interest representation vector, VE i is the embedding vector of the i-th candidate location, N is the total number of all candidate locations. Generally, the candidate locations can be all the locations that the target object has reached in the selected historical period.
[0169] Then, the candidate location with the highest probability is determined as the next location that the target object will go to.
[0170] The following is an introduction to learning W Q , W K and W U process.
[0171] In specific implementation, all locations before the current location in the trajectory data can be used as input, the location after the current location can be used as the tag value, and the location with the largest probability value obtained using the above formula can be used as the predicted value. Q , W K and W U When the weight matrix W Q , W K and W U Initialized to random values.
[0172] Take the trajectory data v1→v2→v4→v5→v1 of the target object on a certain day as an example. The first four locations are used as input and the fifth location is used as a marker. Then, the trajectory matrix is V = (VE1+PE1, VE2+PE2, VE4+PE3, VE5+PE4), and the query matrix Q = W Q V, key weight K = W K V, value matrix U = W U V, Interest Representation Vector The next location of the trajectory sequence is actually v1, represented by Y = (1, 0, 0, 0, 0).
[0173] The next location of the trajectory sequence calculated based on the above formula is v i The probability of p(v i ),i∈[1,5], record Based on the initialized weight matrix W Q , W K and W U , the output of this self-attention model is The error with the actual result Y can be expressed as cross entropy:
[0174] After that, the cross entropy loss function can be used as the objective function of model training. The objective function is shown in the following formula:
[0175]
[0176] Among them, S is the total number of samples in the training sample set, s is the sth trajectory (training sample), and n is the total number of locations. The optimization goal is to minimize the cross entropy loss function.
[0177] Then, an optimizer such as Adam can be used to optimize the objective function, thereby generating the optimal weight matrix
[0178] In addition, based on the trajectory data of multiple target objects in different periods, the social relationships between the target objects can also be discovered, so that managers can better provide elderly care services for the target objects based on the social relationships between the target objects. Based on the trajectory data of the same target object in different periods, the identity of the target object can also be identified. In this way, the identity of the target object is identified based on insensitive data, and the privacy data of the target object is protected. Based on the trajectory data of the same target object in different periods, the abnormal trajectory of the target object can also be discovered. In this way, the abnormal behavior of the target object can be known in advance to prevent the loss of the target object (such as disabled or demented people).
[0179] Based on the same technical concept, the embodiment of the present application also provides a trajectory prediction device. The principle of solving the problem by the trajectory prediction device is similar to that of the above-mentioned trajectory prediction method. Therefore, the implementation of the trajectory prediction device can refer to the implementation of the trajectory prediction method, and the repeated parts will not be repeated. Figure 8 A schematic diagram of the structure of a trajectory prediction device provided in an embodiment of the present application includes an acquisition module 801, a feature analysis module 802, a conversion module 803, an interest analysis module 804, and a determination module 805.
[0180] An acquisition module 801 is used to acquire trajectory data of a target object in a current cycle, wherein the trajectory data includes locations reached by the target object and an arrival order of the locations;
[0181] A feature analysis module 802 is used to perform feature analysis on the trajectory data to obtain trajectory features;
[0182] A conversion module 803 is used to convert the trajectory feature based on a weight parameter to obtain a conversion feature, wherein the weight parameter is obtained by learning the relationship between the trajectory feature and the conversion feature of the trajectory data of the target object in a historical period;
[0183] An interest analysis module 804 is used to analyze the interest of the target object in traveling to each candidate location based on the conversion feature;
[0184] The determination module 805 is used to determine the location where the target object will go based on the interest analysis result.
[0185] In some embodiments, the feature analysis module 802 is specifically used to:
[0186] Based on predetermined location embedding parameters, generating a location embedding vector for each location reached by the target object;
[0187] generating an order embedding vector for the location based on a predetermined order embedding parameter;
[0188] Fusing the location embedding vector and the order vector to obtain a trajectory vector of the location;
[0189] The trajectory vectors of each location are combined in the order of arrival, and the combined trajectory matrix is used as the trajectory feature.
[0190] In some embodiments, the weight parameters include a first weight matrix, a second weight matrix and a third weight matrix, and the conversion module 803 is specifically used for:
[0191] Performing a transformation process on the trajectory matrix based on the first weight matrix to obtain a first transformation matrix;
[0192] Performing a transformation process on the trajectory matrix based on the second weight matrix to obtain a second transformation matrix;
[0193] Performing a transformation process on the trajectory matrix based on the third weight matrix to obtain a third transformation matrix;
[0194] The first conversion matrix, the second conversion matrix and the third conversion matrix are used as the conversion features.
[0195] In some embodiments, the interest analysis module 804 is specifically used to:
[0196] Determining weights of locations reached by the target object based on the first conversion matrix and the second conversion matrix;
[0197] Based on the weights of the locations reached by the target object, a weighted sum is performed on the column vectors in the third transformation matrix to obtain an interest representation vector.
[0198] In some embodiments, the interest analysis module 804 is specifically used to determine the weight w of the i-th location reached by the target object according to the following formula: i :
[0199]
[0200] Among them, q i is the i-th column vector in the first transformation matrix, k i is the i-th column vector in the second transformation matrix, k j is the jth column vector in the second transformation matrix, d is the number of rows in the trajectory matrix, m is the total number of locations reached by the target object, and i and j are both integers.
[0201] In some embodiments, the determining module 805 is specifically used to:
[0202] Based on the interest representation vector and the embedding vector of each candidate location, determining the probability of the target object going to each candidate location, each candidate location is determined according to the location that the target object has visited in a historical period;
[0203] The candidate location with the highest probability is determined as the location to which the target object will go.
[0204] In some embodiments, the determination module 805 is specifically configured to determine the probability p(v) that the target object goes to the cth candidate location according to the following formula: c ):
[0205]
[0206] Among them, vc is the cth candidate location, a is the interest representation vector, VE c is the embedding vector of the cth candidate location, VE l is the embedding vector of the lth candidate location, N is the total number of candidate locations, and c and l are both integers.
[0207] The division of modules in the embodiments of the present application is schematic and is only a logical function division. There may be other division methods in actual implementation. In addition, the functional modules in the embodiments of the present application may be integrated in a processor, or may exist physically separately, or two or more modules may be integrated in one module. The coupling between the modules may be achieved through some interfaces, which are usually electrical communication interfaces, but it is not excluded that they may be mechanical interfaces or other forms of interfaces. Therefore, the modules described as separate components may or may not be physically separated, and may be located in one place or distributed to different locations of the same or different devices. The above-mentioned integrated modules may be implemented in the form of hardware or in the form of software functional modules.
[0208] Fig. 9 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application, the electronic device includes a transceiver 901 and a physical device such as a processor 902, wherein the processor 902 can be a central processing unit (CPU), a microprocessor, a dedicated integrated circuit, a programmable logic circuit, a large-scale integrated circuit, or a digital processing unit, etc. The transceiver 901 is used for electronic devices and other devices to transmit and receive data.
[0209] The electronic device may also include a memory 903 for storing software instructions executed by the processor 902, and of course, some other data required by the electronic device may also be stored, such as identification information of the electronic device, encryption information of the electronic device, user data, etc. The memory 903 may be a volatile memory, such as a random access memory (RAM); the memory 903 may also be a non-volatile memory, such as a read-only memory (ROM), a flash memory, a hard disk drive (HDD) or a solid-state drive (SSD), or the memory 903 may be any other medium that can be used to carry or store the desired program code in the form of an instruction or data structure and can be accessed by a computer, but is not limited thereto. The memory 903 may be a combination of the above memories.
[0210] The specific connection medium between the processor 902, the memory 903 and the transceiver 901 is not limited in the embodiment of the present application. Fig. 9 In the example, the memory 903, the processor 902 and the transceiver 901 are connected via the bus 904. Fig. 9 The connections between the other components are shown in bold lines, which are only for illustration and are not intended to be limiting. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Fig. 9 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0211] The processor 902 may be dedicated hardware or a processor that runs software. When the processor 902 can run software, the processor 902 reads the software instructions stored in the memory 903 and, driven by the software instructions, executes the trajectory prediction method involved in the aforementioned embodiment.
[0212] An embodiment of the present application further provides a storage medium. When instructions in the storage medium are executed by a processor of an electronic device, the electronic device can execute the trajectory prediction method involved in the aforementioned embodiment.
[0213] In some possible implementations, various aspects of the trajectory prediction method provided in the present application may also be implemented in the form of a program product, wherein the program product includes a program code. When the program product is run on an electronic device, the program code is used to enable the electronic device to execute the trajectory prediction method involved in the aforementioned embodiment.
[0214] The program product may adopt any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a RAM, a ROM, an erasable programmable read-only memory (EPROM), a flash memory, an optical fiber, a compact disk read only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.
[0215] The program product for trajectory prediction in the embodiment of the present application may adopt a CD-ROM and include program code, and may be run on a computing device. However, the program product of the present application is not limited thereto, and in this document, a readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, apparatus, or device.
[0216] The readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, wherein the readable program code is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The readable signal medium may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0217] The program code contained on the readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wired, optical cable, radio frequency (RF), etc., or any suitable combination of the foregoing.
[0218] Program code for performing the operations of the present application may be written in any combination of one or more programming languages, including object-oriented programming languages such as Java, C++, etc., and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In the case of a remote computing device, the remote computing device may be connected to the user computing device via any type of network such as a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (e.g., via the Internet using an Internet service provider).
[0219] It should be noted that, although several units or subunits of the device are mentioned in the above detailed description, this division is merely exemplary and not mandatory. In fact, according to the embodiments of the present application, the features and functions of two or more units described above can be embodied in one unit. Conversely, the features and functions of one unit described above can be further divided into multiple units to be embodied.
[0220] In addition, although the operations of the method of the present application are described in a specific order in the drawings, this does not require or imply that the operations must be performed in this specific order, or that all the operations shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps.
[0221] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0222] The present application is described with reference to the flowcharts and / or block diagrams of the methods, apparatus (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0223] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0224] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0225] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications falling within the scope of the present application.
[0226] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.
Claims
1. A trajectory prediction method, characterized in that: include: Acquire trajectory data of the target object in the current cycle, the trajectory data including the locations reached by the target object and the order of arrival of the locations; Performing feature analysis on the trajectory data to obtain trajectory features, wherein the trajectory features are represented as a trajectory matrix; The trajectory feature is converted based on a weight parameter to obtain a conversion feature, wherein the weight parameter is obtained by learning the relationship between the trajectory feature and the conversion feature of the trajectory data of the target object in a historical period; Analyzing the target object's interest in visiting each candidate location based on the obtained conversion features; Based on the interest analysis result, determining the location that the target object will go to; The weight parameters include a first weight matrix, a second weight matrix, and a third weight matrix. The trajectory features are converted based on the weight parameters to obtain conversion features, including: Performing a transformation process on the trajectory matrix based on the first weight matrix to obtain a first transformation matrix; Performing a transformation process on the trajectory matrix based on the second weight matrix to obtain a second transformation matrix; Performing a transformation process on the trajectory matrix based on the third weight matrix to obtain a third transformation matrix; using the first conversion matrix, the second conversion matrix and the third conversion matrix as the conversion features; Based on the conversion features, the target object's interest in visiting each candidate location is analyzed, including: Determining weights of locations reached by the target object based on the first conversion matrix and the second conversion matrix; Based on the weights of the locations reached by the target object, a weighted sum is performed on the column vectors in the third transformation matrix to obtain an interest representation vector.
2. The method according to claim 1, characterized in that Performing feature analysis on the trajectory data to obtain trajectory features includes: Based on predetermined location embedding parameters, generating a location embedding vector for each location reached by the target object; generating an order embedding vector for the location based on a predetermined order embedding parameter; Fusing the location embedding vector and the order embedding vector to obtain a trajectory vector of the location; The trajectory vectors of each location are combined according to the arrival order, and the combined trajectory matrix is used as the trajectory feature.
3. The method according to claim 1, characterized in that The weight w of the i-th location reached by the target object is determined according to the following formula: i : Among them, q i is the i-th column vector in the first transformation matrix, k i is the i-th column vector in the second transformation matrix, k j is the jth column vector in the second transformation matrix, d is the number of rows in the trajectory matrix, m is the total number of locations reached by the target object, and i and j are both integers.
4. The method according to claim 1, characterized in that Based on the interest analysis results, determine the location that the target object will go to, including: Based on the interest representation vector and the embedding vector of each candidate location, determining the probability of the target object going to each candidate location, each candidate location is determined according to the location that the target object has visited in a historical period; The candidate location with the highest probability is determined as the location to which the target object will go.
5. The method according to claim 4, characterized in that The probability p(v c ): Among them, v c is the cth candidate location, a is the interest representation vector, VE c is the embedding vector of the cth candidate location, VE l is the embedding vector of the lth candidate location, N is the total number of candidate locations, and c and l are both integers.
6. A trajectory prediction device, characterized in that: include: An acquisition module, used to acquire trajectory data of a target object in a current cycle, wherein the trajectory data includes locations arrived at by the target object and an arrival order of the locations; A feature analysis module, used for performing feature analysis on the trajectory data to obtain trajectory features, wherein the trajectory features are represented as a trajectory matrix; A conversion module, used for converting the trajectory features based on weight parameters to obtain conversion features, wherein the weight parameters are obtained by learning the relationship between the trajectory features and the conversion features of the trajectory data of the target object in a historical period; An interest analysis module, used for analyzing the interest of the target object in traveling to each candidate location based on the obtained conversion features; A determination module, used to determine the location that the target object will go to based on the interest analysis result; The weight parameters include a first weight matrix, a second weight matrix and a third weight matrix; The conversion module is specifically used to convert the trajectory matrix based on the first weight matrix to obtain a first conversion matrix; convert the trajectory matrix based on the second weight matrix to obtain a second conversion matrix; convert the trajectory matrix based on the third weight matrix to obtain a third conversion matrix; use the first conversion matrix, the second conversion matrix and the third conversion matrix as the conversion features; The interest analysis module is specifically used to determine the weights of each location reached by the target object based on the first transformation matrix and the second transformation matrix; based on the weights of each location reached by the target object, weighted summation is performed on the column vectors in the third transformation matrix to obtain an interest representation vector.
7. An electronic device, characterized in that: include: at least one processor, and a memory communicatively connected to the at least one processor, wherein: The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can perform the method according to any one of claims 1 to 5.
8. A storage medium, characterized in that: When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device can execute the method as claimed in any one of claims 1 to 5.
Citation Information
Patent Citations
Trajectory prediction method and device, electronic equipment and medium
CN111401233A
Trajectory data enhancement and trajectory identification method based on embedding-mixing
CN112949628A
Interest point analysis method and device
CN113033560A
