Cross-event user real-time behavior chain variable calculation method and system

Through the real-time chain variable calculation method of user behavior across events, Redis and Lua scripts are used to solve the problem of difficult to capture user behavior association in the existing technology, and efficient storage and rapid response to user behavior are achieved, which significantly improves the analysis. Accuracy and system performance.

CN118939691APending Publication Date: 2024-11-12重庆富民银行股份有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410944849.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-15
Publication Date
2024-11-12

AI Technical Summary

Technical Problem

The existing technology is difficult to fully capture the chronological order and logical correlation between user behavior, resulting in one-sided analysis results, making it difficult to identify complex fraudulent behaviors and evaluate user risks, and the storage space expansion and maintenance costs increase in high-frequency and large-scale operation scenarios. ,影响系统性能。

Method used

Using the real-time behavior chain variable calculation method of cross-events, describing user behavior sequences by defining chain expressions, storing behavior data using Redis, and using Lua scripts for real-time monitoring and matching, outputting the status of business chain variables, real-time implementation of users Efficient storage and fast response to behavior.

Benefits of technology

Effectively identify and evaluate the fraud risks of user behavior, reduce network interaction costs, improve data processing efficiency and accuracy, support high availability, high concurrency and high scalability, and ensure the timeliness of behavioral data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118939691A_ABST
    Figure CN118939691A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of user real-time behavior processing, in particular to a cross-event user real-time behavior chain variable calculation method and system. Comprising the following steps: defining a chain expression of user cross-event behaviors for describing an ordered or disordered behavior sequence of a user in a specific time period; a Redis database is used for storing user behavior data, and each piece of user behavior data is composed of a behavior identifier and a timestamp; user behaviors are monitored in real time, and behavior events and time stamps of the behavior events are stored in a Redis set; during calling, the behavior data stored in the Redis are traversed and matched through a Lua script to verify whether the user behavior meets the defined chain type expression or not; and outputting the state of the service chain variable according to a matching result. According to the technical scheme, the time sequence and logic association between user behaviors can be comprehensively captured.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of user real-time behavior processing, and in particular to a method and system for calculating chain variables of user real-time behavior across events. Background Art

[0002] In the digital age, user behavior data has become an important cornerstone for corporate decision-making, anti-fraud analysis, and user portrait construction. Especially in high-frequency interactive industries such as finance and e-commerce, users' real-time behavior data not only reflects their consumption habits and preferences, but also implies potential fraud risks and market trends. However, traditional user behavior analysis methods are often limited to single-dimensional data indicators, such as the number of transfers and average consumption within a certain period of time, ignoring the time sequence and logical relationship between user behaviors, making it difficult to fully and accurately portray user behavior patterns and potential risks.

[0003] Most existing systems only perform statistical analysis based on single behavioral events (such as transfers and logins), and fail to examine a series of user behaviors as a whole process, resulting in one-sided analysis results and difficulty in capturing complex behavioral patterns.

[0004] In high-frequency, large-scale operation scenarios, existing methods directly store the full amount of data for each operation into a cache system (such as Redis), which not only causes the storage space to expand rapidly and increases maintenance costs, but may also affect system performance due to excessive data processing burdens.

[0005] In addition, due to the lack of comprehensive analysis of users' cross-event behavior chains, existing anti-fraud systems and user portrait construction methods are unable to identify complex fraud behaviors and assess user risks, and it is difficult to effectively respond to diverse fraud methods and rapidly changing market environments. Summary of the invention

[0006] The purpose of the present invention is to propose a method and system for calculating chain variables of real-time user behaviors across events, and the technical solution can fully capture the time sequence and logical associations between user behaviors.

[0007] To achieve the above-mentioned objectives, in a first aspect, an embodiment of the present disclosure provides a cross-event user real-time behavior chain variable calculation system, including a chain expression that defines the user's cross-event behavior, which is used to describe the ordered or unordered behavior sequence of the user within a specific time period; using a Redis database to store user behavior data, each user behavior data consists of a behavior identifier and a timestamp; real-time monitoring of user behavior, and storing behavior events and their occurrence timestamps in a Redis collection; when called, traversing and matching the behavior data stored in Redis through a Lua script to verify whether the user behavior satisfies the defined chain expression; and outputting the status of the business chain variable according to the matching result.

