Method, apparatus for determining user active location and user active location monitoring system
By optimizing the DBSCAN algorithm with GeoHash and KD Tree indexes, and combining it with the KMeans++ algorithm, the problem of high computational complexity in clustering user active locations was solved, achieving efficient and accurate determination of user active locations.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- 中国邮政储蓄银行股份有限公司
- Filing Date
- 2023-12-29
- Publication Date
- 2026-06-05
AI Technical Summary
In existing technologies, clustering algorithms for user active locations have high computational complexity, consume a lot of computing resources, and are inefficient, especially when dealing with massive amounts of data.
The GeoHash algorithm is used for region encoding and initial screening, combined with the KD Tree algorithm to build an index, the DBSCAN algorithm is used for clustering, and the KMeans++ algorithm is used to determine the initial cluster centers, ultimately obtaining the user's active location.
It simplifies the calculation of distances between data points during clustering, improves computational efficiency and accuracy, reduces computational complexity, and ensures the accuracy of the determination of user active locations.
Smart Images

Figure CN117812542B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data analysis technology, and more specifically, to a method, apparatus, computer-readable storage medium, and user active location monitoring system for determining user active locations. Background Technology
[0002] In existing technologies, the mainstream approach to analyzing user hotspot locations mainly involves using the user's mobile phone location, calling various map software SDKs, collecting the geographic location information carried in the mobile phone signaling data, and then performing cluster analysis based on the collected user geographic location sample points.
[0003] In existing technologies, one approach is to analyze users' work and residence locations based on geographic location information in user logs. After filtering sample points using a weighted algorithm, the density clustering algorithm DBSCAN is used to obtain cluster centers as the users' permanent residence areas. This approach is fast because the DBSCAN algorithm is sensitive to clustered samples and does not require specifying the number of clusters or the characteristics of cluster centers. However, the accuracy of the analysis results is low. Another approach is to simply combine DBSCAN and KMeans. However, for massive amounts of data, the DBSCAN algorithm involves a large number of distance calculations during the initial clustering process, resulting in high computational complexity, high consumption of computing resources, and low efficiency. Summary of the Invention
[0004] The main objective of this application is to provide a method, apparatus, computer-readable storage medium, and user active location monitoring system for determining user active locations, so as to at least solve the problems of high computational complexity, high computational resource consumption, and reduced computational efficiency of clustering algorithms in the prior art.
[0005] To achieve the above objectives, according to one aspect of this application, a method for determining a user's active location is provided, comprising: determining a first target region and a first target location based on user logs; encoding the first target region using a GeoHash algorithm to obtain multiple second target regions; and determining multiple third target regions based on the second target regions, wherein the first target region is a region the user has traversed, the first target location is the user's dwell location, and the multiple third target regions are the first preset number of second target regions corresponding to the user's activity ranking; dividing the third target regions based on the first target location using a KD Tree algorithm to obtain multiple fourth target regions, wherein one third target region corresponds to multiple fourth target regions; clustering the fourth target regions using a DBSCAN algorithm to obtain a first cluster cluster; determining initial cluster centers based on the first cluster cluster using a KMeans++ algorithm; clustering based on the initial cluster centers and the first cluster cluster using a KMeans++ algorithm to obtain a second cluster cluster; and determining the cluster center of the second cluster cluster as the target active location.
[0006] Optionally, encoding the first target region based on the GeoHash algorithm to obtain multiple second target regions includes: determining multiple first boundary coordinates based on the boundary of the first target region, wherein the first boundary coordinates include the maximum longitude, minimum longitude, maximum latitude, and minimum latitude of the first target region; converting each boundary coordinate into binary form, and uniformly dividing the boundary coordinates in binary form to obtain multiple second boundary coordinates, wherein the second boundary coordinates include the maximum longitude, minimum longitude, maximum latitude, and minimum latitude of each second target region; concatenating the binary representations of the longitude and latitude of the second boundary coordinates to obtain candidate GeoHash codes, and truncating the candidate GeoHash codes according to a preset length to obtain target GeoHash codes, wherein each GeoHash code corresponds one-to-one with a second target region.
[0007] Optionally, determining multiple third target regions based on the second target region includes: determining multiple first target quantities based on the first target location and the second target region, where the first target quantity is the number of first target locations included in each of the second target regions; when the first target quantity is greater than a second threshold, determining the corresponding second target region as a sixth target region; obtaining multiple first coefficients, first target durations, second coefficients, second target durations, second target quantities, and third coefficients, where the first coefficients are coefficients corresponding to each of the sixth target regions, the first target duration is the sum of the dwell times corresponding to the first target locations in each of the sixth target regions, the second coefficient is the coefficient corresponding to a nine-square grid range centered on any one of the sixth target regions, and the second target duration is the sum of the dwell times of the first target locations included in the nine-square grid range centered on any one of the sixth target regions. The sum of the dwell time corresponding to each location, the second target quantity is the number of the first target locations included in the nine-square grid range centered on any of the sixth target areas, and the third coefficient is the coefficient corresponding to the first target area; the product of the first coefficient, the first target duration, and the first target quantity is calculated to obtain the first target value, the product of the second coefficient, the second target duration, the second target quantity, and the third coefficient is calculated to obtain the second target value, and the sum of the first target value and the second target value is calculated to obtain the activity level; the third target area is determined based on the activity level, the first preset quantity, and the sixth target area, and the third target area includes the sixth target areas ranked first preset number of the corresponding user's activity level and the sixth target areas in the nine-square grid range centered on the sixth target areas ranked first preset number of the corresponding user's activity level.
[0008] Optionally, before dividing the third target region using the KD Tree algorithm, the method further includes: determining a second target location based on the third target region and the first target location, wherein the second target location is the first target location included in the third target region; obtaining a sampling rate; determining a target set based on the second target location and the sampling rate, wherein the ratio of the number of third target locations to the number of second target locations in the target set is the sampling rate; iterating the target set until the target set satisfies a first preset condition, wherein the first preset condition is that the sum of the minimum Euclidean distances between the fourth target location and the third target location in the target set is maximized, wherein the fourth target location is the second target location not included in the target set.
[0009] Optionally, the third target region is divided using a KD Tree algorithm to obtain multiple fourth target regions, including: a first calculation step, calculating the variance based on the longitude of each third target location in the third target region to obtain a first variance, and calculating the variance based on the latitude of each third target location in the third target region to obtain a second variance; a first determination step, if the first variance is greater than the second variance, determining the median of the longitude of the third target location as the third target value, and segmenting the third target location according to the third target value to obtain two first datasets to complete one segmentation, wherein each of the two first datasets includes a corresponding longitude greater than the third target value. The third target position and the third target position with a corresponding longitude less than the third target value; the second determination step, when the number of segmentations is less than the first preset number, determines the median latitude of the third target position in the first dataset as the fourth target value and segments the first dataset according to the fourth target value to obtain two second datasets, the two second datasets respectively including the third target position with a corresponding latitude greater than the fourth target value and the third target position with a corresponding latitude less than the fourth target value; the third determination step, when the number of segmentations is less than the first preset number, determines the median latitude of the third target position in the second dataset as the fourth target value and segments the first dataset according to the fourth target value to obtain two second datasets, the two second datasets respectively including the third target position with a corresponding latitude greater than the fourth target value and the third target position with a corresponding latitude less than the fourth target value; The median of the longitude of the location is determined as the third target value, and the second dataset is segmented according to the third target value to obtain two first datasets; the fourth determination step is to determine the median of the latitude of the third target location as the third target value when the second variance is greater than the first variance, and to segment the third target location according to the third target value to obtain two first datasets to complete one segmentation, wherein the two first datasets respectively include the third target location with a latitude greater than the third target value and the third target location with a latitude less than the third target value; the fifth determination step is to determine the segmentation steps when the number of segmentations is less than a first preset number. Next, the median of the longitude of the third target location in the first dataset is determined as the fourth target value, and the first dataset is segmented according to the fourth target value to obtain two second datasets. The two second datasets respectively include the third target location with a longitude greater than the fourth target value and the third target location with a longitude less than the fourth target value; in the sixth determining step, if the number of segmentations is less than a first preset number, the median of the latitude of the third target location in the second dataset is determined as the third target value, and the second dataset is segmented according to the third target value to obtain two first datasets;The second and third determination steps, or the fifth and sixth determination steps, are repeated at least once until the number of segmentations equals the first preset number, resulting in multiple first datasets or second datasets. The fourth target region is then determined based on the first or second datasets, where each fourth target region includes all the third target locations from one of the first or second datasets.
[0010] Optionally, clustering the fourth target region using the DBSCAN algorithm to obtain a first cluster includes: a seventh determination step, where any one of the third target locations is determined as a target sample point, and a fifth target region is determined with the target sample point as the center and a preset radius; an eighth determination step, where if the number of third target locations in the fifth target region corresponding to the target sample point is greater than a third threshold, the target sample point is determined as a target core point and the other third target locations in the fifth target region are determined as target boundary points; a ninth determination step, where the target core point and the corresponding target boundary points are determined as backup... Selecting clusters; the tenth determination step, if the fifth target region corresponding to the target core point in the candidate clusters includes other target core points, merge the candidate clusters corresponding to the target core point in the fifth target region to obtain the first cluster; if the fifth target region corresponding to the target core point in the candidate clusters does not include other target core points, determine the candidate cluster as the first cluster; repeat the seventh determination step, the eighth determination step, the ninth determination step and the tenth determination step at least once until all the first clusters are determined.
[0011] Optionally, the initial cluster centers are determined based on the first cluster using the KMeans++ algorithm, and a second cluster is obtained by clustering based on the initial cluster centers and the first cluster using the KMeans++ algorithm, including: a filtering step, randomly selecting a second preset number of the third target positions in the first cluster as the initial cluster centers; a second calculation step, calculating the distance between each of the third target positions and each of the initial cluster centers to obtain multiple first target distances, and classifying each of the third target positions into the initial cluster center with the smallest corresponding first target distance to obtain a third cluster; a third calculation step, calculating the first... The average longitude and average latitude of each of the three target locations in the three clusters are used to obtain the updated cluster center; in the fourth calculation step, the distance between each of the three target locations and each of the updated cluster centers is calculated to obtain multiple second target distances, and each of the three target locations is classified into the updated cluster center with the smallest corresponding second target distance to update the third cluster; the third calculation step and the fourth calculation step are repeated at least once until the second target distance corresponding to each of the three target locations in each of the three clusters is less than the fourth threshold or the number of iterations reaches the second preset number, and each of the three clusters is determined as the second cluster.
[0012] According to another aspect of this application, a device for determining a user's active location is provided, characterized in that the device comprises: an encoding unit, configured to determine a first target region and a first target location based on user logs, encode the first target region using a GeoHash algorithm to obtain a plurality of second target regions, and determine a plurality of third target regions based on the second target regions, wherein the first target region is a region traversed by the user, the first target location is a location where the user stays, and the third target regions are a first preset number of second target regions corresponding to the user with the highest activity; a segmentation unit, configured to divide the third target region according to the first target location using a KD Tree algorithm to obtain a plurality of fourth target regions, wherein one third target region corresponds to a plurality of fourth target regions; a first clustering unit, configured to cluster the fourth target regions using a DBSCAN algorithm to obtain a first cluster cluster; a second clustering unit, configured to determine an initial cluster center based on the first cluster cluster using a KMeans++ algorithm, and cluster the first cluster cluster using a KMeans++ algorithm to obtain a second cluster cluster; and a first determination unit, configured to determine a fifth target region based on the second cluster cluster and determine the fifth target region as a target active location.
[0013] According to another aspect of this application, a computer-readable storage medium is provided, the computer-readable storage medium including a stored program, wherein, when the program is executed, it controls the device on which the computer-readable storage medium is located to perform any of the methods described.
[0014] According to another aspect of this application, a user active location monitoring system is provided, comprising: one or more processors, a memory, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, the one or more programs comprising methods for any one of the methods.
[0015] Applying the technical solution of this application, in the above-mentioned method for determining user active locations, firstly, a first target area and a first target location are determined based on user logs. The first target area is then encoded using the GeoHash algorithm to obtain multiple second target areas. Multiple third target areas are then determined based on the second target areas. The first target area represents the area the user has traversed, the first target location represents the user's dwell location, and the multiple third target areas represent the first preset number of second target areas corresponding to the user's activity level. Next, the third target areas are divided using the KD Tree algorithm based on the first target location to obtain multiple fourth target areas, with one third target area corresponding to multiple fourth target areas. Then, the fourth target areas are clustered using the DBSCAN algorithm to obtain a first cluster cluster. Next, the first cluster clusters are clustered using the KMeans++ algorithm to determine initial cluster centers. Based on the initial cluster centers and the first cluster clusters, the KMeans++ algorithm is used to cluster again to obtain a second cluster cluster. Finally, the cluster center of the second cluster cluster is determined as the target active location. This application uses the GeoHash algorithm for region partitioning and initial screening of regions, selecting regions with high activity levels as data points for clustering input to ensure the accuracy of the clustering results. Then, it uses the KD Tree algorithm to create an index for the sample points, guiding the DBSCAN algorithm for clustering. The KD Tree algorithm categorizes the data points by region, simplifying the calculation of distances between data points during DBSCAN clustering. The initial clusters are then determined using the DBSCAN algorithm, simplifying the process of determining cluster centers using the KMeans++ algorithm. Finally, the target clusters are obtained using the KMeans++ algorithm, and the user's active region is determined based on these target clusters. This solves the problems of high computational complexity, high resource consumption, and reduced computational efficiency in existing clustering algorithms. Attached Figure Description
[0016] Figure 1A hardware structure block diagram of a mobile terminal is shown, illustrating a method for determining a user's active location according to an embodiment of this application.
[0017] Figure 2 A flowchart illustrating a method for determining a user's active location according to an embodiment of this application is shown.
[0018] Figure 3 A flowchart illustrating a specific method for determining a user's active location according to an embodiment of this application is shown.
[0019] Figure 4 A flowchart illustrating a method for indexing sample points using a KD Tree algorithm according to an embodiment of this application is shown.
[0020] Figure 5 A schematic diagram of a process for determining a first cluster using the DBSCAN algorithm according to an embodiment of this application is shown;
[0021] Figure 6 A schematic diagram of a process for obtaining a second cluster by clustering using the KMeans++ algorithm according to an embodiment of this application is shown.
[0022] Figure 7 A structural block diagram of a user active location determination device provided according to an embodiment of this application is shown.
[0023] The above figures include the following reference numerals:
[0024] 102. Processor; 104. Memory; 106. Transmission device; 108. Input / output device. Detailed Implementation
[0025] It should be noted that, unless otherwise specified, the embodiments and features described in this application can be combined with each other. This application will now be described in detail with reference to the accompanying drawings and embodiments.
[0026] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.
[0027] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate for the embodiments of this application described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0028] For ease of description, the following explains some of the nouns or terms used in the embodiments of this application:
[0029] The DBSCAN (Density-Based Spatial Clustering of Application with Noise) algorithm is a density-based clustering algorithm that performs well in noisy and uncertain clustering scenarios. By calculating the density of sample points, it can effectively reduce the impact of outliers on clustering.
[0030] GeoHash: Geographic location hashing is a type of address encoding that converts two-dimensional latitude and longitude coordinates into a one-dimensional string.
[0031] KD-TREE (K-Dimensional Tree) is a tree-structured data structure that stores instance points in a K-dimensional space for fast retrieval. It is primarily used for searching key data in multidimensional space (e.g., range search and nearest neighbor search).
[0032] KMeans++ is an improved algorithm based on the KMeans (K-Means Clustering Algorithm), and iteratively solves the clustering analysis algorithm.
[0033] As described in the background section, among the existing algorithms for clustering user active locations, the DBSCAN algorithm has low accuracy. The combination of the DBSCAN algorithm and the K-means algorithm requires a large amount of data. Furthermore, the DBSCAN algorithm has high computational complexity and low efficiency when processing massive amounts of data. To address the problems of high computational complexity, high computational resource consumption, and low computational efficiency of existing clustering algorithms, embodiments of this application provide a method, apparatus, computer-readable storage medium, and user active location monitoring system for determining user active locations.
[0034] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention.
[0035] The methods and embodiments provided in this application can be executed on a mobile terminal, computer terminal, or similar computing device. Taking running on a mobile terminal as an example, Figure 1 This is a hardware structure block diagram of a mobile terminal for a method of determining a user's active location according to an embodiment of the present invention. (See diagram below.) Figure 1 As shown, a mobile terminal may include one or more ( Figure 1 Only one is shown in the diagram. A processor 102 (which may include, but is not limited to, a microprocessor MCU or a programmable logic device FPGA, etc.) and a memory 104 for storing data are also shown. The mobile terminal may further include a transmission device 106 for communication functions and an input / output device 108. Those skilled in the art will understand that... Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the mobile terminal described above. For example, the mobile terminal may also include components that are more... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown.
[0036] The memory 104 can be used to store computer programs, such as application software programs and modules, like the computer program corresponding to the device information display method in this embodiment of the invention. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, thereby implementing the above-described method. The memory 104 may include high-speed random access memory and non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory remotely located relative to the processor 102, and these remote memories can be connected to the mobile terminal via a network. Examples of the aforementioned networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof. The transmission device 106 is used to receive or send data via a network. Specific examples of the aforementioned networks may include wireless networks provided by the mobile terminal's communication provider. In one example, the transmission device 106 includes a network interface controller (NIC), which can be connected to other network devices via a base station to communicate with the Internet. In one example, the transmission device 106 may be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0037] This embodiment provides a method for determining the active location of a user running on a mobile terminal, computer terminal, or similar computing device. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.
[0038] Figure 2 This is a flowchart of a method for determining a user's active location according to an embodiment of this application. Figure 2 As shown, the method includes the following steps:
[0039] Step S201: Determine the first target area and the first target location based on the user logs, encode the first target area based on the GeoHash algorithm to obtain multiple second target areas, and determine multiple third target areas based on the second target areas. The first target area is the area through which the user passes, the first target location is the location where the user stays, and the multiple third target areas are the first preset number of the second target areas ranked by the activity level of the corresponding user.
[0040] Specifically, such as Figure 3 As shown, this application sets up a method to collect geographic location information from user logs to obtain the first target location, which serves as the user's activity trajectory. The first target area is then determined based on the activity trajectory and uniformly converted into the WGS84 geographic coordinate system. The first target area is then encoded using the GeoHash algorithm and segmented to obtain the second target area. Furthermore, a rapid initial screening is performed based on the activity levels of different areas to obtain representative second target areas with high user activity trajectory density, thus obtaining a third target area. The first target location within the third target area is used as input data for the algorithm to determine the user's active location. This reduces computational complexity by removing low-density data while ensuring the accuracy of the final result.
[0041] Step S202: Based on the first target location, the third target region is divided using the KD Tree algorithm to obtain multiple fourth target regions, with one third target region corresponding to multiple fourth target regions.
[0042] Specifically, such as Figure 3As shown, based on the KD Tree algorithm, the third target region is divided into multiple sub-regions according to the latitude and longitude of the first target location in the third target region, thus obtaining the fourth target region. An index tree is then established. In the DBSCAN algorithm's clustering process, the distance is first determined based on the index results, and then the distance to the first target location that cannot be determined based on the index results is calculated. This greatly reduces the computational complexity of the DBSCAN algorithm when dealing with massive amounts of data and improves the overall computational speed of the algorithm.
[0043] Step S203: Based on the fourth target region mentioned above, the first cluster is obtained by clustering using the DBSCAN algorithm;
[0044] Specifically, such as Figure 3 As shown, in order to reduce the problem that the accuracy of the KMeans++ algorithm depends on the accuracy of the cluster centers, and that the computational workload increases sharply when the cluster centers are randomly selected, this application adopts the DBSCAN algorithm's sensitivity to data points. Based on the DBSCAN algorithm, in the absence of cluster centers, preliminary clustering is performed to determine the location of outliers and core points, and then multiple initial clusters are obtained, which is the first cluster mentioned above.
[0045] Step S204: Determine the initial cluster center based on the first cluster using the KMeans++ algorithm, and then perform clustering based on the initial cluster center and the first cluster using the KMeans++ algorithm to obtain the second cluster.
[0046] Specifically, such as Figure 3 As shown, based on the first cluster obtained by the DBSCAN algorithm, initial cluster centers are determined within the first cluster. This ensures the accuracy of the KMeans++ algorithm while reducing the number of iterations required for the algorithm to reach convergence. Then, based on these initial cluster centers, clustering is performed using the KMeans++ algorithm, ultimately resulting in multiple second clusters. The first target position within these second clusters represents the user's active position.
[0047] Step S205: Determine the cluster center of the second cluster as the target active location.
[0048] Specifically, the active location of each user is determined based on the aforementioned second cluster.
[0049] In this embodiment, firstly, a first target area and a first target location are determined based on user logs. The first target area is then encoded using the GeoHash algorithm to obtain multiple second target areas. Multiple third target areas are then determined based on these second target areas. The first target area represents the area the user traverses, the first target location represents the user's dwell location, and the multiple third target areas represent the first preset number of second target areas corresponding to the user's activity level. Next, the third target areas are divided using the KD Tree algorithm based on the first target location to obtain multiple fourth target areas, with one third target area corresponding to multiple fourth target areas. Then, the fourth target areas are clustered using the DBSCAN algorithm to obtain a first cluster. Next, the first cluster is clustered using the KMeans++ algorithm to determine initial cluster centers. Based on the initial cluster centers and the first cluster, the KMeans++ algorithm is used to cluster again to obtain a second cluster. Finally, the cluster centers of the second clusters are determined as the target active locations. This application uses the GeoHash algorithm for region partitioning and initial screening of regions, selecting regions with high activity levels as data points for clustering input to ensure the accuracy of the clustering results. Then, the K-DTree algorithm is used to index the sample points, guiding the DBSCAN algorithm for clustering. The KD Tree algorithm is used to classify the data points by region, simplifying the calculation of distances between data points during DBSCAN clustering. Initial clusters are then determined using the DBSCAN algorithm, simplifying the process of determining cluster centers using the KMeans++ algorithm. Finally, the target clusters are obtained using the KMeans++ algorithm, and the user's active region is determined based on these target clusters. This solves the problems of high computational complexity, high resource consumption, and reduced computational efficiency in existing clustering algorithms.
[0050] In order to obtain the aforementioned second target region, in one optional implementation, step S201 includes:
[0051] Step S2011: Determine multiple first boundary coordinates based on the boundary of the first target area, wherein the first boundary coordinates include the maximum longitude, minimum longitude, maximum latitude, and minimum latitude of the first target area;
[0052] Specifically, the latitude and longitude of the boundary of the first target area determined based on the user's active trajectory are calibrated to obtain the maximum longitude, maximum latitude, minimum longitude, and minimum latitude of the first target area, thus obtaining four first boundary coordinates.
[0053] Step S2012: Convert each of the above-mentioned boundary coordinates into binary form, and uniformly divide the boundary coordinates in binary form to obtain multiple second boundary coordinates. The second boundary coordinates include the maximum longitude, minimum longitude, maximum latitude, and minimum latitude of each of the above-mentioned second target areas.
[0054] Specifically, the longitude or latitude of the first boundary coordinates is converted into binary form, and the difference between the maximum and minimum longitudes is uniformly divided, and the difference between the maximum and minimum latitudes is uniformly divided to obtain multiple second boundary coordinates. Each second boundary coordinate includes the maximum longitude, minimum longitude, maximum latitude, and minimum latitude of each second target area.
[0055] Step S2013: The binary representations of the longitude and latitude of the second boundary coordinates are concatenated to obtain the candidate GeoHash code, and the candidate GeoHash code is truncated according to the preset length to obtain the target GeoHash code. The GeoHash code corresponds one-to-one with the second target region.
[0056] Specifically, the longitude and latitude values corresponding to the second target region are spliced together, that is, alternative GeoHash codes are obtained alternately from the first position. Then, according to the accuracy requirements and the corresponding preset length, the alternative GeoHash codes are extracted from the first position to obtain the target GeoHash code. The second target region is represented by the target GeoHash code.
[0057] In order to obtain the aforementioned third target region, in an optional implementation, step S201 further includes:
[0058] Step S2014: Determine a plurality of first targets based on the first target location and the second target region, wherein the number of first targets is the number of the first target locations included in each of the second target regions;
[0059] Specifically, the number of first targets is obtained by traversing the first target locations contained in each of the second target regions according to the second target regions.
[0060] Step S2015: If the number of the first targets is greater than the second threshold, the corresponding second target region is determined as the fourth target region.
[0061] Specifically, the density of active trajectories in the second target region corresponding to the number of the first target being greater than the second threshold is determined to meet a preset requirement, and then the second target region corresponding to the number of the first target is removed to obtain the fourth target region.
[0062] Step S2016: Obtain multiple first coefficients, first target duration, second coefficients, second target duration, second target quantity, and third coefficient. The first coefficients are the coefficients corresponding to each of the fourth target regions. The first target duration is the sum of the dwell times corresponding to the first target positions in each of the fourth target regions. The second coefficient is the coefficient corresponding to the nine-square grid range centered on any of the fourth target regions. The second target duration is the sum of the dwell times corresponding to the first target positions included in the nine-square grid range centered on any of the fourth target regions. The second target quantity is the number of the first target positions included in the nine-square grid range centered on any of the fourth target regions. The third coefficient is the coefficient corresponding to the first target region.
[0063] Specifically, such as Figure 3 As shown, the coefficients corresponding to each of the aforementioned fourth target partitions are obtained to obtain the aforementioned first coefficient Wcur, and the sum of the user's dwell time at each of the aforementioned first target locations in the aforementioned fourth target partitions is obtained to obtain the aforementioned first target duration. Then, the coefficients corresponding to the four target partitions within the nine-square grid range of each of the four target partitions are obtained to obtain the second coefficient Wsur. The sum of the dwell time of the user at each of the first target positions within the nine-square grid range of each of the four target partitions is obtained to obtain the second target duration Tsur. Finally, the number of the first target positions included within the nine-square grid range is obtained to obtain the second target quantity. Furthermore, the coefficients corresponding to the first target region are determined to obtain the third coefficient mentioned above:
[0064] Step S2017: Calculate the product of the first coefficient, the first target duration, and the first target quantity to obtain the first target value; calculate the product of the second coefficient, the second target duration, the second target quantity, and the third coefficient to obtain the second target value; calculate the sum of the first target value and the second target value to obtain the activity level.
[0065] Specifically, the activity level S is obtained by substituting the product of the first coefficient Wcur, the first target duration Tcur, the first target quantity Ccur, the second coefficient Wsur, the second target duration Tsur, the second target quantity Csur, and the third coefficient Wsum into the formula S = Wcur * Tcur * Ccur + Wsur * Tsur * Csur * Wsum.
[0066] Step S2018: Determine the third target area based on the activity level, the first preset quantity, and the sixth target area. The third target area includes the sixth target area ranked first preset quantity in terms of the activity level of the corresponding user, and the sixth target area within a nine-square grid centered on the sixth target area ranked first preset quantity in terms of the activity level of the corresponding user.
[0067] In one embodiment of this application, the three fourth target regions corresponding to the highest activity levels are selected as the third target regions, and the fourth target regions within the nine-square grid of the third target regions are selected as the third target regions.
[0068] To reduce the computational cost of the KD Tree algorithm and improve its speed, in one optional implementation, before dividing the third target region using the KD Tree algorithm, the method further includes:
[0069] Step S301: Determine the second target location based on the third target area and the first target location, wherein the second target location is the first target location included in the third target area;
[0070] Specifically, based on the corresponding third target region, the first target position within the third target region is determined as the second target position.
[0071] Step S302: Obtain the sampling rate; determine the target set based on the second target position and the sampling rate; the ratio of the number of third target positions to the number of second target positions in the target set is the sampling rate.
[0072] Specifically, a preset sampling rate is obtained, and the second target position is randomly selected according to the sampling rate to obtain the third target position. The ratio of the number of the third target positions to the number of the second targets is the sampling rate, and the target set is obtained.
[0073] Step S303: Iterate through the target set until the target set satisfies the first preset condition. The first preset condition is that the sum of the minimum Euclidean distances between the fourth target position and the third target position in the target set is maximized. The fourth target position is the second target position that is not included in the target set.
[0074] Specifically, the above steps are repeated for each of the above third target regions in sequence, and then iterative calculations are performed on each of the above third target regions to determine the above target set as Scur, and then the position of the above fourth target is determined as m, and then the distance between m and Scur is kept to be the maximum, wherein the distance between m and Scur is the minimum Euclidean distance between m and Scur.
[0075] To obtain the aforementioned fourth target region, in one optional implementation, step S202 includes:
[0076] Step S2021, the first calculation step, calculates the variance based on the longitude of each of the third target locations in the third target region to obtain the first variance, and calculates the variance based on the latitude of each of the third target locations in the third target region to obtain the second variance;
[0077] Specifically, such as Figure 4 As shown, the variances of the latitude and longitude of each of the first target locations within each of the aforementioned third target regions are calculated to obtain the first variance and the second variance. The dimension corresponding to the larger variance is then used as the dividing axis to segment the aforementioned third target regions.
[0078] Step S2022, first determination step: when the first variance is greater than the second variance, the median of the longitude of the third target location is determined as the third target value. The third target location is segmented according to the third target value to obtain two first datasets to complete one segmentation. The two first datasets respectively include the third target location with a longitude greater than the third target value and the third target location with a longitude less than the third target value.
[0079] Specifically, such as Figure 4 As shown, when the variance corresponding to longitude is greater than the variance corresponding to latitude (i.e., when the first variance is greater than the second variance), the median of the longitude corresponding to the third target position is taken as the third target value and used as the separating axis. The third target positions with longitudes greater than the third target value are categorized into the right subtree, and the third target positions with longitudes less than the third target value are categorized into the left subtree, thus obtaining two sets of the first dataset.
[0080] Step S2023, the second determination step, when the number of segmentation times is less than the first preset number of times, the median of the latitude of the third target position in the first dataset is determined as the fourth target value, and the first dataset is segmented according to the fourth target value to obtain two second datasets. The two second datasets respectively include the third target position with the corresponding latitude greater than the fourth target value and the third target position with the corresponding latitude less than the fourth target value.
[0081] Specifically, such as Figure 4As shown, the number of times the third target location in the third target region is divided is obtained, which is the segmentation depth. If the number of segmentations is less than a first preset number, another dimension is used as the separating axis to further segment the first dataset. Each of the first datasets corresponds to two of the second datasets.
[0082] Step S2024, the third determination step, when the number of segmentation is less than the first preset number of segmentation, the median of the longitude of the third target position in the second dataset is determined as the third target value, and the second dataset is segmented according to the third target value to obtain two first datasets.
[0083] Specifically, such as Figure 4 As shown, after the segmentation is completed, the number of times the third target position in the third target region is divided is determined again to obtain the segmentation number. If the segmentation number is less than the first preset number, the second dataset is re-segmented according to the third target value corresponding to each second dataset.
[0084] Step S2025, the fourth determination step, in the case that the second variance is greater than the first variance, the median of the latitude of the third target position is determined as the third target value, and the third target position is segmented according to the third target value to obtain two first datasets to complete one segmentation. The two first datasets respectively include the third target position with the corresponding latitude greater than the third target value and the third target position with the corresponding latitude less than the third target value.
[0085] Specifically, such as Figure 4 As shown, when the variance corresponding to latitude is greater than the variance corresponding to longitude (i.e., when the second variance is greater than the first variance), the median of the latitude of the third target position is taken as the third target value and used as the separating axis. The third target positions with latitudes greater than the third target value are categorized into the right subtree, and the third target positions with latitudes less than the third target value are categorized into the left subtree, thus obtaining two sets of the first dataset.
[0086] Step S2026, the fifth determination step, when the number of segmentation is less than the first preset number of segmentation, the median of the longitude of the third target position in the first dataset is determined as the fourth target value, and the first dataset is segmented according to the fourth target value to obtain two second datasets. The two second datasets respectively include the third target position with a longitude greater than the fourth target value and the third target position with a longitude less than the fourth target value.
[0087] Specifically, such as Figure 4As shown, the number of times the third target location in the third target region is divided is obtained, which is the segmentation depth. If the number of segmentations is less than a first preset number, another dimension is used as the separating axis to further segment the first dataset. Each of the first datasets corresponds to two of the second datasets.
[0088] Step S2027, the sixth determining step, when the number of segmentation times is less than the first preset number of times, the median of the latitude of the third target position in the second dataset is determined as the third target value, and the second dataset is segmented according to the third target value to obtain two first datasets.
[0089] Specifically, such as Figure 4 As shown, after the segmentation is completed, the number of times the third target position in the third target region is divided is determined again to obtain the segmentation number. If the segmentation number is less than the first preset number, the second dataset is re-segmented according to the third target value corresponding to each second dataset.
[0090] Step S2028: Repeat the second determination step and the third determination step or the fifth determination step and the sixth determination step at least once until the number of segmentations is equal to the first preset number of segmentations, to obtain multiple first datasets or second datasets, and determine the fourth target region based on the first datasets or second datasets. A fourth target region includes all the third target locations in a first dataset or second dataset.
[0091] Specifically, such as Figure 4 As shown, repeat the second and third determination steps or repeat the fifth and sixth determination steps until the number of segmentations reaches the first preset number, and determine the region corresponding to the dataset obtained after segmentation as the fourth target region.
[0092] To obtain the first cluster mentioned above, in an optional implementation, step S203 includes:
[0093] Step S2031, the seventh determination step, determines any one of the above-mentioned third target locations as a target sample point, and determines the fifth target area with the above-mentioned target sample point as the center and a preset radius;
[0094] Specifically, such as Figure 5 As shown, any one of the above-mentioned third target locations is randomly selected from all the above-mentioned fourth target regions and determined as the above-mentioned target sample point x. Then, the neighborhood ε of the above-mentioned target sample point is determined to obtain the above-mentioned fifth target region.
[0095] Step S2032, the eighth determination step, in the case that the number of the third target positions in the fifth target region corresponding to the above target sample point is greater than the third threshold, the above target sample point is determined as the target core point and the other third target positions in the fifth target region are determined as target boundary points;
[0096] Specifically, such as Figure 5 As shown, the number of the third target locations in the neighborhood of the target sample point is determined. If the number is greater than the third threshold MinPts, the target sample point is determined as the target core point, and the third target locations in the fifth target region other than the target core point are determined as the target boundary points.
[0097] Step S2033, the ninth determination step, is to determine the candidate clusters based on the above target core points and the corresponding above target boundary points;
[0098] Specifically, such as Figure 5 As shown, the aforementioned target core point and the aforementioned target boundary point in the neighborhood are determined as the aforementioned candidate clusters.
[0099] Step S2034, the tenth determining step: if the fifth target region corresponding to the target core point in the candidate cluster includes other target core points, merge the candidate clusters corresponding to the target core points in the fifth target region to obtain the first cluster; if the fifth target region corresponding to the target core point in the candidate cluster does not include other target core points, determine the candidate cluster as the first cluster.
[0100] Specifically, such as Figure 5 As shown, for each boundary point in the above candidate clusters, it is determined whether it is a core point. If the boundary point is a core point, the above candidate cluster corresponding to the boundary point and the candidate cluster of the target core point are merged until no further merging is possible, resulting in the above first cluster. If the boundary point is not a core point, the above candidate cluster is determined as the above first cluster.
[0101] Step S2035: Repeat the seventh determination step, the eighth determination step, the ninth determination step, and the tenth determination step at least once until all the first clusters are determined.
[0102] Specifically, such as Figure 5As shown, after determining the first cluster, a target sample point that is not in the first cluster is randomly selected, and the seventh, eighth, ninth and tenth determination steps are repeated in sequence until all sample points are divided, or the remaining sample points do not meet the conditions for the above steps.
[0103] To obtain the aforementioned second cluster, in an optional implementation, step S204 includes:
[0104] Step S2041, the screening step, randomly selects a second preset number of locations from the third target locations in the first cluster to determine the initial cluster centers;
[0105] Specifically, such as Figure 6 As shown, a third target location is randomly selected in the first cluster as the initial cluster center, and K-1 cluster centers are determined based on the distance between the initial cluster center and other third target locations, for a total of K cluster centers.
[0106] Step S2042, the second calculation step, calculates the distance between each of the above-mentioned third target positions and each of the above-mentioned initial cluster centers to obtain multiple first target distances, and classifies each of the above-mentioned third target positions into the above-mentioned initial cluster center with the smallest corresponding first target distance to obtain a third cluster;
[0107] Specifically, such as Figure 6 As shown, the Euclidean distance between each of the aforementioned third target locations and each of the aforementioned initial cluster centers is calculated, and then the Haversine distance is calculated based on the Euclidean distance. Then, the aforementioned third target locations are divided according to the aforementioned Haversine distance, and each of the aforementioned third target locations is classified into the corresponding aforementioned initial cluster centers to obtain the aforementioned third clusters.
[0108] It should be noted that this application builds an index based on the KD TREE algorithm. In the process of determining the distance, an approximate distance can be determined based on the root node in the index between the fourth target region to which the third target location belongs and the fourth target region to which the initial cluster center belongs. That is, if the distance is more than a first number of root nodes, it is determined that the third target location does not belong to the initial cluster center; if the distance is less than a second number of root nodes, it is determined that the third target location belongs to the initial cluster center; and if the distance is between the first and second number of root nodes, the calculation is performed, which greatly reduces the amount of computation.
[0109] Step S2043, the third calculation step, calculate the mean of longitude and the mean of latitude corresponding to each of the above-mentioned third target locations in the above-mentioned third cluster to obtain the updated cluster center;
[0110] Specifically, such as Figure 6 As shown, based on the third clusters corresponding to the K initial cluster centers, the mean of the latitude and longitude of each of the third target locations in the clusters is calculated, and the new cluster centers of each of the third clusters are determined, thus obtaining the updated cluster centers.
[0111] Step S2044, the fourth calculation step, calculates the distance between each of the above-mentioned third target positions and each of the above-mentioned updated cluster centers to obtain multiple second target distances, and classifies each of the above-mentioned third target positions into the above-mentioned updated cluster center with the smallest corresponding second target distance to update the above-mentioned third cluster;
[0112] Specifically, such as Figure 6 As shown, the Euclidean distance between each of the aforementioned third target locations and each of the aforementioned updated cluster centers is calculated, and then the Haversine distance is calculated based on the Euclidean distance. Then, the aforementioned third target locations are divided according to the aforementioned Haversine distance, and each of the aforementioned third target locations is classified into the corresponding aforementioned updated cluster centers, and the aforementioned third clusters are updated.
[0113] Step S2045: Repeat the above third calculation step and fourth calculation step at least once until the distance of the second target corresponding to each of the above third target positions in each of the above third clusters is less than the fourth threshold or the number of iterations reaches the second preset number, and determine each of the above third clusters as the above second clusters.
[0114] Specifically, such as Figure 6 As shown, the third and fourth calculation steps are repeated iteratively until the clusters of the Kmeans++ algorithm converge or the maximum number of iterations is reached. The operation ends and the corresponding third cluster is output to obtain the second cluster.
[0115] It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases the steps shown or described may be executed in a different order than that shown here.
[0116] This application also provides a device for determining a user's active location. It should be noted that this device can be used to execute the method for determining a user's active location provided in this application. This device is used to implement the above embodiments and preferred embodiments; details already described will not be repeated. As used below, the term "module" can refer to a combination of software and / or hardware that performs a predetermined function. Although the device described in the following embodiments is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.
[0117] The following describes the device for determining the active location of a user provided in the embodiments of this application.
[0118] Figure 7 This is a structural block diagram of a user active location determination device according to an embodiment of this application. Figure 7 As shown, the device includes:
[0119] The encoding unit 10 is used to determine a first target area and a first target location based on user logs, encode the first target area based on the GeoHash algorithm to obtain multiple second target areas, and determine multiple third target areas based on the second target areas. The first target area is the area through which the user passes, the first target location is the location where the user stays, and the third target area is the first preset number of the second target areas with the highest activity level for the corresponding user.
[0120] The segmentation unit 20 is used to divide the third target region according to the first target location using the KD Tree algorithm to obtain multiple fourth target regions, and one third target region corresponds to multiple fourth target regions.
[0121] The first clustering unit 30 is used to obtain the first cluster by clustering the fourth target region according to the DBSCAN algorithm;
[0122] The second clustering unit 40 is used to determine the initial cluster center based on the first cluster using the KMeans++ algorithm, and to perform clustering based on the initial cluster center and the first cluster using the KMeans++ algorithm to obtain the second cluster.
[0123] The first determining unit 50 is used to determine the cluster center of the second cluster as the target active location.
[0124] In this embodiment, the encoding unit determines a first target region and a first target location based on user logs, encodes the first target region using the GeoHash algorithm to obtain multiple second target regions, and determines multiple third target regions based on the second target regions. The first target region is the area the user passes through, the first target location is the user's dwell location, and the multiple third target regions are the first preset number of the second target regions corresponding to the user's activity ranking. The segmentation unit divides the third target region using the KD Tree algorithm based on the first target location to obtain multiple fourth target regions, with one third target region corresponding to multiple fourth target regions. The first clustering unit clusters the fourth target regions using the DBSCAN algorithm to obtain a first cluster cluster. The second clustering unit determines the initial cluster center using the KMeans++ algorithm based on the first cluster cluster, and clusters the first cluster cluster using the KMeans++ algorithm based on the initial cluster center and the first cluster cluster to obtain a second cluster cluster. The first determining unit determines the cluster center of the second cluster cluster as the target active location. This application uses the GeoHash algorithm for region partitioning and initial screening of regions, selecting regions with high activity levels as data points for clustering input to ensure the accuracy of the clustering results. Then, it uses the KD Tree algorithm to create an index for the sample points, guiding the DBSCAN algorithm for clustering. The KD Tree algorithm categorizes the data points by region, simplifying the calculation of distances between data points during DBSCAN clustering. The initial clusters are then determined using the DBSCAN algorithm, simplifying the process of determining cluster centers using the KMeans++ algorithm. Finally, the target clusters are obtained using the KMeans++ algorithm, and the user's active region is determined based on these target clusters. This solves the problems of high computational complexity, high resource consumption, and reduced computational efficiency in existing clustering algorithms.
[0125] To obtain the aforementioned second target region, in one optional implementation, the encoding unit includes:
[0126] The first determining module is used to determine multiple first boundary coordinates based on the boundary of the first target area, wherein the first boundary coordinates include the maximum longitude, minimum longitude, maximum latitude, and minimum latitude of the first target area;
[0127] The first conversion module is used to convert each of the above-mentioned boundary coordinates into binary form, and to uniformly divide the boundary coordinates in binary form to obtain multiple second boundary coordinates, wherein the second boundary coordinates include the maximum longitude, minimum longitude, maximum latitude and minimum latitude of each of the above-mentioned second target areas.
[0128] The second conversion module is used to concatenate the binary representations of the longitude and latitude of the second boundary coordinates to obtain a candidate GeoHash code, and to truncate the candidate GeoHash code according to a preset length to obtain a target GeoHash code. The GeoHash code corresponds one-to-one with the second target region.
[0129] To obtain the aforementioned third target region, in an optional implementation, the encoding unit further includes:
[0130] The second determining module is used to determine a plurality of first targets based on the first target location and the second target region, wherein the number of first targets is the number of first target locations included in each of the second target regions;
[0131] The third determining module is used to determine the corresponding second target region as the fourth target region when the number of the first targets is greater than the second threshold.
[0132] The acquisition module is used to acquire multiple first coefficients, first target duration, second coefficients, second target duration, second target quantity, and third coefficient. The first coefficients are the coefficients corresponding to each of the fourth target regions. The first target duration is the sum of the dwell times corresponding to the first target positions in each of the fourth target regions. The second coefficients are the coefficients corresponding to the nine-square grid range centered on any of the fourth target regions. The second target duration is the sum of the dwell times corresponding to the first target positions included in the nine-square grid range centered on any of the fourth target regions. The second target quantity is the number of the first target positions included in the nine-square grid range centered on any of the fourth target regions. The third coefficient is the coefficient corresponding to the first target region.
[0133] The first calculation module is used to calculate the product of the first coefficient, the first target duration, and the first target quantity to obtain a first target value; calculate the product of the second coefficient, the second target duration, the second target quantity, and the third coefficient to obtain a second target value; and calculate the sum of the first target value and the second target value to obtain the activity level.
[0134] The fourth determining module is used to determine the third target area based on the activity level, the first preset quantity, and the sixth target area. The third target area includes the sixth target area that ranks first preset quantity in terms of the activity level of the corresponding user, and the sixth target area within a nine-square grid centered on the sixth target area that ranks first preset quantity in terms of the activity level of the corresponding user.
[0135] To reduce the computational load of the KD Tree algorithm and improve its processing speed, the device further includes:
[0136] The second determining unit is configured, in an optional embodiment, to determine a second target position based on the third target region and the first target position before dividing the third target region using the KD Tree algorithm, wherein the second target position is the first target position included in the third target region.
[0137] The acquisition unit is used to acquire a sampling rate, determine a target set based on the second target position and the sampling rate, and the ratio of the number of third target positions in the target set to the number of second target positions is the sampling rate.
[0138] An iterative unit is used to iterate over the target set until the target set satisfies a first preset condition. The first preset condition is that the sum of the minimum Euclidean distances between the fourth target position and the third target position in the target set is maximized. The fourth target position is the second target position that is not included in the target set.
[0139] To obtain the aforementioned fourth target region, in one optional implementation, the segmentation unit includes:
[0140] The second calculation module is used to perform the first calculation step, calculate the variance based on the longitude of each of the third target locations in the third target region to obtain the first variance, and calculate the variance based on the latitude of each of the third target locations in the third target region to obtain the second variance.
[0141] The fifth determining module is used to perform the first determining step. When the first variance is greater than the second variance, the median of the longitude of the third target position is determined as the third target value. The third target position is segmented according to the third target value to obtain two first datasets to complete one segmentation. The two first datasets respectively include the third target position with a longitude greater than the third target value and the third target position with a longitude less than the third target value.
[0142] The sixth determining module is used to perform the second determining step. When the number of segmentation times is less than the first preset number of times, the median of the latitude of the third target position in the first dataset is determined as the fourth target value, and the first dataset is segmented according to the fourth target value to obtain two second datasets. The two second datasets respectively include the third target position with a latitude greater than the fourth target value and the third target position with a latitude less than the fourth target value.
[0143] The seventh determining module is used to perform the third determining step. When the number of segmentation steps is less than the first preset number of steps, the median of the longitude of the third target position in the second dataset is determined as the third target value, and the second dataset is segmented according to the third target value to obtain two first datasets.
[0144] The eighth determining module is used to perform the fourth determining step. When the second variance is greater than the first variance, the median of the latitude of the third target position is determined as the third target value. The third target position is segmented according to the third target value to obtain two first datasets to complete one segmentation. The two first datasets respectively include the third target position with a latitude greater than the third target value and the third target position with a latitude less than the third target value.
[0145] The ninth determining module is used to execute the fifth determining step. When the number of segmentation steps is less than the first preset number of steps, the median of the longitude of the third target position in the first dataset is determined as the fourth target value. The first dataset is then segmented according to the fourth target value to obtain two second datasets. The two second datasets respectively include the third target position with a longitude greater than the fourth target value and the third target position with a longitude less than the fourth target value.
[0146] The tenth determining module is used to execute the sixth determining step. When the number of segmentation steps is less than the first preset number of steps, the median of the latitude of the third target position in the second dataset is determined as the third target value, and the second dataset is segmented according to the third target value to obtain two first datasets.
[0147] The first repeating module is used to repeat the second and third determining steps or the fifth and sixth determining steps at least once until the number of segmentations is equal to the first preset number of segmentations, to obtain multiple first datasets or second datasets, and to determine the fourth target region based on the first datasets or second datasets. A fourth target region includes all the third target locations in a first dataset or second dataset.
[0148] To obtain the aforementioned first cluster, in one optional implementation, the first clustering unit includes:
[0149] The eleventh determination module is used to execute the seventh determination step, which determines any one of the above-mentioned third target locations as a target sample point, and determines the fifth target area with the above-mentioned target sample point as the center and a preset radius.
[0150] The twelfth determination module is used to execute the eighth determination step, in which the number of the third target positions in the fifth target region corresponding to the above target sample point is greater than the third threshold, the above target sample point is determined as the target core point and the other third target positions in the fifth target region are determined as target boundary points.
[0151] The thirteenth determination module is used to execute the ninth determination step, and to determine the candidate clusters based on the above target core points and the corresponding above target boundary points.
[0152] The fourteenth determining module is used to execute the tenth determining step, in the case that the fifth target region corresponding to the target core point in the candidate cluster includes other target core points, the candidate clusters corresponding to the target core point in the fifth target region are merged to obtain the first cluster; in the case that the fifth target region corresponding to the target core point in the candidate cluster does not include other target core points, the candidate cluster is determined as the first cluster.
[0153] The second repeating module is used to repeat the seventh, eighth, ninth and tenth determination steps at least once until all the first clusters are determined.
[0154] To obtain the aforementioned second cluster, in one optional implementation, the second clustering unit includes:
[0155] The filtering module is used to perform the filtering step, randomly selecting a second preset number of the third target positions in the first cluster to determine the initial cluster centers.
[0156] The third calculation module is used to perform the second calculation step, calculate the distance between each of the above-mentioned third target positions and each of the above-mentioned initial cluster centers to obtain multiple first target distances, and classify each of the above-mentioned third target positions into the above-mentioned initial cluster center with the smallest corresponding first target distance to obtain a third cluster;
[0157] The fourth calculation module is used to execute the third calculation step, which calculates the mean longitude and the mean latitude of each of the third target locations in the third cluster to obtain the updated cluster center.
[0158] The fifth calculation module is used to execute the fourth calculation step, calculate the distance between each of the above-mentioned third target positions and each of the above-mentioned updated cluster centers to obtain multiple second target distances, and classify each of the above-mentioned third target positions into the above-mentioned updated cluster center with the smallest corresponding second target distance to update the above-mentioned third cluster.
[0159] The third repeating module is used to repeat the third calculation step and the fourth calculation step at least once until the distance between the second target corresponding to each third target position in each third cluster is less than the fourth threshold or the number of iterations reaches the second preset number, thereby determining each third cluster as the second cluster.
[0160] The aforementioned user active location determination device includes a processor and a memory. The encoding unit, segmentation unit, first clustering unit, second clustering unit, and first determination unit are all stored as program units in the memory. The processor executes these program units stored in the memory to achieve the corresponding functions. All of the above modules are located in the same processor; alternatively, the modules may be located in different processors in any combination.
[0161] The processor contains a kernel, which retrieves the corresponding program units from memory. One or more kernels can be configured, and adjusting kernel parameters can improve the accuracy and efficiency of clustering user activity locations.
[0162] The memory may include non-permanent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip.
[0163] This invention provides a computer-readable storage medium including a stored program, wherein, when the program is executed, it controls the device where the computer-readable storage medium is located to perform the method for determining the user's active location.
[0164] This invention provides a processor for running a program, wherein the program executes the method for determining the user's active location.
[0165] This invention provides a user active location monitoring system, which includes a processor, a memory, and a program stored in the memory and executable on the processor. When the processor executes the program, it implements at least the above-described method for determining the user's active location.
[0166] This application also provides a computer program product that, when executed on a data processing device, is adapted to perform a program that initializes the determination method steps for having at least the aforementioned active user location.
[0167] It is obvious to those skilled in the art that the modules or steps of the present invention described above can be implemented using general-purpose computing devices. They can be centralized on a single computing device or distributed across a network of multiple computing devices. They can be implemented using computer-executable program code, and thus can be stored in a storage device for execution by a computing device. In some cases, the steps shown or described can be performed in a different order than those described herein, or they can be fabricated as separate integrated circuit modules, or multiple modules or steps can be fabricated as a single integrated circuit module. Thus, the present invention is not limited to any particular combination of hardware and software.
[0168] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0169] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0170] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0171] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0172] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0173] Memory may include non-persistent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.
[0174] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.
[0175] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0176] As can be seen from the above description, the embodiments of this application achieve the following technical effects:
[0177] 1) The method for determining the active location of users in this application includes: First, determining a first target area and a first target location based on user logs; encoding the first target area using the GeoHash algorithm to obtain multiple second target areas; and determining multiple third target areas based on the second target areas. The first target area is the area the user passes through, the first target location is the user's dwell location, and the multiple third target areas are the first preset number of the second target areas ranked by the activity level of the corresponding user. Then, dividing the third target area using the KD Tree algorithm based on the first target location to obtain multiple fourth target areas, with one third target area corresponding to multiple fourth target areas. Next, clustering the fourth target areas using the DBSCAN algorithm to obtain a first cluster. Then, determining the initial cluster center using the KMeans++ algorithm based on the first cluster, and clustering the initial cluster center and the first cluster using the KMeans++ algorithm to obtain a second cluster. Finally, determining the cluster center of the second cluster as the target active location. This application uses the GeoHash algorithm for region partitioning and initial screening of regions, selecting regions with high activity levels as data points for clustering input to ensure the accuracy of the clustering results. Then, the K-DTree algorithm is used to index the sample points, guiding the DBSCAN algorithm for clustering. The K-DTree algorithm is used to classify the data points by region, simplifying the calculation of distances between data points during DBSCAN clustering. Initial clusters are then determined using the DBSCAN algorithm, simplifying the process of determining cluster centers using the KMeans++ algorithm. Finally, the target clusters are obtained using the KMeans++ algorithm, and the user's active region is determined based on these target clusters. This solves the problems of high computational complexity, high resource consumption, and reduced computational efficiency in existing clustering algorithms.
[0178] 2) The user active location determination device of this application includes an encoding unit that determines a first target area and a first target location based on user logs, encodes the first target area using the GeoHash algorithm to obtain multiple second target areas, and determines multiple third target areas based on the second target areas. The first target area is the area the user passes through, the first target location is the user's dwell location, and the multiple third target areas are the first preset number of the second target areas corresponding to the user's activity ranking. A segmentation unit divides the third target area using the K-DTree algorithm based on the first target location to obtain multiple fourth target areas, with one third target area corresponding to multiple fourth target areas. A first clustering unit clusters the fourth target areas using the DBSCAN algorithm to obtain a first cluster cluster. A second clustering unit determines an initial cluster center using the KMeans++ algorithm based on the first cluster cluster, and clusters the initial cluster center and the first cluster cluster using the KMeans++ algorithm to obtain a second cluster cluster. A first determination unit determines the cluster center of the second cluster cluster as the target active location. This application uses the GeoHash algorithm for region partitioning and initial screening of regions, selecting regions with high activity levels as data points for clustering input to ensure the accuracy of the clustering results. Then, it uses the KD Tree algorithm to create an index for the sample points, guiding the DBSCAN algorithm for clustering. The KD Tree algorithm categorizes the data points by region, simplifying the calculation of distances between data points during DBSCAN clustering. The initial clusters are then determined using the DBSCAN algorithm, simplifying the process of determining cluster centers using the KMeans++ algorithm. Finally, the target clusters are obtained using the KMeans++ algorithm, and the user's active region is determined based on these target clusters. This solves the problems of high computational complexity, high resource consumption, and reduced computational efficiency in existing clustering algorithms.
[0179] The above description is merely a preferred embodiment of this application and is not intended to limit this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.
Claims
1. A method for determining a user's active location, characterized in that, include: Based on user logs, a first target area and a first target location are determined. The first target area is encoded using the GeoHash algorithm to obtain multiple second target areas. Multiple third target areas are determined based on the second target areas. The first target area is the area through which the user passes, the first target location is the user's dwell location, and the multiple third target areas are the first preset number of second target areas corresponding to the user's activity ranking. The third target region is divided according to the first target location using the KD Tree algorithm to obtain multiple fourth target regions, and one third target region corresponds to multiple fourth target regions; The first cluster is obtained by clustering the fourth target region using the DBSCAN algorithm. The initial cluster centers are determined using the KMeans++ algorithm based on the first cluster, and the second cluster is obtained by clustering using the KMeans++ algorithm based on the initial cluster centers and the first cluster. The cluster center of the second cluster mentioned above is determined as the target active location.
2. The method according to claim 1, characterized in that, Multiple second target regions are obtained by encoding the first target region using the GeoHash algorithm, including: Multiple first boundary coordinates are determined based on the boundary of the first target area. The first boundary coordinates include the maximum longitude, minimum longitude, maximum latitude, and minimum latitude of the first target area. Each of the boundary coordinates is converted into binary form, and the boundary coordinates in binary form are uniformly divided to obtain multiple second boundary coordinates. The second boundary coordinates include the maximum longitude, minimum longitude, maximum latitude, and minimum latitude of each second target area. The binary representations of the longitude and latitude of the second boundary coordinates are concatenated to obtain candidate GeoHash codes, and the candidate GeoHash codes are truncated according to a preset length to obtain target GeoHash codes. Each GeoHash code corresponds one-to-one with the second target region.
3. The method according to claim 1, characterized in that, Based on the second target region, multiple third target regions are determined, including: Based on the first target location and the second target region, a plurality of first target quantities are determined, wherein the first target quantity is the number of first target locations included in each second target region; If the number of the first target is greater than the second threshold, the corresponding second target region is determined as the sixth target region; The system obtains multiple first coefficients, first target durations, second coefficients, second target durations, second target quantities, and a third coefficient. The first coefficients are the coefficients corresponding to each of the sixth target regions. The first target duration is the sum of the dwell times corresponding to the first target positions in each of the sixth target regions. The second coefficient is the coefficient corresponding to the nine-square grid range centered on any one of the sixth target regions. The second target duration is the sum of the dwell times corresponding to the first target positions included in the nine-square grid range centered on any one of the sixth target regions. The second target quantity is the number of first target positions included in the nine-square grid range centered on any one of the sixth target regions. The third coefficient is the coefficient corresponding to the first target region. The first target value is obtained by multiplying the first coefficient, the first target duration, and the first target quantity; the second target value is obtained by multiplying the second coefficient, the second target duration, the second target quantity, and the third coefficient; and the activity level is obtained by summing the first target value and the second target value. The third target region is determined based on the activity level, the first preset quantity, and the sixth target region. The third target region includes the sixth target region that ranks first preset quantity in terms of activity level for the corresponding user, and the sixth target region within a nine-square grid centered on the sixth target region that ranks first preset quantity in terms of activity level for the corresponding user.
4. The method according to claim 1, characterized in that, Before dividing the third target region using the KD Tree algorithm, the method further includes: The second target location is determined based on the third target region and the first target location, wherein the second target location is the first target location included in the third target region; A sampling rate is obtained, and a target set is determined based on the second target position and the sampling rate. The ratio of the number of third target positions to the number of second target positions in the target set is the sampling rate. The target set is iterated until the target set satisfies a first preset condition, wherein the sum of the minimum Euclidean distances between the fourth target position and the third target position in the target set is maximized, and the fourth target position is the second target position not included in the target set.
5. The method according to claim 4, characterized in that, The third target region is divided using the KD Tree algorithm to obtain multiple fourth target regions, including: The first calculation step involves calculating the variance based on the longitude of each of the third target locations in the third target region to obtain a first variance, and calculating the variance based on the latitude of each of the third target locations in the third target region to obtain a second variance. In the first determination step, if the first variance is greater than the second variance, the median of the longitude of the third target location is determined as the third target value. The third target location is then segmented according to the third target value to obtain two first datasets, completing one segmentation. The two first datasets respectively include the third target location with a longitude greater than the third target value and the third target location with a longitude less than the third target value. The second determination step involves determining the median of the latitude of the third target position in the first dataset as the fourth target value when the number of segmentations is less than the first preset number of segmentations. The first dataset is then segmented according to the fourth target value to obtain two second datasets. The two second datasets respectively include the third target position with a latitude greater than the fourth target value and the third target position with a latitude less than the fourth target value. The third determination step involves, if the number of segmentations is less than the first preset number of segmentations, determining the median of the longitude of the third target location in the second dataset as the third target value, and segmenting the second dataset according to the third target value to obtain two first datasets; The fourth determination step is to determine the median of the latitude of the third target location as the third target value when the second variance is greater than the first variance. The third target location is then segmented according to the third target value to obtain two first datasets, completing one segmentation. The two first datasets respectively include the third target location with a latitude greater than the third target value and the third target location with a latitude less than the third target value. The fifth determination step involves determining the median of the longitude of the third target position in the first dataset as the fourth target value when the number of segmentations is less than the first preset number of segmentations. The first dataset is then segmented according to the fourth target value to obtain two second datasets. The two second datasets respectively include the third target position with a longitude greater than the fourth target value and the third target position with a longitude less than the fourth target value. The sixth determination step is to determine the median of the latitude of the third target position in the second dataset as the third target value when the number of segmentation steps is less than the first preset number of steps, and to segment the second dataset according to the third target value to obtain two first datasets. The second determination step and the third determination step or the fifth determination step and the sixth determination step are repeated at least once until the number of segmentations is equal to the first preset number of times to obtain multiple first datasets or second datasets. The fourth target region is determined based on the first dataset or the second dataset. A fourth target region includes all the third target locations in a first dataset or the second dataset.
6. The method according to claim 4, characterized in that, The first cluster is obtained by clustering the fourth target region using the DBSCAN algorithm, including: The seventh determination step is to determine any one of the third target locations as a target sample point, and to determine the fifth target region with the target sample point as the center and a preset radius. The eighth determination step is as follows: if the number of third target locations in the fifth target region corresponding to the target sample point is greater than the third threshold, the target sample point is determined as the target core point and the other third target locations in the fifth target region are determined as target boundary points. The ninth step is to determine the candidate clusters based on the target core points and the corresponding target boundary points; The tenth determination step is as follows: if the fifth target region corresponding to the target core point in the candidate cluster includes other target core points, the candidate clusters corresponding to the target core point in the fifth target region are merged to obtain the first cluster; if the fifth target region corresponding to the target core point in the candidate cluster does not include other target core points, the candidate cluster is determined as the first cluster. Repeat the seventh, eighth, ninth, and tenth determination steps at least once until all the first clusters are determined.
7. The method according to claim 4, characterized in that, Initial cluster centers are determined using the KMeans++ algorithm based on the first cluster. A second cluster is then obtained by clustering using the KMeans++ algorithm based on the initial cluster centers and the first cluster, including: The screening step involves randomly selecting a second preset number of locations from the third target positions within the first cluster to determine the initial cluster centers. The second calculation step involves calculating the distance between each of the third target locations and each of the initial cluster centers to obtain multiple first target distances, and classifying each of the third target locations into the initial cluster center with the smallest corresponding first target distance to obtain a third cluster. The third calculation step is to calculate the mean of longitude and the mean of latitude corresponding to each of the third target locations in the third cluster to obtain the updated cluster center; The fourth calculation step involves calculating the distance between each of the third target locations and each of the updated cluster centers to obtain multiple second target distances, and then classifying each of the third target locations into the updated cluster center with the smallest corresponding second target distance to update the third cluster. Repeat the third and fourth calculation steps at least once until the distance to the second target corresponding to each third target position in each third cluster is less than the fourth threshold or the number of iterations reaches the second preset number, and then determine each third cluster as the second cluster.
8. A device for determining a user's active location, characterized in that, The device includes: The encoding unit is used to determine a first target area and a first target location based on user logs, encode the first target area based on the GeoHash algorithm to obtain multiple second target areas, and determine multiple third target areas based on the second target areas. The first target area is the area through which the user passes, the first target location is the location where the user stays, and the third target area is a first preset number of second target areas with the highest activity level for the corresponding user. The segmentation unit is used to divide the third target region according to the first target location using the KD Tree algorithm to obtain multiple fourth target regions, wherein one third target region corresponds to multiple fourth target regions; The first clustering unit is used to cluster the fourth target region using the DBSCAN algorithm to obtain the first cluster. The second clustering unit is used to determine the initial cluster center based on the first cluster using the KMeans++ algorithm, and to perform clustering based on the initial cluster center and the first cluster using the KMeans++ algorithm to obtain the second cluster. The first determining unit is used to determine the cluster center of the second cluster as the target active location.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored program, wherein, when the program is executed, it controls the device on which the computer-readable storage medium is located to perform the method according to any one of claims 1 to 7.
10. A user active location monitoring system, characterized in that, include: One or more processors, a memory, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, the one or more programs comprising methods for performing any one of claims 1 to 7.