Geographical knowledge graph link prediction method based on entity semantic similarity and clustering combined with negative sampling
Patent Information
- Application Number
- CN202410872124.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-01
- Publication Date
- 2026-10-30
- Estimated Expiration
- 2044-07-01
AI Technical Summary
然而,采用随机采样方法生成的负例三元组并不理想,因为随机采样方法选择的替换实体往往与正例三元组中的另一实体没有明显的关联,这导致生成的负例三元组在地理知识图谱中可能缺乏合理的语义关系,从而降低了负例三元组的质量
1)本发明提出从地理矢量图中如何抽取符合地理知识元组表示框架的三元组数据,并构建出地理三元组数据集;
Smart Images

Figure CN118966326B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of geographic knowledge graphs, specifically to a method for predicting geographic knowledge graph links based on negative sampling that combines entity semantic similarity and clustering. Background Technology
[0002] In geographic information science, geographic knowledge is typically represented based on location features and relationships between locations. With the development of big data and geospatial intelligence, the generation of massive amounts of spatiotemporal information is accompanied by greater complexity and diversity, leading to sparsity and incompleteness in geographic knowledge, posing new challenges to location representation. As an emerging method for large-scale structured knowledge modeling, geographic knowledge graphs offer a new approach to formally organizing geographic knowledge, with triples being a common representation. Knowledge graph embedding representation models map entities and relationships in the knowledge graph to a low-dimensional continuous numerical vector space. This representation makes high-dimensional, sparse graph-structured data more suitable for machine learning algorithms, facilitating tasks such as representation learning and link prediction.
[0003] Geographic knowledge graphs are organized in the form of triples based solely on known facts, meaning the dataset contains only positive samples. Therefore, it is necessary to generate negative samples for each positive sample to measure the model loss during knowledge graph representation learning training. Negative sampling is a key step in knowledge graph embedding representation models. By generating negative triples, it improves the model's discriminative ability, enabling the knowledge graph embedding model to better capture the semantic associations of entities and relationships.
[0004] Random sampling is currently the most widely used method in geographic knowledge graph representation learning. Its core idea is to delete the head or tail entity from positive triples and then randomly select an entity from the entity set in a uniform distribution to replace the deleted entity, thus constructing negative triples. However, negative triples generated using random sampling are not ideal because the replacement entity often has no clear connection with the other entity in the positive triple. This leads to the generated negative triples potentially lacking reasonable semantic relationships in the geographic knowledge graph, thereby reducing the quality of the negative triples. Summary of the Invention
[0005] To address the aforementioned technical problems, this invention provides a method for predicting links in a geographic knowledge graph based on negative sampling combined with entity semantic similarity and clustering. This invention creatively proposes a method for extracting triple data that conforms to the geographic knowledge tuple representation framework from geographic vector maps, and optimizes the TransE model to form a geographic knowledge graph embedding GKTransE model. The GKTransE model constructs a geographic knowledge fusion engine to extract the semantic information of geographic entities from the triples, completing the initialization of the model's entity vectors. Simultaneously, in the negative sampling part, it calls the K-Means algorithm to implement a dynamic negative sample generation strategy, effectively expanding the expressive power of the geographic knowledge graph.
[0006] The technical solution adopted in this invention is as follows: A method for predicting links in a geographic knowledge graph based on negative sampling combining entity semantic similarity and clustering includes the following steps: Step 1: Propose a geographic knowledge tuple representation framework to realize a structured representation of geographic entities, their attributes, and the relationships between entities; Step 2: Obtain geographic vector map. Use the ArcGIS platform to extract the geographic data from the geographic vector map in a structured manner and import the geographic data into the Neo4j graph database. Export the geographic data in the form of triples and clean it to obtain geographic triple data, also known as positive triples. Step 3: Construct a knowledge fusion engine to extract the semantic information of geographic entities in the triples and complete the initialization of entity vectors for embedding the geographic knowledge graph into the GKTransE model; Step 4: Call the K-Means algorithm to divide the entities into multiple clusters based on their semantic information. During negative sampling, other entities in the same cluster as the entity being replaced will be randomly selected as negative entities to construct negative triplets. Step 5: Combine the knowledge fusion machine and perform batch training on positive and negative triples to update the vectors, thereby improving the expressive power of the geographic knowledge graph embedding. Step 6: Predict the missing entities based on the known entity information in the triples, completing the link prediction task in the Geographic Knowledge Graph Embedding GKTransE model. Specifically, for the triples... Predict the missing entity h; for triples Predict the missing entity t.
[0007] In step 1, the geographic knowledge tuple representation framework is as follows:
[0008]
[0009] in: A knowledge tuple representation model for geographic entities and their attributes; E Represents geographic entities; S V represents entity attributes; V represents attribute values. A knowledge tuple representation model for two different geographic entities. E 1 represents a geographic head entity. E 2 represents a geographic tail entity. R It represents the relationship between two entities.
[0010] Step 2 includes the following steps: S21. Open the geographic vector map in the ArcGIS platform, representing place names as points or lines, and view the multiple attributes of the place name and their corresponding attribute values.
[0011] S22. To calculate the distance between points in a geographic vector map, the Euclidean distance between two points can be calculated, and a corresponding threshold can be given to determine the proximity between the two points. The expression is as follows:
[0012] in, and The coordinates of latitude and longitude of the two place names are represented respectively. The distance relationship is obtained by comparing the Euclidean distance with multiple thresholds. The distance relationships include: very close within the city, close within the city, very far within the city, very close between the city, close between the city, far between the city, and very far between the city.
[0013] S23. Based on the midpoint of the geographic vector map With point The azimuth angle between the two points determines their directional relationship. There are eight directional relationships: East, Northeast, North, Northwest, West, Southwest, South, and Southeast. Figure 2 As shown. Distance and orientation relationships are combined to form the spatial relationships between entities; Among them, the angle range for the north direction is 337.5-22.5, with a central angle of 0; the angle range for the northeast direction is 22.5-67.5, with an angle of 45, and so on for other directions.
[0014]
[0015]
[0016]
[0017]
[0018] The above formula first calculates the difference between the latitude and longitude of the two points, denoted by delta_x and delta_y respectively. Then, it calculates the radians by calling the built-in function of atan2 in mathematics. Finally, it converts the radians to degrees and ensures that the result is between 0 and 360 degrees.
[0019]
[0020]
[0021] according to directions [ index This gives us the direction of point A from point B. Since each direction has a range of 48 degrees, to ensure the angle is correctly mapped to the direction, we add a 22.5-degree offset so that the center angle of each direction falls in the middle of the range. Dividing the adjusted angle by 45 and rounding down will map each 45-degree range to an integer between 0 and 7. Then, we use modulo arithmetic to get the index of the direction and determine the direction.
[0022] S24. Export the attribute information contained in each entity and its spatial information with other entities in a table format. Each column in the table represents an attribute relationship or a spatial relationship. S25. Use the Py2neo package to store the table in the Neo4j graph database, and then read the entities and relations from the Neo4j graph database and convert them into geographic triples data. For example... Figure 3 As shown, Figure 3 The image shows a Neo4j visualization of some of the data. Figure 3 The left side shows the labels and relationship types of the entities, while the center shows a graph formed by the connections between multiple entities through relationships.
[0023] In step 3 For the entities in the triplet, the FastText model is called to obtain the entity vector, and the entity vector initialization is completed. For the relations in the triplet, the FastText model is called to obtain the relation vector, and the relation vector initialization is completed.
[0024] In step 4, K objects are randomly selected from the N entity datasets as initial cluster centers. The distance from each entity point to the cluster center is calculated, and they are assigned to the nearest cluster one by one. After all entities have been assigned, the positions of the K cluster centers are updated.
[0025] Compare the K cluster centers calculated in the previous step with the current cluster centers. If the cluster centers have changed, return to the step of calculating the distance from each entity point to the cluster center; otherwise, output the clustering results.
[0026] The K-means algorithm is used to divide N entities into K clusters to minimize the Euclidean distance between each entity and its cluster center. The expression is as follows:
[0027] in, K Indicates the number of clusters. e Represents an entity vector. c i Indicates the first i The center vectors of the clusters, C i This represents the aggregation of entity e in the i-th cluster. L 2 is the Euclidean distance of the second norm; In step 4, when the geographic knowledge graph embedding model GKTransE performs negative sampling, it randomly selects other entities in the cluster where the replaced entity is located as negative examples and generates negative example triples.
[0028] Step 5 includes the following steps: S51. Read the entity and relation information from the constructed geographic triplet data, initialize the entity and relation tensors using the knowledge fusion tool, and then process each row of the tensors. L 2. Normalization; S52. When training the GKTransE model, batch training is used. K-means partitioning is called in each training session to divide the entities into multiple clusters. During negative sampling, the random function is called. If the value is less than 0.5, the head entity of the positive triplet is replaced to generate the negative triplet; otherwise, the tail entity is replaced. The S53 and GKTransE models calculate the loss by calling a function based on the tensors corresponding to the positive and negative triplet pairs, and then perform backpropagation on the loss function to update the parameters and minimize the loss function.
[0029] The training algorithm for the GKTransE model is as follows:
[0030] Step 6 includes the following steps: S61, Test set triplet ( h , r , t The missing entity h or t in the test triplet is called the correct entity, and the other entities are called candidate entities. The candidate entities are used to replace the entities h or t in the test triplet in turn to form a set of candidate triplets. S62. Calculate the score for each candidate triplet and the correct triplet using a scoring function; the GKTransE model employs...
[0031] The translation principle embeds entities and relations into the same vector space; therefore, the scoring function is defined as:
[0032] in, Represents a triplet The score is calculated by adding the relation vector r to the head entity vector h and then subtracting the L1 norm of the tail entity vector t.
[0033] S63. Call the sort function to record the sorting of correct triples. Based on the sorting values of correct triples in each test set, calculate the GKTransE model evaluation index to provide a quantitative analysis of the model's performance.
[0034] Specifically, in the evaluation process of the link prediction task, for each test tuple in the test set T... The remaining entities in the entity set are used to replace its head entity in turn to generate... And calculate the score. Alternatively, replace the tail entity sequentially to generate... Calculate the score ; Ranking of correct samples among all test samples after replacing the head entity. And, in all test samples after replacing the tail entity, the ranking of the correct samples' scores. It is defined by the following form:
[0035]
[0036] Among them, II ( ) is an indicator function; if the condition is true, the function value is 1, otherwise it is 0; T represents the test set. This represents a triplet in the test set. Indicates replacement Negative triples generated by the middle-head entity This indicates that the score function was used for calculation. The score, This indicates that the score function was used for calculation. The fraction. Similarly, Indicates replacement Negative triplets generated by mid-tail entities.
[0037] The most commonly used evaluation metrics for the performance of knowledge graph embedding models are: Mean Reciprocal Ranking MRR Mean Rank MR ) and the hit rate for ranks less than n ( Hits@n The three indicators are defined as follows:
[0038]
[0039]
[0040] in, T It is a test set of triples. i It is the number of sets of triples. It is to replace the head entity to generate the first i Link prediction ranking for triples It is a link prediction ranking that replaces the tail entity to generate the i-th triplet. MRR It is the average of the scores of the last two positive tuples in the test triplet set. The higher the value of the indicator, the better, indicating that the ranking is consistent with the actual situation. MR It is the average score ranking of predicted positive example tuples. The smaller the value of this indicator, the better. The smaller the predicted value, the higher the accuracy of the model. Hits@n This refers to a ranking less than or equal to in link prediction. n The average percentage of triples, Hit@n The higher the indicator, the better. n Taking 10 is the most common choice.
[0041] This invention presents a method for predicting links in a geographic knowledge graph based on negative sampling combined with entity semantic similarity and clustering. The technical effects are as follows: 1) This invention proposes a method for extracting triple data that conforms to the geographic knowledge tuple representation framework from geographic vector maps and constructing a geographic triple dataset; 2) This invention proposes a knowledge fusion device that extracts semantic information of entity and relation data in geographic triples, completes the initialization of entity relation vectors in the geographic knowledge graph embedding model GKTransE, thereby improving the expressive power of the model; 3) This invention proposes a negative sampling method based on semantic similarity. The K-Means algorithm is called in the negative sampling part, which can more accurately capture entities with similar semantics and effectively improve the diversity and quality of negative samples.
[0042] 4) This invention introduces entity semantic information, and for the first time integrates entity semantic information into the geographic knowledge graph embedding task. By utilizing the semantic features of entities, it effectively expands the expressive power of the geographic knowledge graph and achieves significant performance improvement in the link prediction task. Attached Figure Description
[0043] The present invention will be further described below with reference to the accompanying drawings and examples; Figure 1 This is a flowchart of the prediction method of the present invention.
[0044] Figure 2 This is a diagram illustrating the orientation relationship.
[0045] Figure 3 A visualization of Neo4j.
[0046] Figure 4 This is a vector diagram of the water system. Detailed Implementation
[0047] like Figure 1 As shown, this invention provides a method for predicting links in a geographic knowledge graph based on negative sampling combining entity semantic similarity and clustering, comprising the following steps: S1: Propose a geographic knowledge tuple representation framework to realize a structured representation of geographic entities, their attributes, and the relationships between entities; Specifically, the geographic knowledge tuple representation framework is primarily used to structure and represent geographic information for better storage of geographic data. Geographic entities are the basic components of geographic knowledge tuples; common geographic entities include cities, roads, and rivers. Each geographic entity has a set of attribute information describing its specific characteristics, such as name, coordinates, and category. Geographic relationships describe the spatial relationships between geographic entities; common geographic relationships mainly include topological relationships, directional relationships, and distance relationships. Therefore, the knowledge tuple representation framework considers two aspects: the triple representation of geographic entities and their attributes, and the triple representation of relationships between entities.
[0048] Furthermore, the knowledge tuple representation framework describing geographic entities, their attributes, and the relationships between entities is as follows:
[0049]
[0050] in, A knowledge tuple representation model for representing geographic entities and their attributes. E Representing geographic entities, S V represents entity attributes, and V represents attribute values. A knowledge tuple representation model for two different geographic entities. E 1 represents a geographic head entity. E 2 represents a geographic tail entity. R It represents the relationship between two entities.
[0051] S2: Obtain geographic vector maps, extract the geographic data in a structured manner through the ArcGIS platform, import the data into the Neo4j graph database, export the data in triplet form and clean it to obtain geographic triplet data; Specifically, geographic vector maps are a commonly used data representation method in Geographic Information Systems (GIS), containing rich geographic information. Vector maps represent geographic entities and their attribute information through sets of shape points and lines. Spatial relationships between entities can be determined in ArcGIS.
[0052] As a preferred implementation method, step S2 specifically includes: S21. Open the geographic vector map in ArcGIS. The place names in the map are represented by points. View the multiple attributes of the place name and their corresponding attribute values. S22. To calculate the distance between points in a geographic vector map, the Euclidean distance between two points can be calculated, and a corresponding threshold can be given to determine the proximity between the two points. The expression is as follows:
[0053] in, and The latitude and longitude coordinates of the two place names are represented respectively. The distance relationship is obtained by comparing the Euclidean distance with multiple thresholds. S23. Based on the azimuth values between points in the vector map, determine the directional relationship between the place names represented by two points. Combine the distance relationship and the directional relationship to form the spatial relationship between entities. S24. Export the attribute information contained in each entity and its spatial information with other entities in a table format. Each column in the table represents an attribute relationship or a spatial relationship. S25. Use the Py2neo package to store the table in the graph database Neo4j, and then read the nodes and relationships from the graph database and convert them into geographic triples.
[0054] S3: Construct a knowledge fusion engine to extract the semantic information of geographic entities in triples and complete the entity vector initialization of the geographic knowledge graph embedding model GKTransE; Specifically, in knowledge graph embedding models, entity vectorization is initialized by calling the `Embedding` function, which accepts two hyperparameters: the number of entities and the length of the embedding vector, thus generating a fixed-length vector for each entity. However, pre-trained word embedding models learn richer representations from large-scale corpora, focusing not only on the surface meaning of entity words but also delving into the rich semantic structures hidden in the language. This gives the model a higher level of language understanding, which is crucial for the complex semantic relationships between entities in knowledge graphs.
[0055] Furthermore, the FastText model itself has low complexity, which speeds up training while maintaining high accuracy. At the same time, the model performs well in handling low-frequency generated word vectors, effectively addressing the situation where the cleaned dataset still contains scattered entities.
[0056] As a preferred implementation method, step S3 specifically includes: S31. For entities in the triplet, call the FastText model to obtain entity vectors and complete entity vector initialization; S32. For the relations in the triplet, call the FastText model to obtain the relation vector and complete the relation vector initialization.
[0057] S4: Call the K-Means algorithm to divide the entities into multiple clusters based on semantic information. During negative sampling, other entities in the same cluster as the entity being replaced will be randomly selected as negative entities to construct negative triplets. As a preferred implementation method, step S4 specifically includes: S41. Randomly select K objects from the N entity dataset as initial cluster centers. Calculate the distance from each entity point to a cluster center and assign them to the nearest cluster one by one. After all entities have been assigned, update the positions of the K cluster centers. Compare the K cluster centers calculated in the previous step with the current cluster centers. If the cluster centers have changed, return to the step of calculating the distance from each entity point to a cluster center; otherwise, output the clustering results.
[0058] The goal is to divide N entities into K clusters, minimizing the Euclidean distance between each entity and its cluster center, expressed as:
[0059] in, K Indicates the number of clusters. e Represents an entity vector. c i Indicates the first i The center vectors of the clusters, C i This represents the aggregation of entity e in the i-th cluster. L 2 is the Euclidean distance of the second norm; S42. When the geographic knowledge graph embedding model GKTransE performs negative sampling, it randomly selects other entities in the cluster where the replaced entity is located as negative examples and generates negative example triples.
[0060] S5: By combining a knowledge fusion engine and performing batch training on positive and negative triplets, vector updates are achieved, thereby improving the expressive power of knowledge graph embedding. Specifically, given a geographical knowledge graph ,in This indicates that the geographical knowledge graph contains N A collection of entities. This indicates that the geographical knowledge graph contains M A set of relations of a relation. This represents a triple in a geographical knowledge graph. h For the head entity, r For the relationship, t The tail entity. The GKTransE model uses... The translation principle embeds entities and relations into the same vector space; therefore, the scoring function is defined as:
[0061] in, f (h,r,t) represents the score of the triple (h,r,t). This scoring function calculates the score by analyzing the head entity vector. h Add relation vectors r Subtract the tail entity vector t The L1 norm is used to evaluate the reasonableness of triples. A smaller score indicates a more reasonable triple. The optimization objective is to minimize the score of positive triples and maximize the score of negative triples. Therefore, the loss function can be derived as:
[0062] The above formula L Let (h,r,t) represent the loss of the entire model, (h',r,t') represent positive triples, and (h',r,t') represent negative triples. S It is the set of positive triples. It is a set of negative triples, which are formed by comparing the head entities of positive triples. h or tail entity t The result was obtained by substitution. This represents a hyperparameter used to set the minimum difference between the scores of positive triples and negative triples, while the Adam optimizer is used to update the model's parameters during training.
[0063] Furthermore, the GKTransE algorithm first reads data from the dataset and defines some hyperparameters to input into the model. Then, it calls the FastText model to initialize the entity and relation vectors, followed by regularization of the vectors to prevent overfitting. In the recurrent part, batch processing is used, extracting b triples of size b from the dataset S for training each time. Then, the K-Means algorithm is called to create an entity dictionary, associating entity IDs with their cluster labels. Negative triples are generated by replacing other entities in the same cluster, and the dataset is updated. After the loop ends, the loss is calculated, and the entity and relation vectors are updated.
[0064] As a preferred implementation method, step S5 specifically includes: S51. Read the entity and relation information from the dataset, initialize the entity tensor and relation tensor using the knowledge fusion tool, and then process each row of the tensor. L 2. Normalization; S52. Batch training is used during GKTransE model training. K-means partitioning is called during each training iteration to divide entities into multiple clusters. During negative sampling, the random function is called. If the value is less than 0.5, the head entity of the positive triplet is replaced to generate a negative triplet; otherwise, the tail entity is replaced. S53. The model calls a function to calculate the model loss based on the tensors corresponding to the positive and negative triplet pairs, and then performs backpropagation on the loss function to update the model parameters and minimize the loss function.
[0065] S6: Predict the missing entity based on the known entity information in the triples, and complete the link prediction task in the knowledge graph embedding model.
[0066] As a preferred implementation method, step S6 specifically includes: S61, Test set triplet ( h , r , t The missing entity h (or t) in the test triplet is called the correct entity, and the other entities are called candidate entities. The candidate entities are used to replace entities h or t in the test triplet in turn to form a set of candidate triplets. S62. Calculate the score for each candidate triplet and the correct triplet using the scoring function.
[0067] S63. Call the sort function to record the sorting of correct triples. Calculate the model evaluation index based on the sorting values of correct triples in each test set to provide a quantitative analysis of the model performance.
[0068] Specifically, in the evaluation process of the link prediction task, for each test tuple in the test set T... The remaining entities in the entity set are used to replace its head entity in turn to generate... And calculate the score. Alternatively, replace the tail entity sequentially to generate... Calculate the score ; Ranking of correct samples among all test samples after replacing the head entity. And, in all test samples after replacing the tail entity, the ranking of the correct samples' scores. It is defined by the following form:
[0069]
[0070] Among them, II ( ) is an indicator function. If the condition is true, the function value is 1; otherwise, it is 0.
[0071] The most commonly used evaluation metrics for the performance of knowledge graph embedding models are: Mean Reciprocal Ranking, MRR Mean Rank MR ) and the hit rate for ranks less than n ( Hits@n The three indicators are defined as follows:
[0072]
[0073]
[0074] in, T It is a test set of triples. i It is the number of sets of triples. It is to replace the head entity to generate the first i Link prediction ranking for triples It is the link prediction ranking for generating the i-th triple by replacing the tail entity. MRR It is the average of the scores of the last two positive tuples in the test triplet set. The higher the value of the indicator, the better, indicating that the ranking is consistent with the actual situation. MR It is the average score ranking of predicted positive example tuples. The smaller the value of this indicator, the better. The smaller the predicted value, the higher the accuracy of the model. Hits@n This refers to a ranking less than or equal to in link prediction. n The average percentage of triples, Hit@n The higher the indicator, the better. n Taking 10 is the most common choice.
Claims
1. A method for predicting links in a geographic knowledge graph based on negative sampling combining entity semantic similarity and clustering, characterized in that... Includes the following steps: Step 1: Propose a geographic knowledge tuple representation framework to realize a structured representation of geographic entities, their attributes, and the relationships between entities; Step 2: Obtain the geographic vector map, perform structured extraction on the geographic data of the geographic vector map, import the geographic data into the graph database, export the geographic data in the form of triples and clean it to obtain geographic triple data, also known as positive triples. Step 3: Construct a knowledge fusion engine to extract the semantic information of geographic entities in the triples and complete the initialization of entity vectors for embedding the geographic knowledge graph into the GKTransE model; Step 4: Call the K-Means algorithm to divide the entities into multiple clusters based on their semantic information. During negative sampling, other entities in the same cluster as the entity being replaced will be randomly selected as negative entities to construct negative triplets. Step 5: Combine the knowledge fusion machine and perform batch training on positive and negative triplet pairs; Step 6: Predict the missing entities based on the known entity information in the triples, and complete the link prediction task in embedding the geographic knowledge graph into the GKTransE model; In step 3, for entities in a triplet, the FastText model is called to obtain entity vectors, and entity vector initialization is completed; for relations in a triplet, the FastText model is called to obtain relation vectors, and relation vector initialization is completed. Step 6 includes the following steps: S61: Test set triples ( h , r , t The missing entity h or t in the test triplet is called the correct entity, and the other entities are called candidate entities. The candidate entities are used to replace the entities h or t in the test triplet in turn to form a set of candidate triplets. S62: Calculate the score for each candidate triplet and the correct triplet using a scoring function; the GKTransE model employs... The translation principle embeds entities and relations into the same vector space; therefore, the scoring function is defined as: ; in, Represents a triplet The score is calculated by adding the relation vector r to the head entity vector h and then subtracting the L1 norm of the tail entity vector t. S63: Call the sort function to record the sorting of the correct triples. Based on the sorting values of the correct triples in each test set, calculate the GKTransE model evaluation index to provide a quantitative analysis of the model's performance. Specifically, in the evaluation process of the link prediction task, for each test tuple in the test set T... The remaining entities in the entity set are used to replace its head entity in turn to generate... And calculate the score. Alternatively, replace the tail entity sequentially to generate... Calculate the score ; Ranking of correct samples among all test samples after replacing the head entity. And, in all test samples after replacing the tail entity, the ranking of the correct samples' scores. It is defined by the following form: ; ; Among them, II ( ) is an indicator function; if the condition is true, the function value is 1, otherwise it is 0; T represents the test set. This represents a triplet in the test set. Indicates replacement Negative triples generated by the middle-head entity This indicates that the score function was used for calculation. The score, This indicates that the score function was used for calculation. The fraction; similarly, Indicates replacement Negative triplets generated by mid-tail entities.
2. The geographic knowledge graph link prediction method based on negative sampling combining entity semantic similarity and clustering as described in claim 1, characterized in that: In step 1, the geographic knowledge tuple representation framework is as follows: ; ; in: A knowledge tuple representation model for geographic entities and their attributes; E Represents geographical entities; S V represents entity attributes; V represents attribute values. A knowledge tuple representation model for two different geographic entities. E 1 represents a geographic head entity. E 2 represents a geographic tail entity. R It represents the relationship between two entities.
3. The geographic knowledge graph link prediction method based on negative sampling combining entity semantic similarity and clustering as described in claim 1, characterized in that: Step 2 includes the following steps: S21: Open the geographic vector map in the ArcGIS platform, representing place names as points or lines, and view the multiple attributes of the place name and their corresponding attribute values; S22: Calculate the distance relationships between points in a geographic vector map. By calculating the Euclidean distance between two points and providing a corresponding threshold, the relative distance between the two points can be determined. The expression is as follows: ; in, and The latitude and longitude coordinates of the two place names are represented respectively. The distance relationship is obtained by comparing the Euclidean distance with multiple thresholds. The distance relationship includes: very close within the city, close within the city, very far within the city, very close between the city, close between the city, far between the city, and very far between the city. S23: Based on the midpoint of the geographic vector map With point The azimuth angle between the two points determines the directional relationship between the place names they represent; the directional relationship includes 8 types, namely east, northeast, north, northwest, west, southwest, south and southeast, and the distance relationship and directional relationship together form the spatial relationship between entities; S24: Export the attribute information contained in each entity and its spatial information with other entities in a table. Each column in the table represents an attribute relationship or a spatial relationship. S25: Use the Py2neo package to store the table in the graph database Neo4j, and then read the entities and relations from the graph database Neo4j and convert them into geographic triples data.
4. The geographic knowledge graph link prediction method based on negative sampling combining entity semantic similarity and clustering as described in claim 1, characterized in that: In step 4, K objects are randomly selected from the N entity datasets as initial cluster centers. The distance from each entity point to the cluster center is calculated, and they are assigned to the nearest cluster one by one. After all entities have been assigned, the positions of the K cluster centers are updated. Compare the K cluster centers calculated in the previous step with the current cluster centers. If the cluster centers have changed, return to the step of calculating the distance from each entity point to the cluster center; otherwise, output the clustering results. The K-means algorithm is used to divide N entities into K clusters to minimize the Euclidean distance between each entity and its cluster center. The expression is as follows: ; in, K Indicates the number of clusters. e Represents an entity vector. c i Indicates the first i The center vectors of the clusters, C i This represents the aggregation of entity e in the i-th cluster. L 2 represents the Euclidean distance of the second norm.
5. The geographic knowledge graph link prediction method based on negative sampling combining entity semantic similarity and clustering according to claim 4, characterized in that: In step 4, when the geographic knowledge graph embedding model GKTransE performs negative sampling, it randomly selects other entities in the cluster where the replaced entity is located as negative examples and generates negative example triples.
6. The geographic knowledge graph link prediction method based on negative sampling combining entity semantic similarity and clustering as described in claim 1, characterized in that: Step 5 includes the following steps: S51: Read the entity and relation information from the constructed geographic triplet data, initialize the entity and relation tensors using the knowledge fusion tool, and then process each row of the tensors. L 2. Normalization; S52: Batch training is used when training the GKTransE model. K-means partitioning is called in each training session to divide the entities into multiple clusters. During negative sampling, the random function is called. If the value is less than 0.5, the head entity of the positive triplet is replaced to generate the negative triplet; otherwise, the tail entity is replaced. S53: The GKTransE model calculates the loss by calling a function based on the tensors corresponding to the positive and negative triplet pairs, and then performs backpropagation on the loss function to update the parameters and minimize the loss function.
7. The geographic knowledge graph link prediction method based on negative sampling combining entity semantic similarity and clustering as described in claim 1, characterized in that: Evaluation metrics include: average last place ranking MRR Average ranking MR Hit rate for ranks less than n Hits@n The three indicators are defined as follows: ; ; ; in, T It is a test set of triples. i It is the number of sets of triples. It is to replace the head entity to generate the first i Link prediction ranking for triples It is the link prediction ranking generated by replacing the tail entity to produce the i-th triple; MRR It is the average of the reciprocal scores of the predicted positive tuples in the test triplet set. The higher the index value, the better, indicating that the ranking is consistent with the actual situation. MR It is the average of the predicted scores of positive tuples. The smaller the value of this indicator, the better. The smaller the predicted value, the higher the accuracy of the model. Hits@n This refers to a ranking less than or equal to in link prediction. n The average percentage of triples, Hit@n The higher the indicator, the better.