[0008] Beneficial effects of the basic solution: By defining chain expressions, it is possible to flexibly and accurately describe the user's behavior sequence in multiple dimensions within a specific time period, including the orderliness and disorderliness of the behavior, so as to effectively identify and evaluate the fraud risk or user profile of user behavior in different business scenarios or fields such as finance and e-commerce.

[0009] By utilizing Redis's efficient data processing capabilities, real-time monitoring and efficient storage of user behavior can be achieved. It has high availability, high concurrency, high scalability, and supports data persistence, ensuring the timeliness of behavior data. Combined with the logical processing of Lua scripts, the network interaction cost between applications and redistribution is reduced (such as the number of interactions. Redis natively supports Lua scripts and Redis server-side precompilation, so there is no need for multiple network interactions. Only one interaction is needed to get the final result). It also supports transactions, ensuring the accuracy of data. This method can achieve real-time monitoring and rapid response to user behavior, significantly improving the efficiency and accuracy of data processing.

[0010] As an implementable preferred solution, each user's behavior chain variable is stored in a Redis collection. The key of the collection is user_id_var_id, where user_id is the unique identifier of the user and var_id is the unique identifier of the variable.

[0011] As an implementable preferred solution, when a user performs an operation, the operation event and timestamp are stored in a Redis collection in the format of event name: timestamp.

[0012] As an implementable preferred solution, for each new event, check whether the first two events in the Redis collection are consistent. If they are consistent, check whether they are consistent with the current event. If they are consistent with the current event, delete the previous event and add the current event. If they are inconsistent, directly add the current event.

[0013] As an implementable preferred solution, when a variable needs to be used, the Redis collection data corresponding to the value time is queried through the key to obtain the query result.

[0014] As an implementable preferred solution, a Lua script is used to traverse each element in the collection, check the event type, and determine whether the condition in the expression is satisfied.

[0015] As an implementable preferred solution, the Lua script is also used to perform event time difference calculation, calculate the time difference with the previous event, and ensure that the time difference meets the time window defined in the expression.

[0016] As an implementable preferred solution, if the time difference and type of all events meet the conditions defined in the chain expression, the service chain variable is true, and the result of the service chain variable is output. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] Figure 1 A logical diagram of a method for calculating user real-time event chain variables across events.

[0018] Figure 2 This is a diagram of string storage in the Redis collection after a user opens an account.

[0019] Figure 3 This is a diagram of string storage in the Redis collection after a user signing event.

[0020] Figure 4 This is a diagram of string storage in the Redis collection after the user's first transfer event.

[0021] Figure 5 This is a diagram of string storage in the Redis collection after the user's second transfer event.

[0022] Figure 6 This is a logical diagram of the string storage changes in the Redis collection after the user's third transfer event.

[0023] Figure 7 This is a diagram of string storage in the Redis collection after a user cancels his account.

[0024] Figure 8 Schematic diagram of the structure of an electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION

[0025] In order to make the technical solution and advantages of the present application clearer, the technical solution of the present invention will be further described in detail below in conjunction with the accompanying drawings. It will be understood that the specific embodiments described herein are only partial embodiments of the present invention, which are only used to explain the present application, rather than to limit the present application. It should be noted that the technical features or combinations of technical features described in the following embodiments should not be considered isolated, and they can be combined with each other to achieve better technical effects. The same reference numerals appearing in the drawings of the following embodiments represent the same features or components, which can be applied to different embodiments.

[0026] In addition, unless otherwise defined, the technical terms or scientific terms used in the description of the present invention should have the common meanings understood by those skilled in the art in the art to which the present invention belongs.

[0027] The present invention is further described in detail below in conjunction with the accompanying drawings:

[0028] Reference numerals: electronic device 500 , processor 501 , communication interface 502 , memory 503 , bus 504 .

[0029] Reference Figure 1 , a cross-event user real-time behavior chain variable calculation method, including

[0030] Step S100, a chain expression is defined for the user's cross-event behavior, so as to express the user's real-time behavior within a time period, and whether the real-time behavior is in an ordered (occurring in sequence) or disordered (occurring simultaneously) state.

[0031] The following is an example of an expression, where e1, e2, and e3 represent different real-time user behaviors:

[0032] Example 1: *e1 e2 e3 1h, which means disorder, e1, e2, and e3 appear at the same time within 1 hour;

