User classification method and apparatus, electronic device, and storage medium
By using bucketed storage and multi-threaded processing of total user access time, and by calculating access time quantiles using target masks, the problem of inaccurate user classification in existing technologies is solved, achieving more efficient user classification and service information recommendation.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-28
- Publication Date
- 2026-03-03
AI Technical Summary
Existing technologies classify users based on a given access duration threshold, which leads to inaccurate classification and makes it impossible to recommend suitable service information to users.
The total access duration of users is stored in buckets using a target mask. The access duration quantile is calculated based on the total access duration and a preset quantile. By using bucket storage and multi-threaded processing, the computation latency and storage space usage are reduced, and the classification accuracy is improved.
It improves the accuracy of user classification and storage space utilization, reduces the latency of calculating access time quantiles, and ensures the appropriateness of recommended service information.
Smart Images

Figure CN117009629B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of user classification technology, and in particular to a user classification method, apparatus, electronic device, and storage medium. Background Technology
[0002] To maintain user engagement with an application (APP), service providers typically use the duration of user access to the APP as a metric to measure user stickiness.
[0003] After determining the duration of a user's access to the app, the user is categorized to recommend suitable services. This process typically involves categorizing users based on a given access duration threshold. While this method achieves user categorization, it is prone to inaccurate categorization, leading to an inability to recommend appropriate services.
[0004] Therefore, there is an urgent need to provide a user classification method. Summary of the Invention
[0005] This invention provides a user classification method, apparatus, electronic device, and storage medium to address the deficiencies in the prior art.
[0006] This invention provides a user classification method, comprising:
[0007] Get the total access duration of each user to the target object, and store the total access durations in buckets based on the target mask;
[0008] Based on the total access duration and the preset quantile, determine the initial position corresponding to the preset quantile, and calculate the access duration quantile at the preset quantile based on the initial position and the number of elements in each bucket.
[0009] Users are categorized based on their total access duration and access duration percentile.
[0010] According to a user classification method provided by the present invention, the step of calculating the access duration quantile at the preset quantile based on the initial position and the number of elements in each bucket specifically includes:
[0011] Based on the identifiers of each bucket, the buckets are sorted to obtain the first sorting result;
[0012] Starting from the first bucket in the first sorting result, based on the difference information between the current position and the number of elements in the current bucket, the target bucket in each bucket and the target position of the preset position in the target bucket are determined; the current position is determined based on the difference information corresponding to the previous position, and the initial value of the current position is the initial position;
[0013] Sort the elements in the target bucket to obtain a second sorting result;
[0014] Based on the target location and the second sorting result, the access duration quantile is determined.
[0015] According to a user classification method provided by the present invention, the step of storing each total access duration in buckets based on a target mask includes:
[0016] Based on the target mask, each total access duration is divided into an index segment and a content segment;
[0017] Using multi-threading, the content segment of each total access duration is stored in a bucket identified by the index segment.
[0018] According to a user classification method provided by the present invention, the step of dividing each total access duration into an index segment and a content segment based on the target mask includes:
[0019] Based on the non-zero bits of the target mask, shift operations and logical operations are used to divide each total access duration into an index segment and a content segment.
[0020] According to a user classification method provided by the present invention, the step of determining the initial position corresponding to the access duration quantile based on the total access duration and the preset quantile includes:
[0021] Store each bucket in memory;
[0022] If the memory capacity is insufficient, buckets with a content segment count greater than the threshold value corresponding to the target mask are selected from the buckets and written to the disk.
[0023] According to a user classification method provided by the present invention, the target mask is determined based on the following method:
[0024] The optimal mask range is determined based on the total number of access durations and the content segments of each total access duration.
[0025] Determine any one of the masks within the optimal mask range as the target mask.
[0026] According to a user classification method provided by the present invention, the step of classifying each user based on the total access time and the access time quantiles includes:
[0027] Based on the classification results corresponding to each user, service information is recommended for each user.
[0028] The present invention also provides a user classification device, comprising:
[0029] The bucketed storage module is used to obtain the total access time of each user to the target object, and to store each total access time in buckets based on the target mask.
[0030] The quantile calculation module is used to determine the initial position corresponding to the preset quantile based on the total access time and the preset quantile, and to calculate the access time quantile at the preset quantile based on the initial position and the number of elements in each bucket.
[0031] The classification module is used to classify each user based on the total access time and the access time percentile.
[0032] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the user classification method as described above.
[0033] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the user classification method as described above.
[0034] The present invention also provides a computer program product, including a computer program that, when executed by a processor, implements the user classification method as described above.
[0035] The user classification method, apparatus, electronic device, and storage medium provided by this invention, through target masks, divide and store the total access durations into buckets. This not only makes more efficient use of storage space but also improves the efficiency of bucketed storage by using target masks. Due to the introduction of buckets, the calculation step of access duration quantiles does not require full sorting or full indexing of the total access durations, reducing the latency of calculating access duration quantiles and improving the calculation efficiency. Compared to existing technologies that classify users based on a given access duration threshold, using access duration quantiles considers the relationship between the total access durations of each user, resulting in more accurate user classification and providing a basis for recommending appropriate service information to users subsequently. Attached Figure Description
[0036] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, those skilled in the art can obtain other drawings based on the drawings described below without creative effort.
[0037] Figure 1 This is a flowchart illustrating the user classification method provided by the present invention;
[0038] Figure 2 This is a schematic diagram of the user classification device provided by the present invention;
[0039] Figure 3 This is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation
[0040] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0041] In existing technologies, after determining the duration of a user's access to an application (APP), users are typically categorized based on a given access duration threshold. This method leads to inaccurate categorization, resulting in the inability to recommend suitable service information to users. Therefore, this invention provides a user categorization method.
[0042] Figure 1 This is a flowchart illustrating a user classification method provided in an embodiment of the present invention, such as... Figure 1 As shown, the method includes:
[0043] S11, obtain the total access time of each user to the target object, and store the total access time in buckets based on the target mask;
[0044] S12, based on the total access time and the preset percentile, determine the initial position corresponding to the preset percentile, and based on the initial position and the number of elements in each bucket, calculate the access time percentile at the preset percentile.
[0045] S13. Based on the total access duration and the access duration percentile, classify each user.
[0046] Specifically, the user classification method provided in this embodiment of the invention is executed by a user classification device, which can be configured in a server. The server can be a local server or a cloud server. The local server can be a computer, etc., and this embodiment of the invention does not make specific limitations.
[0047] First, execute step S11 to obtain the total access time of each user to the target object. The target object can be an app, a webpage, a website, etc., without specific limitations. The total access time refers to the cumulative access time of each user to the target object at the current moment and before, and the unit of this total access time can be hours (h) or days, etc. It can be understood that each user has a corresponding total access time.
[0048] Then, based on the target mask, the total access times are bucketed and stored. Both the target mask and each total access time can be represented by binary numbers, and the number of bits in the target mask can be the same as the number of bits in each total access time. The target mask can include non-zero bits and zero bits. The number of non-zero bits can be set as needed and is not specifically limited here. For example, the number of non-zero bits can be set to 8, then the number of zero bits is the difference between the number of bits in the target mask and 8.
[0049] In this embodiment of the invention, the total access time and target mask for each user can both be long integer data types, i.e., long data types, and their bit length can both be 64 bits.
[0050] The total access duration can be segmented using the target mask, and the segmentation results can be stored in buckets. The segmentation results can include first information for marking the buckets and second information for marking each access duration and storing it in the bucket.
[0051] Then, step S12 is executed to determine the initial position corresponding to the preset percentile based on the total access time and the preset percentile. Since each user has a corresponding total access time, the total access time can be understood as the total number of users. The preset percentile is a pre-defined percentile standard, expressed as a percentage. For example, it can be at least one of the 20th percentile, 30th percentile, 40th percentile, 60th percentile, and 80th percentile; that is, there can be one or more preset percentiles.
[0052] By using the total access duration and the preset percentile, the initial position corresponding to the preset percentile can be determined. This initial position can be the product of the total access duration and the preset percentile. For example, if the position is represented as Rank, the total access duration as total, and the preset percentile as p, then the initial position can be represented as Rank = p * total.
[0053] Then, by combining the initial position and the number of elements in each bucket, the access duration quantile at the preset quantile can be calculated. The number of elements in each bucket can be understood as the number of total access durations with the same first information, and the elements in each bucket can be understood as the second information that marks the total access duration corresponding to the first information of that bucket.
[0054] The process of calculating the access duration quantile can be as follows: first, sort each bucket, and then iteratively determine the target bucket where the preset quantile is located based on the initial position. Further determine the position of the preset quantile in the target bucket, and then determine the element stored in the target bucket where the preset quantile is located, i.e., the second information. After that, the total access duration corresponding to the second information is the access duration quantile at the preset quantile.
[0055] It is understandable that when there is one preset quantile, if the preset quantile is a 2-quantile, then there is one access duration quantile; if the preset quantile is a 3-quantile, then there are two access duration quantiles. That is, the number of access duration quantiles = the number of preset quantiles - 1. When there are multiple preset quantiles, there are also multiple access duration quantiles.
[0056] Since it's impossible to load massive amounts of data into memory at once to calculate quantiles, there are currently two common methods for calculating quantiles. The first method is to build a full binary tree index to calculate quantiles. The second method is to use external sorting to calculate quantiles.
[0057] Building a full binary tree index to quickly calculate quantiles can effectively improve query efficiency, but its drawbacks become apparent with increasing data volume. In big data scenarios, while directly querying quantiles using a full binary tree index results in low latency, building such an index on massive datasets is a time-consuming process and consumes enormous storage space. Both of these aspects are current pain points, especially when queries are normally distributed or relatively concentrated, resulting in a large number of attribute columns being indexed but queried infrequently. In such scenarios, the index resource overhead becomes unprofitable. Therefore, the method of building a full binary tree index to calculate quantiles suffers from excessively long index building time and excessive persistent storage space consumption.
[0058] The external sorting method involves two steps: first, sorting each segment of the input file using an appropriate internal sorting method; then, merging the segments generated in the first stage using a merge algorithm until only one merged segment remains; finally, using the sorted result to calculate quantiles. The drawback of this method is that each query requires multiple I / O operations, resulting in a long query time, especially noticeable in scenarios with frequent quantile queries. In other words, directly using external sorting to calculate quantiles suffers from excessively long query times.
[0059] Compared to existing quantile calculation methods, this embodiment of the invention determines the initial position corresponding to the preset quantile by using the total access duration and the preset quantile, and then calculates the access duration quantile at the preset quantile using the initial position and the number of elements in each bucket. Due to the introduction of each bucket, the calculation step for the access duration quantile does not require full sorting or full indexing of each total access duration, thus reducing the latency of calculating the access duration quantile and improving the calculation efficiency.
[0060] Finally, step S13 is executed. The access duration quantile can be used to classify the total access duration of each user, thereby classifying each user. The number of user categories can be equal to the access duration quantile + 1, meaning that the total access duration on both sides of each access duration quantile belongs to different user categories.
[0061] Furthermore, based on the total access duration and the access duration quantiles, the relationship between the total access duration and the access duration quantiles can be determined to identify the category of each user. Each user's category can be used to characterize the user's activity level towards the target object. The activity level can include multiple levels, such as very low, lower, medium, higher, and very high.
[0062] The user classification method provided in this embodiment of the invention uses a target mask to bucket the total access durations, which not only makes more efficient use of storage space but also improves the efficiency of bucketed storage through the use of the target mask. Due to the introduction of each bucket, the calculation step of the access duration quantile does not require a full sorting or full indexing of the total access durations, reducing the latency of calculating the access duration quantile and improving the calculation efficiency. Compared to the prior art that classifies users based on a given access duration threshold, using access duration quantiles considers the relationship between the total access durations of each user, making the user classification results more accurate and providing a basis for recommending appropriate service information to users subsequently.
[0063] Based on the above embodiments, the user classification method provided in this embodiment of the invention, which calculates the access duration quantile at the preset quantile based on the initial position and the number of elements in each bucket, specifically includes:
[0064] Based on the identifiers of each bucket, the buckets are sorted to obtain the first sorting result;
[0065] Starting from the first bucket in the first sorting result, based on the difference information between the current position and the number of elements in the current bucket, the target bucket in each bucket and the target position of the preset position in the target bucket are determined; the current position is determined based on the difference information corresponding to the previous position, and the initial value of the current position is the initial position;
[0066] Sort the elements in the target bucket to obtain a second sorting result;
[0067] Based on the target location and the second sorting result, the access duration quantile is determined.
[0068] Specifically, in this embodiment of the invention, when calculating the access duration quantiles, each bucket can be sorted according to its identifier, i.e., the first information of the total access duration. The buckets can be sorted in ascending order of the identifiers to obtain the first sorting result.
[0069] Then, starting from the first bucket in the first sorting result, the target buckets in each bucket and the target positions of the preset quantiles within the target buckets can be determined based on the difference between the current position and the number of elements in the current bucket. This difference information can be the size relationship between the two and the difference between them.
[0070] It is understandable that the initial value of the current position is the initial position, and the current position can be determined by the difference information corresponding to the previous position. The difference information corresponding to the previous position refers to the difference information between the previous position and the number of elements in the previous bucket.
[0071] This process is iterative and can be achieved through the following steps:
[0072]
[0073] Where target_backet is the target bucket, bucket is the current bucket, and bucket[] is the first sorted result.
[0074] After exiting the FOR loop via BREAK in Line 5, you can obtain the target bucket target_backet and the target position Rank of the preset quantile within the target bucket.
[0075] Afterwards, the elements in the target bucket can be sorted to obtain a second sorting result. When sorting the elements in the target bucket, an index can be configured for each element. This second sorting result is the sorting result of the elements according to the index, which can be an ascending sorting result.
[0076] Based on the target location, the corresponding access duration quantile can be found from the second sorting results. Configuring the index and finding the access duration quantile can be achieved through the following process:
[0077] In this embodiment of the invention, during the process of determining the access duration quantiles, only the elements within the bucket and the target bucket are sorted, and only the elements within the target bucket are indexed. It is not necessary to perform a full sort or build a full index for each total access duration. This reduces the latency of calculating the access duration quantiles, improves the calculation efficiency, and allows for more efficient use of storage space. Even when the total access duration is normally distributed or relatively concentrated, storage resources are not wasted. Furthermore, it reduces the number of I / O operations required to calculate the access duration quantiles, enabling fast calculation even in scenarios where access duration quantiles need to be frequently calculated.
[0078] Based on the above embodiments, the user classification method provided in this embodiment of the invention, which involves storing the total access duration in buckets based on a target mask, includes:
[0079] Based on the target mask, each total access duration is divided into an index segment and a content segment;
[0080] Using multi-threading, the content segment of each total access duration is stored in a bucket identified by the index segment.
[0081] Specifically, in this embodiment of the invention, when storing each total access duration in buckets, each total access duration can be divided into an index segment and a content segment using a target mask. The index segment is the first information, and the content segment is the second information.
[0082] The index segment can be obtained by dividing the data and taking the quotient, specifically using the function f_index(value) = value / mask. Here, value is the total access duration, and mask is the target mask.
[0083] The content segment can be obtained by dividing and taking the remainder, that is, by using the function f_tail(value) = value % mask.
[0084] Subsequently, a bucket can be created using the index segment of each total access duration as an identifier, and the content segment of that total access duration can be stored in that bucket. This process can be implemented using multithreading. Since multiple index segments with different total access durations may be the same, buckets can be used to group and store the total access durations.
[0085] In this embodiment of the invention, the complete steps of storing each total access duration in buckets may include:
[0086] Read all total access duration values and process each value according to steps S21 to S23.
[0087] S21, use the target mask to group and store the values into different buckets. The index segment of the value can be obtained by the function f_index(value) = value / mask, and the content segment can be obtained by f_tail(value) = value%mask.
[0088] S22. If f_index(value) does not exist, create a bucket with f_index(value) as the key. If f_index(value) exists, execute S23 directly.
[0089] S23, store f_tail(value) into the bucket, and increment the number of elements cnt in the bucket by one.
[0090] S24. After looping through all values, iterate through all buckets once, sort and store them as backet[], and count the total number of values, i.e. the total number of access times.
[0091] The above steps can be achieved through the following process:
[0092]
[0093]
[0094] In this embodiment of the invention, only the content segments of each total access duration are stored in the bucket, which can reduce the storage space occupied.
[0095] Based on the above embodiments, the user classification method provided in this embodiment of the invention, which divides each total access duration into an index segment and a content segment based on the target mask, includes:
[0096] Based on the non-zero bits of the target mask, shift operations and logical operations are used to divide each total access duration into an index segment and a content segment.
[0097] Specifically, in this embodiment of the invention, when dividing each total access duration into an index segment and a content segment, the non-zero bits of the target mask can be used, and shift operations and logical operations can be employed. That is, the index segment can be obtained using the IP mask concept, determined through a combination of shift operations and logical operations, specifically by `head = value >>> (64-digit)`. Here, `value` represents a certain total access duration, and `digit` represents the non-zero bits in the target mask.
[0098] The content segment can also be obtained using the IP mask concept, determined by a combination of bit shifting and logical operations, i.e., by tail = value & (~0l>>>digit).
[0099] Understandably, for each total access duration, splitting the target mask into index and content segments using bitwise operations only requires four calculations: subtraction, shift, shift, and AND.
[0100] Since the process of a computer calculating x / y is essentially a process of continuously subtracting y from x, let ri represent the remainder obtained after the i-th operation. Then we have:
[0101] If ri>0, then the quotient is 1, the remainder and the quotient are shifted left by 1 position, and then the divisor is subtracted, that is, ri+1=2ri-y;
[0102] If ri < 0, then the quotient is 0, the remainder and the quotient are shifted left by 1 position, and the divisor is added, that is, ri + 1 = 2ri + y.
[0103] A 64-bit division operation requires 128 additions, subtractions, and shift operations, which has a time complexity 32 times that of a shift operation.
[0104] Therefore, computer division is far more complex than bitwise operations. By using shift operations and logical operations to split the target mask into index segments and content segments, computational efficiency can be greatly improved.
[0105] Based on the above embodiments, the user classification method provided in this embodiment of the invention, wherein sorting each element in the target bucket to obtain a second sorting result includes:
[0106] Multithreading is used to index and create elements in the target bucket;
[0107] Based on the index of each element, the elements are sorted to obtain the second sorting result.
[0108] Specifically, in this embodiment of the invention, during the process of sorting the elements in the target bucket to obtain the second sorting result, multi-threading can be used to create indexes for each element in the target bucket, and then sort the elements according to the created indexes to obtain the second sorting result. This not only maximizes the use of the computer operating system's multi-threading capabilities but also improves the calculation efficiency of access time quantiles.
[0109] Based on the above embodiments, the user classification method provided in this embodiment of the invention, which involves storing each total access duration in buckets based on a target mask, includes:
[0110] Based on the target mask, multi-threading is used to divide and store the total access time into buckets.
[0111] Specifically, in this embodiment of the invention, when storing each total access duration in buckets, multi-threaded synchronous storage of each total access duration can be implemented. This not only maximizes the use of the computer operating system's multi-threading, but also improves the calculation efficiency of the access duration quantile.
[0112] According to tests, the loading rate of the access duration quantile is directly proportional to the number of threads. The read time of the access duration quantile is reduced by (1 - 1 / number of threads) * 100%.
[0113] Based on the above embodiments, the user classification method provided in this embodiment of the invention, before determining the initial position corresponding to the access duration quantile based on the total access duration and the preset quantile, includes:
[0114] Store each bucket in memory;
[0115] If the memory capacity is insufficient, buckets with a content segment count greater than the threshold value corresponding to the target mask are selected from the buckets and written to the disk.
[0116] Specifically, in this embodiment of the invention, after storing each total access duration in buckets using the target mask, each bucket can be stored in memory first, which can reduce the number of I / O operations.
[0117] When memory capacity is insufficient, buckets with a number of content segments exceeding a certain threshold can be selected from various buckets and written to disk. The threshold can be set as needed, but it should not be too high or too low. If it is too high, it may lead to insufficient memory utilization later. If it is too low, it may lead to excessive I / O operations. Experiments showed that the final access time quantile calculation time was reduced by (1 - memory size / number of content segments) * 100%.
[0118] The quantity threshold can be set as needed, corresponding to the target mask. It can be the maximum capacity of buckets identified by index segments after dividing the total access time by the target mask, allowing for flexible adjustment of the target mask to minimize the number of I / O operations and optimize algorithm efficiency. Theoretically, the larger the quantity threshold, the larger the data volume of a single batch I / O, the fewer the number of I / O operations per batch, and the higher the overall efficiency of the algorithm. Furthermore, the quantity threshold is at most equal to the maximum capacity of each bucket after applying the target mask. However, in reality, the quantity threshold cannot be increased without limit due to limited memory.
[0119] In this embodiment of the invention, memory and disk are used together as storage space, which can make full use of storage space and reduce the number of I / O operations.
[0120] Based on the above embodiments, the user classification method provided in this embodiment of the invention determines the target mask based on the following method:
[0121] The optimal mask range is determined based on the total number of access durations and the content segments of each total access duration.
[0122] Determine any one of the masks within the optimal mask range as the target mask.
[0123] Specifically, in this embodiment of the invention, the target mask may be a mask randomly selected from the optimal mask range. The optimal mask range may be determined based on the total number of access times in the actual deployment scenario and the size of the content segment of each total access time.
[0124] In this embodiment of the invention, the quantity threshold corresponding to the target mask can be the optimal quantity threshold determined for each mask within the optimal mask range after determining the optimal mask range, so as to find the optimal configuration [target mask, quantity threshold]. This can minimize the number of I / O operations, thereby further improving the calculation efficiency of access duration quantiles.
[0125] Based on the above embodiments, the user classification method and access duration quantile calculation method provided in this embodiment of the invention, compared with the external sorting method and the full indexing method in the prior art, show that the number of I / O operations per query of the external sorting method is at least n times that of other methods. In big data scenarios, n is very large, so it has the lowest efficiency in the scenario of calculating access duration quantiles. The calculation method proposed in this embodiment of the invention has an index construction I / O operation n / m that is 1 / log n of the full index. Since n is much greater than 2, the number of I / O operations in the index construction process in this embodiment of the invention is less than that of the full index, and the number of I / O operations per query is 1, which is less than or equal to the number of I / O operations of the full index. See Table 1 for details. In summary, the calculation method in this embodiment of the invention has the best time performance.
[0126] Table 1 Comparison of I / O Counts
[0127] Index building process Single quantile lookup External sorting method 0 n*log n / m Full indexing method n*log n / m log n / m>1? log n / m:1 Calculation method in this invention n / m 1
[0128] Based on the above embodiments, the user classification method provided in this embodiment of the invention classifies users by using the total access time and the access time percentile, and then includes:
[0129] Based on the classification results corresponding to each user, service information is recommended for each user.
[0130] Specifically, in this embodiment of the invention, after classifying each user, service information can be recommended to each user based on the classification results. It is understood that the classification results refer to the user's category. Therefore, recommending service information to each user means recommending appropriate service information to users of different categories. This ensures the relevance and rationality of the service information recommendations, improves user experience, and helps increase user stickiness.
[0131] like Figure 2 As shown, based on the above embodiments, this embodiment of the invention provides a user classification device, including:
[0132] Bucket storage module 21 is used to obtain the total access time of each user to the target object, and to store each total access time in buckets based on the target mask.
[0133] The quantile calculation module 22 is used to determine the initial position corresponding to the preset quantile based on the total access time and the preset quantile, and to calculate the access time quantile at the preset quantile based on the initial position and the number of elements in each bucket.
[0134] The classification module 23 is used to classify each user based on the total access time and the access time percentile.
[0135] Based on the above embodiments, the user classification device provided in this embodiment of the invention, wherein the quantile calculation module is specifically used for:
[0136] Based on the identifiers of each bucket, the buckets are sorted to obtain the first sorting result;
[0137] Starting from the first bucket in the first sorting result, based on the difference information between the current position and the number of elements in the current bucket, the target bucket in each bucket and the target position of the preset position in the target bucket are determined; the current position is determined based on the difference information corresponding to the previous position, and the initial value of the current position is the initial position;
[0138] Sort the elements in the target bucket to obtain a second sorting result;
[0139] Based on the target location and the second sorting result, the access duration quantile is determined.
[0140] Based on the above embodiments, the user classification device provided in this embodiment of the invention, wherein the bucket storage module is specifically used for:
[0141] Based on the target mask, each total access duration is divided into an index segment and a content segment;
[0142] Using multi-threading, the content segment of each total access duration is stored in a bucket identified by the index segment.
[0143] Based on the above embodiments, the user classification device provided in this embodiment of the invention, wherein the bucket storage module is further specifically used for:
[0144] Based on the non-zero bits of the target mask, shift operations and logical operations are used to divide each total access duration into an index segment and a content segment.
[0145] Based on the above embodiments, the user classification device provided in this embodiment of the invention further includes a storage module, used for:
[0146] Store each bucket in memory;
[0147] If the memory capacity is insufficient, buckets with a content segment count greater than the threshold value corresponding to the target mask are selected from the buckets and written to the disk.
[0148] Based on the above embodiments, the user classification device provided in this embodiment of the invention further includes a mask determination module, used for:
[0149] The optimal mask range is determined based on the total number of access durations and the size of the content segments for each total access duration.
[0150] Use any mask within the optimal mask range as the target mask.
[0151] Based on the above embodiments, the user classification device provided in this embodiment of the invention further includes a recommendation module, used for:
[0152] Based on the classification results corresponding to each user, service information is recommended for each user.
[0153] Specifically, the functions of each module in the user classification device provided in this embodiment correspond one-to-one with the operation flow of each step in the above method embodiment, and the achieved effect is also the same. Please refer to the above embodiments for details, and this will not be repeated in this embodiment.
[0154] Figure 3 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 3 As shown, the electronic device may include a processor 310, a communications interface 320, a memory 330, and a communication bus 340, wherein the processor 310, the communications interface 320, and the memory 330 communicate with each other through the communication bus 340. The processor 310 can call logical instructions in the memory 330 to execute the user classification method provided in the above embodiments. The method includes: obtaining the total access time of each user to the target object, and storing the total access time in buckets based on the target mask; determining the initial position corresponding to the preset quantile based on the total access time and the preset quantile, and calculating the access time quantile at the preset quantile based on the initial position and the number of elements in each bucket; and classifying each user based on the total access time and the access time quantile.
[0155] Furthermore, the logical instructions in the aforementioned memory 330 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0156] On the other hand, the present invention also provides a computer program product, which includes a computer program that can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the user classification method provided by the above methods. The method includes: obtaining the total access duration of each user to a target object, and storing the total access durations in buckets based on a target mask; determining the initial position corresponding to the preset quantile based on the total access duration and a preset quantile, and calculating the access duration quantile at the preset quantile based on the initial position and the number of elements in each bucket; and classifying each user based on the total access duration and the access duration quantile.
[0157] In another aspect, the present invention also provides a non-transitory computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the user classification method provided by the above methods. The method includes: obtaining the total access duration of each user to a target object, and storing the total access durations in buckets based on a target mask; determining the initial position corresponding to the preset quantile based on the total access duration and a preset quantile, and calculating the access duration quantile at the preset quantile based on the initial position and the number of elements in each bucket; and classifying each user based on the total access duration and the access duration quantile.
[0158] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0159] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0160] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method of classifying users, characterized by, The method comprises the following steps: obtaining the total access duration of each user to a target object, and storing the total access duration in buckets based on a target mask; determining an initial position corresponding to the access duration quantile based on the number of total access durations and a preset quantile, and calculating the access duration quantile at the preset quantile based on the initial position and the number of elements in each bucket; classifying each user based on the total access duration and the access duration quantile; The method of calculating the access duration quantile at the preset quantile based on the initial position and the number of elements in each bucket comprises the following steps: sorting each bucket based on its identifier to obtain a first sorting result; starting from the first bucket in the first sorting result, determining a target bucket in each bucket and a target position of the preset quantile in the target bucket based on the difference information between the current position and the number of elements in the current bucket; the current position is determined based on the difference information corresponding to the previous position of the current position, and the initial value of the current position is the initial position; sorting each element in the target bucket to obtain a second sorting result; determining the access duration quantile based on the target position and the second sorting result; The method of storing the total access duration in buckets based on the target mask comprises the following steps: dividing each total access duration into an index segment and a content segment based on the target mask; storing the content segment of each total access duration into a bucket identified by the index segment using multi-threading; The method of dividing each total access duration into an index segment and a content segment based on the target mask comprises the following steps: based on the number of non-zero bits of the target mask, dividing each total access duration into an index segment and a content segment using a shift operation method and a logical operation method.
2. The user classification method of claim 1, wherein, The method of determining the initial position corresponding to the access duration quantile based on the number of total access durations and the preset quantile comprises the following steps: storing each bucket in the memory; if the capacity of the memory is insufficient, writing into the disk the buckets whose content segment number is greater than the number threshold corresponding to the target mask.
3. The user classification method of claim 1, wherein, The target mask is determined based on the following method: determining an optimal mask range according to the number of total access durations and the size of the content segment of each total access duration; taking any mask within the optimal mask range as the target mask.
4. The user classification method of claim 1, wherein, The method of classifying each user based on the total access duration and the access duration quantile comprises the following steps: based on the classification results corresponding to each user, recommending service information to each user.
5. A user classification apparatus characterized by comprising: The method comprises the following steps: a bucket storage module for obtaining the total access duration of each user to a target object, and storing the total access duration in buckets based on a target mask; a quantile calculation module for determining an initial position corresponding to the access duration quantile based on the number of total access durations and a preset quantile, and calculating the access duration quantile at the preset quantile based on the initial position and the number of elements in each bucket; a classification module for classifying each user based on the total access duration and the access duration quantile; The bucket storage module is specifically used for: Based on the number of non-zero bits of the target mask, each total access duration is divided into an index segment and a content segment by using a shift operation mode and a logic operation mode; By using multi-threading, the content segment of each total access duration is stored into a bucket identified by the index segment; The split number calculation module is specifically configured to: Sort the buckets based on their identifiers to obtain a first sorting result; Starting from the first bucket in the first sorting result, determine a target bucket in the buckets and a target position of the preset split number in the target bucket based on difference information between a current position and a number of elements in the current bucket; the current position is determined based on difference information corresponding to a previous position of the current position, and an initial value of the current position is the initial position; Sort the elements in the target bucket to obtain a second sorting result; Determine the access duration split number based on the target position and the second sorting result.
6. An electronic device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, The processor executes the program to implement the user classification method of any one of claims 1 to 4.
7. A non-transitory computer-readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to implement the user classification method of any one of claims 1 to 4.
Citation Information
Patent Citations
Access duration processing method and device, equipment and readable medium
CN107402864A
User classification method based on user behavior analysis
CN107592346A