[0033] Example 2: e1 e2 e3 e1 e2 e3 1h, which means order, e1, e2, e3 appear in sequence within 1 hour (other events may be included in between);

[0034] Example 3: e1 e2|e3 2h, in order, e1 appears within 2 hours and then e2 or e3 appears;

[0035] Example 4: e1#2h e2#5m e3 3h, in order, e1 appears within 3 hours, e2 appears within 2 hours, and e3 appears within 5 minutes.

[0036] Taking a financial scenario as an example, the chain expression of the user's real-time behavior in this scenario is as follows:

[0037] openacct#10m sign transfer|withdraw 1h cancelacct 2h;

[0038] This expression means that within the last 2 hours, the user signed a contract within 10 minutes after account opening, transferred or withdrew funds after signing the contract, and closed the account within 1 hour after the operation.

[0039] Step S200: Redis is used for data storage, and each user's behavior chain variable is stored in a Redis set. The key of the set is user_id_var_id, where user_id is the unique identifier of the user and var_id is the unique identifier of the variable.

[0040] Step S300: When the user performs an operation, the operation event and timestamp are stored in the Redis collection in the format of event name (behavior identifier): timestamp.

[0041] For example, refer to Figure 2 , the user opens an account at 10:00 on January 31, 2024. The key of the redis set storage is user01_var01, the value is [openacct:1706666400] and the score is 1706666400, where 1706666400 is the timestamp of 10:00 on January 31, 2024 (in this embodiment, the timestamp uses the Unix timestamp, that is, the number of seconds since January 1, 1970), and the value is a string of the event name plus ": (colon)" plus the timestamp.

[0042] Step S400, perform storage optimization. For each new event, check whether the first two events in the Redis set are consistent. If they are consistent, check whether they are consistent with the current event; if they are consistent with the current event, delete the previous event and add the current event; if they are inconsistent, add the current event directly. In dealing with high-frequency, large-scale event processing scenarios such as salary payment or batch account transfer, some existing technologies directly store the full amount of data for each operation into a cache system such as Redis, which not only causes a sharp expansion of storage space and increases maintenance costs, but also may significantly drag down system performance due to a large amount of data operations, affecting service response time and overall stability. This technical solution avoids storing a large number of identical events, saves storage costs and improves system performance.

[0043] For example, the user signed a contract at 10:05 on January 31, 2024. Check whether the previous two events in the value set of redis key user01_var01 are consistent. Since there is only an account opening event before, it does not meet the above conditions, so this event is added to the set. Figure 3 , value becomes [openacct: 1706666400, sign: 1706666700] and score is 1706666700.

[0044] The user transferred money at 10:20 on January 31, 2024. The first two events were account opening and contract signing. If the conditions are not met, refer to Figure 4 , add this event to the collection, the value becomes [openacct: 1706666400, sign: 1706666700, transfer: 1706667600], and the score is 1706667600.

[0045] The user performed a transfer operation at 10:23 on January 31, 2024. The first two events were the contract signing event and the transfer event. If the conditions are not met, this event will be added to the collection. Figure 5, the value then becomes [openacct: 1706666400, sign: 1706666700, transfer: 1706667600, transfer: 1706667780], and the score is 1706667780.

[0046] The user made a transfer operation at 10:26 on January 31, 2024. If the previous two events were both transfer events and this event is also a transfer event, the condition is met. At this time, the most recent transfer event needs to be deleted, and the latest transfer event is added to the value. Refer to Figure 6 , the value then becomes [openacct: 1706666400, sign: 1706666700, transfer: 1706667600, transfer: 1706667960], and the score is 1706667960.

[0047] The user closed the account at 10:40 on January 31, 2024. At this time, refer to Figure 7 , the value is [openacct: 1706666400, sign: 1706666700, transfer: 1706667600, transfer: 1706667960, cancelacct: 1706668800], and the score is 1706668800.

[0048] Step S500, when a variable needs to be used, query the Redis set data corresponding to the value time through the key to obtain the query result.

[0049] For example, if the variables of this user (user01) need to be used at 10:50 on January 31, 2024, the set data in Redis with the key user01_var01 and the value time between 8:50 (timestamp: 1706662200) and 10:50 (timestamp: 1706669400) (within 2 hours) can be queried. Since the score stores the timestamp, the data with 1706662200 <= <score <= 1706669400 can be retrieved. The query result at this time is:

[0050] [openacct: 1706666400, sign: 1706666700, transfer: 1706667600, transfer: 1706667960, cancelacct: 1706668800].

[0051] Step S600, using Lua script to traverse the data in the Redis collection, matching according to the chain expression, judging the business chain variable, and for each event, checking whether it meets the conditions in the expression (such as time sequence, time difference, etc.), including:

[0052] Step S601, traverse each element in the collection and check the event type.

[0053] Step S602, perform event time difference calculation, for each event in the chain expression, calculate the time difference with the previous event, and ensure that the time difference meets the time window defined in the expression.

[0054] Step S603: If the time difference and type of all events meet the conditions defined in the chain expression, the service chain variable is true and the result of the service chain variable is output; otherwise, it is false.

[0055] Taking the query result in step S500 as an example, the event list obtained by the query is as follows, and each event includes an event name and a corresponding timestamp:

[0056] openacct:1706666400;

[0057] sign:1706666700;

[0058] transfer:1706667600;

[0059] transfer:1706667960;

[0060] cancelacct:1706668800.

[0061] Convert the timestamp to a more readable datetime format:

[0062] openacct: 2024-01-31 10:00;

[0063] sign: January 31, 2024 10:05;

[0064] transfer: January 31, 2024, 10:20;

[0065] transfer: January 31, 2024 10:23;

[0066] cancelacct: 1 / 31 / 2024 10:26.

[0067] According to the chain expression:

[0068] openacct#10m sign transfer|withdraw 1h cancelacct 2h.

[0069] Verify the following conditions: sign the contract within 10 minutes after opening the account (openacct); transfer or withdraw funds within 1 hour after signing the contract; cancel the account within 2 hours after transferring or withdrawing funds (cancelacct).

[0070] Calculate the time difference between each two consecutive events:

[0071] openacct to sign: 1706666700-1706666400=300 seconds (5 minutes);

[0072] Sign to the first transfer: 1706667600-1706666700=900 seconds (15 minutes);

[0073] From the first transfer to the second transfer: 1706667960-1706667600=360 seconds (6 minutes);

[0074] The second transfer to cancelacct: 1706668800-1706667960=840 seconds (14 minutes).

[0075] Conditional verification is performed to verify whether the requirements of the chain expression are met based on the time difference and event type: sign occurs 5 minutes after openacct, satisfying the condition of within 10 minutes; the first transfer occurs 15 minutes after sign, satisfying the condition of within 1 hour; the second transfer occurs 6 minutes after the first transfer. Although two transfers occur here, according to the chain expression, only the time condition from the first transfer to the account cancellation needs to be verified; cancelacct occurs 14 minutes after the second transfer, satisfying the condition of within 2 hours.

[0076] Since the time difference and type of all events meet the requirements of the chain expression, the result of the business chain variable is true.

[0077] Examples of specific application scenarios:

[0078] In the field of e-commerce, the analysis of user behavior can reveal consumers' purchasing habits and subsequent behavior patterns. For example, consider a user who quickly makes a purchase after logging into his account, but chooses to return the product within 24 hours. These behaviors may indicate that the user has a tendency to make impulse purchases, but then reconsiders and regrets the purchase decision. Through continuous monitoring and analysis of such behaviors, e-commerce platforms can better understand customer needs and preferences through a cross-event user real-time behavior chain variable calculation method, thereby providing more personalized services, while optimizing inventory management and return processes.

[0079] In the financial services industry, real-time monitoring of user behavior is key to preventing fraud and money laundering. Take a user's behavior as an example: the user quickly signed up for a new account, then performed multiple transfer operations in a short period of time, then changed the bank card information bound to it and continued to transfer funds. This series of rapid and unusual behavior patterns may trigger a security alert, indicating that the account may be involved in money laundering or other fraudulent activities. Financial institutions use this in-depth behavioral analysis through a cross-event user real-time behavior chain variable calculation method to strengthen risk management and take timely measures to protect customer assets while complying with regulatory requirements.

[0080] The disclosed embodiment also provides a system for calculating cross-event user real-time behavior chain variables, which uses the above-mentioned cross-event user real-time behavior chain variable calculation method.

[0081] The embodiment of the present disclosure also provides a storage medium, in which a computer program is stored. When the computer program is executed by a processor, all steps of the above-mentioned method for calculating cross-event user real-time behavior chain variables can be implemented.

[0082] Those of ordinary skill in the art can understand that the implementation of all or part of the process in a method for calculating variables of a user's real-time behavior chain across events can be completed by instructing related hardware through a computer program, and the program can be stored in a non-volatile computer-readable storage medium. When the program is executed, it can include the process of each embodiment of a method for calculating variables of a user's real-time behavior chain across events. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.

[0083] The embodiment of the present application 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 implements the steps of the above-mentioned method for calculating variables of a user's real-time behavior chain across events when executing the program. In the embodiment of the present application, the processor is the control center of the computer system, which can be a processor of a physical machine or a processor of a virtual machine.

[0084] Reference Figure 8, the electronic device 500 includes: at least one processor 501, at least one communication interface 502, at least one memory 503 and at least one bus 504. Among them, the bus 504 is used to realize the connection and communication between these components, the communication interface 502 is used to communicate with other node devices for signaling or data, and the memory 503 stores machine-readable instructions executable by the processor 501. When the electronic device 500 is running, the processor 501 communicates with the memory 503 through the bus 504, and the machine-readable instructions are called by the processor 501 to perform the steps of the above-mentioned cross-event user real-time behavior chain variable calculation method. The above content is only an embodiment of the present invention, and the common sense such as the known specific structure and characteristics in the scheme is not described in detail here. Ordinary technicians in the relevant field know all the common technical knowledge in the technical field of the invention before the application date or priority date, can know all the existing technologies in the field, and have the ability to apply conventional experimental means before that date. Ordinary technicians in the relevant field can improve and implement this scheme in combination with their own abilities under the enlightenment given by this application. Some typical known structures or known methods should not become obstacles for ordinary technicians in the relevant field to implement this application. It should be pointed out that for those skilled in the art, several modifications and improvements can be made without departing from the structure of the present invention, which should also be regarded as the protection scope of the present invention, and these will not affect the effect of the implementation of the present invention and the practicality of the patent. The protection scope required by this application shall be based on the content of its claims, and the specific implementation methods and other records in the specification can be used to interpret the content of the claims.

Claims

1. A method for calculating chain variables of real-time user behavior across events, characterized by: Includes chain expressions that define user cross-event behaviors, used to describe ordered or unordered sequences of user behaviors within a specific time period; Use the Redis database to store user behavior data. Each user behavior data consists of a behavior identifier and a timestamp. Monitor user behavior in real time, and store behavior events and their occurrence timestamps in the Redis collection. When called, traverse and match the behavior data stored in Redis through the Lua script to verify whether the user behavior satisfies the defined chain expression. Based on the matching results, output the status of the business chain variable.

2. The method for calculating cross-event user real-time behavior chain variables according to claim 1, characterized in that: Each user's behavior chain variable is stored in a Redis collection; the key of the collection is user_id_var_id, where user_id is the unique identifier of the user and var_id is the unique identifier of the variable.

3. The method for calculating chain variables of real-time user behaviors across events according to claim 1, characterized in that: When a user performs an operation, the operation event and timestamp are stored in the Redis collection in the format of event name: timestamp.

4. The method for calculating cross-event user real-time behavior chain variables according to claim 3, characterized in that: For each new event, check whether the previous two events in the Redis collection are consistent. If they are consistent, check whether they are consistent with the current event. If it is consistent with the current event, delete the previous event and add the current event; If they are inconsistent, the current event is added directly.

5. The method for calculating cross-event user real-time behavior chain variables according to claim 1, characterized in that: When you need to use a variable, query the Redis collection data corresponding to the value time through the key to get the query result.

6. The method for calculating chain variables of real-time user behaviors across events according to claim 1, characterized in that: The Lua script is used to iterate over each element in the collection, check the event type, and determine whether the condition in the expression is met.

7. The method for calculating chain variables of real-time user behaviors across events according to claim 6, characterized in that: The Lua script is also used to perform event time difference calculation, calculate the time difference with the previous event, and ensure that the time difference meets the time window defined in the expression.

8. The method for calculating chain variables of real-time user behaviors across events according to claim 7, characterized in that: If the time difference and type of all events meet the conditions defined in the chain expression, the business chain variable is true and the result of the business chain variable is output.

9. A cross-event user real-time behavior chain variable calculation system, characterized by: A method for calculating cross-event user real-time behavior chain variables as described in any one of claims 1 to 8 is used.