Scene analysis method and device based on causal inference, equipment and storage medium

By extracting effective causes and conditions from the causal inference algorithm and constructing a segmented scenario, the problem that experts need to adjust the causal inference results is solved, and in-depth analysis of target variables and effective adjustments in the business environment are achieved.

CN120234553APending Publication Date: 2025-07-01SF TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311853706.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-12-28
Publication Date
2025-07-01

AI Technical Summary

Technical Problem

The results of the existing causal inference algorithm cannot be directly used for segmented scenario analysis in the business environment, and need to be adjusted based on expert experience, and the causal relationship of the target variable under different conditions cannot be effectively identified.

Method used

By obtaining the set of reasons and conditions to be screened in the business environment, using the causal inference algorithm to extract effective reasons and conditions, constructing a set of candidate conditions, calculating the average causal effect value of the condition, and obtaining effective subdivided scenarios that affect the target variable.

Benefits of technology

In-depth analysis of target variables is achieved, and subdivided scenarios with greater causal effects can be identified under specific conditions, providing more effective business adjustment guidance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120234553A_ABST
    Figure CN120234553A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of data processing, in particular to a scene analysis method and device based on causal inference, equipment and a storage medium. The method comprises the steps of obtaining a to-be-screened reason set and a to-be-screened condition set related to a target variable in a business environment; based on the to-be-screened reason set and the to-be-screened condition set, an effective reason set is extracted from the to-be-screened reason set, and the to-be-screened condition set and to-be-screened reasons not belonging to the effective reason set are constructed into a candidate condition set; based on the candidate condition set and the effective reason set, extracting an effective condition which has a conditional causal effect with the target variable from the candidate condition set; based on the effective condition and the effective reason, an effective subdivision scene influencing the target variable in the service environment is obtained, and the effective subdivision scene is used for adjusting related services of the target variable. According to the method and the device, the reasons and conditions of the target variable in the business environment can be deeply analyzed, and the business related to the target variable is effectively adjusted.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of data processing, and in particular, to a scenario analysis method, apparatus, device, and storage medium based on causal inference. Background Art

[0002] In various business environments such as e-commerce and logistics, causal inference is usually used to identify whether a certain intervention (Treatment) has an impact on a target variable, that is, whether it has a causal effect. For example, in new drug research and development, it is to identify whether a drug can cure a certain disease, and in a marketing scenario, it is to identify whether a coupon can bring about an increase in revenue. If you want to know what are the reasons for a change in a certain target variable, causal discovery algorithms are usually used to identify, and then a causal graph is obtained. However, the results obtained by current causal discovery algorithms often cannot be directly used and need to be adjusted in combination with expert experience. The final result is often a relatively rough result, which cannot show in detail in what scenarios the target variable will change, and cannot achieve effective adjustment of related businesses through the analysis results. Summary of the Invention

[0003] Based on the above defects and deficiencies of the prior art, the present application proposes a scenario analysis method, apparatus, device, and storage medium based on causal inference, which can deeply analyze the reasons and conditions related to the target variable in the business environment and achieve effective adjustment of the business related to the target variable.

[0004] According to the first aspect of the embodiments of the present application, a scenario analysis method based on causal inference is provided, including: obtaining a set of candidate reasons and a set of candidate conditions related to a target variable in a business environment, where the set of candidate reasons includes sample data corresponding to at least one candidate reason respectively, and the set of candidate conditions includes sample data corresponding to at least one candidate condition respectively; based on the set of candidate reasons and the set of candidate conditions, extracting a set of effective reasons from the set of candidate reasons, and constructing the set of candidate conditions and the candidate reasons that do not belong to the set of effective reasons into a set of candidate conditions, where the set of effective reasons includes at least one effective reason having a causal effect on the target variable; based on the set of candidate conditions and the set of effective reasons, extracting effective conditions having a conditional causal effect on the target variable from the set of candidate conditions; based on the effective conditions and the effective reasons, obtaining effective sub-scenarios in the business environment that affect the target variable, where the effective sub-scenarios are used to adjust the business related to the target variable.

[0005] According to the scenario analysis method based on causal inference provided in the first aspect of the embodiments of the present application, extracting, from the candidate condition set, valid conditions that have a conditional causal effect on the target variable based on the candidate condition set and the valid cause set includes: for each valid cause in the valid cause set: calculating the conditional average causal effect value of all valid causes on the target variable under each candidate condition in the candidate condition set; and taking the candidate conditions with the conditional average causal effect value greater than the second threshold as the valid conditions.

[0006] According to the scenario analysis method based on causal inference provided in the first aspect of the embodiments of the present application, calculating the conditional average causal effect value of all valid causes on the target variable under each candidate condition in the candidate condition set; and taking the candidate conditions with the conditional average causal effect value greater than the second threshold as the valid conditions includes: traversing each candidate condition in the candidate condition set: extracting, from the set of reasons to be screened and the set of conditions to be screened, a subset of data that meets the candidate condition and all the valid conditions determined in the past; based on the subset of data, using the causal effect calculation algorithm to calculate the conditional average causal effect value of the valid cause on the target variable; and if the conditional average causal effect value is greater than the second threshold, determining the candidate condition as the valid condition.

[0007] According to the scenario analysis method based on causal inference provided in the first aspect of the embodiments of the present application, during the process of traversing any one candidate condition in the candidate condition set, the second threshold is the sum of the conditional average causal effect value of the valid cause on the target variable and the preset deviation threshold under all the valid conditions determined in the past.

[0008] According to the scenario analysis method based on causal inference provided in the first aspect of the embodiments of the present application, obtaining the valid sub-scenarios that affect the target variable in the business environment based on the valid conditions and the valid causes includes: during the process of traversing any one candidate condition in the candidate condition set, constructing a valid sub-scenario based on the valid cause and all the valid conditions determined in the past.

[0009] According to the scenario analysis method based on causal inference provided in the first aspect of the embodiments of the present application, the obtaining of the set of candidate causes and the set of candidate conditions related to the target variable in the business environment includes: obtaining the original cause sample data and the original condition sample data related to the target variable in the business environment; performing one-hot encoding on the categorical data in the original cause sample data, and performing binning processing on the continuous variables in the original cause sample data and then performing one-hot encoding to obtain the set of candidate causes; and performing one-hot encoding on the categorical data in the original condition sample data, and performing binning processing on the continuous variables in the original condition sample data and then performing one-hot encoding to obtain the set of candidate conditions.

[0010] According to the scenario analysis method based on causal inference provided in the first aspect of the embodiments of the present application, the extracting of the set of effective causes from the set of candidate causes based on the set of candidate causes and the set of candidate conditions includes: calculating the average causal effect value of each of the candidate causes on the target variable based on the set of candidate causes and the set of candidate conditions; taking the candidate causes with the average causal effect value greater than the first threshold as the effective causes, and integrating all the effective causes into the set of effective causes.

[0011] According to the second aspect of the embodiments of the present application, there is provided a scenario analysis device based on causal inference, including: a data acquisition module, configured to obtain a set of candidate causes and a set of candidate conditions related to a target variable in a business environment, where the set of candidate causes includes sample data corresponding to at least one candidate cause respectively, and the set of candidate conditions includes sample data corresponding to at least one candidate condition respectively; a cause screening module, configured to extract a set of effective causes from the set of candidate causes based on the set of candidate causes and the set of candidate conditions, and construct the set of candidate conditions and the candidate causes that do not belong to the set of effective causes into a candidate condition set, where the set of effective causes includes at least one effective cause having a causal effect on the target variable; a condition screening module, configured to extract effective conditions having a conditional causal effect on the target variable from the candidate condition set based on the candidate condition set and the set of effective causes; a scenario acquisition module, configured to obtain an effective sub-scenario in the business environment that affects the target variable based on the effective conditions and the effective causes, where the effective sub-scenario is used to adjust the related business of the target variable.

[0012] According to a third aspect of the embodiments of the present application, an electronic device is provided, including: a memory and a processor; the memory is connected to the processor and is used for storing programs; the processor is used for implementing the scenario analysis method based on causal inference as described in the first aspect by running the programs stored in the memory.

[0013] According to a fourth aspect of the embodiments of the present application, a storage medium is provided, on which a computer program is stored. When the computer program is run by a processor, the scenario analysis method based on causal inference as described in the first aspect is implemented.

[0014] In the embodiments of the present application, a set of candidate reasons and a set of candidate conditions related to a target variable in a business environment are obtained. The set of candidate reasons includes sample data corresponding to at least one candidate reason respectively, and the set of candidate conditions includes sample data corresponding to at least one candidate condition respectively. Based on the set of candidate reasons and the set of candidate conditions, an effective reason set is extracted from the set of candidate reasons, and the set of candidate conditions and the candidate reasons that do not belong to the effective reason set are constructed into a candidate condition set. The effective reason set includes at least one effective reason having a causal effect on the target variable. Based on the candidate condition set and the effective reason set, effective conditions having a conditional causal effect on the target variable are extracted from the candidate condition set. Based on the effective conditions and the effective reasons, effective sub-scenarios affecting the target variable in the business environment are obtained. The effective sub-scenarios are used to adjust the related business of the target variable. In the above process, after obtaining the effective reason set, further on the basis of the effective reasons, effective conditions are extracted, so as to obtain effective sub-scenarios. Compared with a simple causal inference process, this process realizes a deep analysis of the candidate reasons and candidate conditions related to the target variable, finds effective sub-scenarios with a greater causal effect under specific conditions, and the effective sub-scenarios have a more effective guiding significance for the target variable in the business environment, and can effectively adjust the business related to the target variable through the effective sub-scenarios. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art. Obviously, the drawings in the following description are only the embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained according to the provided drawings without creative efforts.

[0016] Figure 1 It is a schematic flowchart of a scenario analysis method based on causal inference provided by the embodiments of the present application;

[0017] Figure 2Schematic flowchart of the process for extracting the set of effective causes provided by the embodiments of the present application;

[0018] Figure 3 Schematic flowchart of the process for extracting effective conditions provided by the embodiments of the present application;

[0019] Figure 4 Block diagram of a scenario analysis device based on causal inference provided by the embodiments of the present application;

[0020] Figure 5 Schematic structural diagram of an electronic device provided by the embodiments of the present application. Detailed implementation manners

[0021] Next, the technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.

[0022] Application Overview

[0023] Causal reasoning is to infer the influence of one thing on another. Existing causal inference algorithms usually analyze through causal diagrams. However, the causal diagrams obtained by existing algorithms often cannot be directly used and need to be adjusted in combination with expert experience. At the same time, in many cases, only the causes that trigger the occurrence of a certain target variable are concerned, rather than whether there are further causal relationships between these causes. For example, in the business diagnosis scenario, more attention is paid to what operations a merchant can perform under what circumstances to bring about an increase in revenue. In this case, "what operations to perform" can be used as the cause that may bring about an increase in revenue, while "under what circumstances to operate" corresponds to a certain condition. Based on this, in a large business environment, how to accurately identify the effective sub-scenarios for the target variable based on multiple causes and conditions is more important for a certain business scenario, and the effective sub-scenarios are more instructive for the relevant business of the target variable in this business environment.

[0024] Exemplary Method

[0025] Based on the above, the present application provides a scenario analysis method based on causal inference, as Figure 1 shown, and the steps of the method are as follows:

[0026] Step 101: Obtain a set of candidate reasons and a set of candidate conditions related to a target variable in a business environment. The set of candidate reasons includes sample data corresponding to at least one candidate reason, and the set of candidate conditions includes sample data corresponding to at least one candidate condition.

[0027] In this embodiment, in any business environment, when it is necessary to analyze the effective segmentation scenarios in the business environment, this method can be adopted. The business environment can be any one of various business environments such as logistics, e-commerce, and physical sales. The candidate reason refers to a reason that may have an impact on the target variable in the business environment, and the candidate condition refers to a condition that may have an impact on the target variable in the business environment. The target variable refers to a variable that needs to be analyzed in the business environment, and it is a variable affected by reasons and conditions in the business environment. For example, in the business environment of item sales, the two operations of "merchant advertising" and "price reduction" are two candidate reasons, "advertising channels" and "target user groups" are two candidate conditions, and "whether it brings revenue increase" is the target variable.

[0028] During the normal progress of the corresponding business in the business environment, collect the sample data of each candidate reason and integrate them into the set of candidate reasons. The sample data corresponding to each candidate reason may be one piece of data or multiple sets of data. For example, collect the sample data of whether the merchant advertises at different time periods, and all of them are used as the sample data of the candidate condition "merchant advertising". Similarly, during the normal progress of the corresponding business in the business environment, collect the sample data of each candidate condition and integrate them into the set of candidate conditions. The sample data corresponding to each candidate condition may be one piece of data or multiple sets of data. For example, different advertising channels such as TV advertising and online advertising have different impacts on revenue increase at different time periods. Different time periods and different channels result in different revenue increases, so the sample data collected under different time periods and different channels are all used as the sample data of the candidate condition "advertising channels".

[0029] Step 102: Based on the set of candidate reasons and the set of candidate conditions, extract a set of effective reasons from the set of candidate reasons, and construct the set of candidate conditions and the candidate reasons that do not belong to the set of effective reasons into a set of candidate conditions. The set of effective reasons includes at least one effective reason that has a causal effect on the target variable.

[0030] In this embodiment, the reasons to be screened are only the reasons that may affect the target variable obtained in advance. To improve the accuracy of this method, based on the set of reasons to be screened and the set of conditions to be screened that may affect the target variable, at least one effective reason is extracted from at least one reason to be screened in the set of reasons to be screened, and all the effective reasons are collectively referred to as the set of effective reasons. At the same time, all the conditions to be screened in the set of conditions to be screened and all the reasons to be screened that do not belong to the effective reasons are used as candidate conditions, and the set is referred to as the set of candidate conditions.

[0031] In this embodiment, an effective reason refers to a reason that has a causal effect on the target variable. Whether there is a causal effect with the target variable can be measured by a pre-set causal inference algorithm, and this causal inference algorithm can adopt any algorithm that can measure the causal effect. For example, the Conditional Outcome Modeling (COM for short, also known as S-learner), the Grouped Conditional Outcome Modeling (GCOM for short, also known as T-leaner), the Double Machine Learning algorithm (DML), the Propensity Score Matching (PSM), or any other causal inference algorithm.

[0032] Step 103: Based on the set of candidate conditions and the set of effective reasons, extract the effective conditions that have a conditional causal effect on the target variable from the set of candidate conditions.

[0033] In this embodiment, after extracting the set of effective reasons, based on the set of candidate conditions and the set of effective reasons, the effective conditions that truly have a conditional causal effect on the target variable are screened out from the set of candidate conditions. It should be noted that whether there is a conditional causal effect with the target variable can be measured by a pre-set conditional causal inference algorithm, and the conditional causal inference algorithm can adopt any algorithm that can measure the conditional causal effect. For example, S-learner, T-learner, or PSM, etc.

[0034] Step 104: Based on the effective conditions and the effective reasons, obtain the effective sub-scenarios that affect the target variable in the business environment, where the effective sub-scenarios are used to adjust the relevant business of the target variable.

[0035] In this embodiment, after extracting both the effective conditions and effective reasons, an effective sub-scenario that affects the target variable in the business environment is constructed through the effective conditions and effective reasons. The effective sub-scenario is constructed by any one effective reason and at least one effective condition. This effective sub-scenario can detailedly characterize under what conditions and for what reasons the target variable can achieve better effects, and has guiding significance for the adjustment of the business related to the target variable in the business environment.

[0036] In one embodiment, a set of candidate reasons and a set of candidate conditions related to the target variable in the business environment are obtained as follows: Obtain the original reason sample data and original condition sample data related to the target variable in the business environment; perform one-hot encoding on the categorical data in the original reason sample data, and perform binning on the continuous variables in the original reason sample data followed by one-hot encoding to obtain the set of candidate reasons; and, perform one-hot encoding on the categorical data in the original condition sample data, and perform binning on the continuous variables in the original condition sample data followed by one-hot encoding to obtain the set of candidate conditions.

[0037] In this embodiment, in order to improve the data processing efficiency and reduce the data processing difficulty, the original reason sample data and original condition sample data collected from the business environment are digitized and standardized, so as to facilitate further processing of the data subsequently.

[0038] Specifically, the set of candidate reasons is denoted as W(w1, w2, w3,..., w n ), where w1, w2, w3,..., w n respectively represent the sample data corresponding to different candidate reasons, and n is the total number of candidate reasons. The set of candidate conditions is denoted as X(x1, x2, x3,..., x m ), where x1, x2, x3,..., x m respectively represent the sample data corresponding to different candidate conditions, and m is the total number of candidate conditions. If it is impossible to determine whether a certain feature should be placed in W or in X, it can be placed in both at the same time. The target variable is denoted as Y. When collecting samples, a certain proportion of positive and negative samples need to be collected, that is, samples with target variable Y = 0 and Y = 1. The ratio of positive sample data to negative sample data should not be too large or too small, so as to enable reasonable analysis of all sample data subsequently.

[0039] Further, in most common causal inference algorithms, the intervention (Treatment) mostly takes values as categorical variables, that is, 0 or 1 represents different categories. To facilitate the identification of causal effects using different causal inference algorithms, the original cause sample data and the original conditional sample data are processed. For categorical data, one-hot encoding (onehot encoding) is performed. For example, for any categorical variable (this variable refers to a cause or a condition) with a value range of ['A', 'B', 'C'], the original sample data (original cause sample data or original conditional sample data) corresponding to this categorical variable is one-hot encoded and becomes w k _A (takes the value of 1 when it is 'A' and 0 when it is not 'A'), w k _B (takes the value of 1 when it is 'B' and 0 when it is not 'B') w k _C (takes the value of 1 when it is 'C' and 0 when it is not 'C').

[0040] For continuous variables, the continuous variable can be binned first to become a categorical variable, and then the corresponding original sample data is also one-hot encoded. For example, for a certain continuous variable with a value range of 0 to 30, after binning, it becomes 0 to 10, 10 to 20, 20 to 30, then after one-hot encoding, it becomes w j _10 (whether it is greater than or equal to 0 and less than 10), w k _20 (whether it is greater than or equal to 10 and less than 20) w k _30 (whether it is greater than or equal to 20 and less than 30). In the following descriptions, both W and X are encoded sample data.

[0041] In one embodiment, based on the set of candidate causes and the set of candidate conditions, an effective cause set is extracted from the set of candidate causes, specifically as follows: Based on the set of candidate causes and the set of candidate conditions, calculate the average causal effect value of each candidate cause on the target variable; The candidate causes with average causal effect values greater than the first threshold are used as effective causes, and all effective causes are integrated into an effective cause set.

[0042] In this embodiment, to extract the effective cause set from the set of candidate causes, the average causal effect value (Average Treatment Effect, ATE) corresponding to each candidate cause is calculated using a preset causal inference algorithm. When the ATE of any candidate cause is greater than the first threshold, this candidate cause is used as an effective cause and added to the effective cause set. Among them, the first threshold is a threshold preset according to the actual situation and needs, and the protection scope of this application is not limited by the specific value of the first threshold.

[0043] Specifically, such as Figure 2As shown in the figure, the process of extracting the set of effective causes is as follows:

[0044] Step 201, variable initialization: Set the target variable Y (the corresponding sample data is Y_train), set the set of causal models M, and initialize M to be empty. Set the set of effective causes as T and initialize T to be empty. The set of causes to be screened is W (w1, w2, w3,..., w n ) and the set of conditions to be screened is X (x1, x2, x3,..., x m );

[0045] Step 202, sequentially take out w i from W, where i ranges from 1 to n;

[0046] Step 203, take w i as the Treatment, and denote the corresponding sample data as T_train. Take the sample data of X and other causes in W except w i as the model input data, denoted as X_train;

[0047] It should be noted that if the proportion of sample data with Treatment being 1 is less than the preset minimum threshold or greater than the preset maximum threshold, for example, all sample data corresponding to Treatment are 1 or the number of samples with Treatment being 1 is extremely small, then the situation of the target variable when Treatment is 0 cannot be known, and thus causal inference cannot be carried out. Skip this w i ;

[0048] Step 204, train the causal model and calculate the ATE corresponding to w i ;

[0049] Specifically, taking the T-leaner as an example for the causal inference algorithm, use the T-leaner to calculate the ATE of the Treatment. The basic model used by the T-learner can be a decision tree, a random forest, a Gradient Boosting Decision Tree (GBDT), or any other basic model that can complete the corresponding algorithm. Here, linear regression is taken as an example;

[0050] Pre-divide various sample data such as Y_train, T_train, and X_train into a training set and a validation set according to a certain proportion. For example, divide the sample data corresponding to any cause to be screened according to a certain proportion, and also divide the sample data corresponding to any condition to be screened according to a certain proportion. The obtained training set is used to train the causal model, and the validation set is used to calculate the ATE;

[0051] The training and usage process of the causal model is as follows:

[0052] Define the model, Learner = TLearner(models = LinearRegression()), where TLearner indicates that the causal model Learner adopts the T-learner algorithm, and the basic model used by T-learner adopts linear regression (LinearRegression);

[0053] Fit the model using the training set, Learner.fit(X = X_train, T = T_train, y = Y_train);

[0054] Calculate ATE through the validation set, ATE = Learner.effect(X_val);

[0055] Step 205, determine whether ATE is greater than the first threshold. If so, it is considered that there is a causal effect on Y, and execute Step 206. If not, execute Step 207; i For Y, execute Step 206 if there is a causal effect, and execute Step 207 if not;

[0056] Step 206, add w i to T, and at the same time add the causal model Learner to M;

[0057] Step 207, determine whether i is greater than or equal to n. If so, execute Step 208. If not, execute Step 202;

[0058] Step 208, the effective condition screening is completed, and output T and M.

[0059] In one embodiment, based on the candidate condition set and the effective cause set, extract the effective conditions that have a conditional causal effect on the target variable from the candidate condition set, specifically as follows:

[0060] For each effective cause in the effective cause set: calculate the conditional average causal effect value of all effective causes on the target variable under each candidate condition in the candidate condition set; use the candidate conditions with the conditional average causal effect value greater than the second threshold as effective conditions.

[0061] In this embodiment, after screening out the effective conditions from the reasons to be screened, the effective conditions are further extracted from the total candidate conditions. When extracting the effective conditions, a preset conditional causal inference algorithm is used to calculate the conditional average treatment effect (CATE) of all effective reasons on the target variable under each candidate condition. When the CATE corresponding to any candidate condition is greater than the second threshold, the candidate condition is taken as an effective condition. Among them, the second threshold is a threshold preset according to the actual situation and needs, and the protection scope of this application is not limited by the specific value of the second threshold.

[0062] In one embodiment, the conditional average treatment effect value of all effective reasons on the target variable is calculated under each candidate condition in the candidate condition set; the candidate conditions with the conditional average treatment effect value greater than the second threshold are used as effective conditions, specifically as follows:

[0063] Traverse each candidate condition in the candidate condition set: extract the sub-data set that meets the candidate condition and all the effective conditions determined in history from the set of reasons to be screened and the set of conditions to be screened; based on the sub-data set, calculate the conditional average treatment effect value of the effective reasons on the target variable; if the conditional average treatment effect value is greater than the second threshold, determine the candidate condition as an effective condition.

[0064] In this embodiment, the CATE is calculated through a conditional causal model. Therefore, before calculating the conditional average treatment effect value, it is necessary to extract the sub-data set that meets the candidate condition and all the effective conditions determined in history from the set of reasons to be screened and the set of conditions to be screened, correctly divide the training set and the validation set with the correct sub-data set, correctly train the conditional causal model, and calculate the correct CATE through the validation set. Of course, for the sub-data set, if the proportion of sample data with Treatment being 1 is less than the minimum threshold or greater than the maximum threshold, causal inference cannot be performed either, and the conditional causal effect returns 0, or the calculation of this candidate condition is directly skipped.

[0065] In one implementation, the conditional causal model directly uses the causal model Learner corresponding to each Treatment in the causal model set obtained in the above embodiment, that is, CATE = Learner.effect(X_val_sub). At this time, the input data of the conditional causal model can be all the sample data corresponding to all the causes in X in the sub-data set and all the other causes W except Treatment; it is also possible to pre-divide the sub-data combination into a sub-training set and a sub-validation set, and the input data of the conditional causal model is all the sample data corresponding to all the causes in X in the sub-validation set and all the other causes W except Treatment (denoted as X_train_sub).

[0066] In another implementation, the model is retrained and CATE is calculated. The sub-data set is pre-divided into a sub-training set and a sub-validation set. Similarly, taking the T-leaner in the causal inference algorithm as an example, the basic model of the T-learner uses linear regression. The training and use process of the conditional causal model is as follows:

[0067] Define the model, Learner = TLearner(models = LinearRegression()), where TLearner represents that the causal model Learner uses the T-leaner algorithm, and the basic model used by the T-learner uses linear regression (LinearRegression);

[0068] Use the sub-training set to fit the model, Learner.fit(X = X_train_sub, T = T_train_sub, y = Y_train_sub), where T_train_sub represents the sample data corresponding to any valid condition T in the sub-training set i when it is used as Treatment, and Y_train_sub represents the sample data corresponding to the target variable Y in the sub-data set;

[0069] Calculate CATE = Learner.effect(X_val_sub) through the sub-validation set.

[0070] In one embodiment, during the process of traversing any candidate condition in the candidate condition set, the second threshold is the sum of the conditional average causal effect value of the effective cause on the target variable and the preset deviation threshold under all the effective conditions determined in history.

[0071] In this embodiment, the second threshold is determined based on all the determined effective conditions, which can effectively improve the screening accuracy of the candidate conditions. The preset deviation threshold is preset according to the actual situation and needs.

[0072] In one embodiment, based on valid conditions and valid reasons, valid sub-scenarios that affect the target variable in the business environment are obtained as follows: During the process of traversing any candidate condition in the candidate condition set, based on the valid reasons and all the valid conditions that have been determined historically, a valid sub-scenario is constructed.

[0073] In this embodiment, each time a candidate condition is processed, a valid sub-scenario can be constructed based on the valid reasons and all the valid conditions that have been determined historically. In this way, more valid sub-scenarios can be obtained, and the specific situation of the target variable in the case of multiple combinations of valid conditions and valid reasons can be known, which can provide more practical information for the adjustment of the target variable in the business environment.

[0074] In a specific embodiment, based on the above embodiment, as Figure 3 shown, the process of extracting valid conditions is as follows:

[0075] Step 301, set the valid sub-scenario set R and initialize R to be empty;

[0076] Step 302, set the valid condition list L corresponding to each valid reason T i where the valid condition list L includes (Treatment, the causal effect value of the valid condition CATE_valid, the valid condition C_valid). When initializing, the conditional causal effect CATE_valid is empty and the valid condition C_valid is empty; set the candidate condition set C, and the candidate condition set C includes all candidate conditions not in the T list;

[0077] Step 303, sequentially extract each T i from T as Treatment;

[0078] Step 304, set the historical candidate condition set C_his and initialize C_his to be empty;

[0079] Step 305, sequentially extract each c i from C, and determine whether c i does not exist in the C_valid and C_his corresponding to T. If so, execute Step 306; if not, execute Step 309; i i

[0080] Step 306, extract the sub-data set based on c i and the valid conditions in C_valid, calculate the conditional causal effect value CATE_valid_c i corresponding to T i and update ci to C_his;

[0081] Step 307, determine whether CATE_valid_c i is greater than CATE_valid plus a preset deviation threshold. If so, it is considered that c i is a valid condition, and step 308 is executed. If not, step 309 is executed;

[0082] Step 308, update (Treatment, conditional causal effect CATE_valid_c i , condition C_valid+[c i ) to L and R respectively, and update c i to C_his;

[0083] Step 309, determine whether each c in C has been traversed i . If so, step 310 is executed. If not, step 305 is executed;

[0084] Step 310, determine whether each T in T has been traversed i . If so, step 311 is executed. If not, step 303 is executed;

[0085] Step 311, remove duplicates from R and output the deduplicated R.

[0086] In this embodiment, the deduplicated R is the required set of valid sub-scenarios. By removing duplicates, redundant data can be filtered out.

[0087] The scenario analysis method based on causal inference provided by this application obtains a set of candidate causes and a set of candidate conditions related to the target variable in the business environment. Among them, the set of candidate causes includes sample data corresponding to at least one candidate cause respectively, and the set of candidate conditions includes sample data corresponding to at least one candidate condition respectively; based on the set of candidate causes and the set of candidate conditions, an effective cause set is extracted from the set of candidate causes, and the set of candidate conditions and the candidate causes that do not belong to the effective cause set are constructed into a candidate condition set. Among them, the effective cause set includes at least one effective cause that has a causal effect on the target variable; based on the candidate condition set and the effective cause set, effective conditions that have a conditional causal effect on the target variable are extracted from the candidate condition set; based on the effective conditions and the effective causes, effective sub-scenarios that affect the target variable in the business environment are obtained. Among them, the effective sub-scenarios are used to adjust the related operations of the target variable. In the above process, after obtaining the effective cause set, further on the basis of the effective causes, effective conditions are extracted, so as to obtain effective sub-scenarios. Compared with a simple causal inference process, this process realizes a deep analysis of the candidate causes and candidate conditions related to the target variable, finds effective sub-scenarios with greater causal effects under specific conditions, and these effective sub-scenarios have more effective guiding significance for the target variable in the business environment, and can effectively adjust the operations related to the target variable through these effective sub-scenarios.

[0088] Exemplary Device

[0089] Correspondingly, an embodiment of this application also provides a scenario analysis device based on causal inference, which is applied to the scenario analysis method based on causal inference provided in each of the above embodiments. As Figure 4 shown, the scenario analysis device based on causal inference includes:

[0090] A data acquisition module 401, configured to obtain a set of candidate causes and a set of candidate conditions related to the target variable in the business environment. Among them, the set of candidate causes includes sample data corresponding to at least one candidate cause respectively, and the set of candidate conditions includes sample data corresponding to at least one candidate condition respectively;

[0091] A cause screening module 402, configured to extract an effective cause set from the set of candidate causes based on the set of candidate causes and the set of candidate conditions, and construct the set of candidate conditions and the candidate causes that do not belong to the effective cause set into a candidate condition set. Among them, the effective cause set includes at least one effective cause that has a causal effect on the target variable;

[0092] A condition screening module 403, configured to extract effective conditions that have a conditional causal effect on the target variable from the candidate condition set based on the candidate condition set and the effective cause set;

[0093] A scenario acquisition module 404, configured to obtain valid sub - scenarios in a business environment that affect a target variable based on valid conditions and valid reasons, where the valid sub - scenarios are used to adjust related operations of the target variable.

[0094] In one embodiment, a condition screening module 403 is configured to, for each valid reason in a set of valid reasons: calculate the conditional average causal effect value of all valid reasons on the target variable under each candidate condition in a set of candidate conditions respectively; and use the candidate conditions with the conditional average causal effect value greater than a second threshold as valid conditions.

[0095] In one embodiment, a condition screening module 403 is configured to traverse each candidate condition in a set of candidate conditions: extract a sub - data set that meets the candidate condition and all previously determined valid conditions from a set of reasons to be screened and a set of conditions to be screened; calculate the conditional average causal effect value of valid reasons on the target variable based on the sub - data set using a causal effect calculation algorithm; and if the conditional average causal effect value is greater than the second threshold, determine the candidate condition as a valid condition.

[0096] In one embodiment, during the process of traversing any candidate condition in a set of candidate conditions, the second threshold is the sum of the conditional average causal effect value of valid reasons on the target variable under all previously determined valid conditions and a preset deviation threshold.

[0097] In one embodiment, a condition screening module 403 is configured to construct a valid sub - scenario based on valid reasons and all previously determined valid conditions during the process of traversing any candidate condition in a set of candidate conditions.

[0098] In one embodiment, a data acquisition module 401 is configured to obtain original reason sample data and original condition sample data related to a target variable in a business environment; perform one - hot encoding on categorical data in the original reason sample data, perform binning on continuous variables in the original reason sample data and then perform one - hot encoding to obtain a set of reasons to be screened; and perform one - hot encoding on categorical data in the original condition sample data, perform binning on continuous variables in the original condition sample data and then perform one - hot encoding to obtain a set of conditions to be screened.

[0099] In one embodiment, a reason screening module 402 is configured to calculate the average causal effect value of each reason to be screened on the target variable based on the set of reasons to be screened and the set of conditions to be screened; use the reasons to be screened with the average causal effect value greater than a first threshold as valid reasons, and integrate all valid reasons into a set of valid reasons.

[0100] The scenario analysis device based on causal inference provided in this embodiment belongs to the same inventive concept as the scenario analysis method based on causal inference provided in the above embodiments of the present application. It can execute the scenario analysis method based on causal inference provided in any of the above embodiments of the present application, and has the corresponding functional modules and beneficial effects for executing the method. For technical details not described in detail in this embodiment, reference may be made to the specific processing content of the scenario analysis method based on causal inference provided in the above embodiments of the present application, which will not be elaborated here.

[0101] Exemplary Electronic Device

[0102] An embodiment of the present application also provides an electronic device, as Figure 5 shown. The electronic device includes: a memory 500 and a processor 501.

[0103] The memory 500 is connected to the processor 501 and is used for storing programs.

[0104] The processor 501 is used to implement the scenario analysis method based on causal inference in the above embodiments by running the programs stored in the memory 500.

[0105] Specifically, the above electronic device may further include: a communication interface 502, an input device 503, an output device 504, and a bus 505.

[0106] The processor 501, the memory 500, the communication interface 502, the input device 503, and the output device 504 are interconnected through the bus. Among them:

[0107] The bus 505 may include a path for transmitting information between various components of the computer system.

[0108] The processor 501 may be a general-purpose processor, such as a general-purpose central processing unit (CPU), a microprocessor, etc., or an application-specific integrated circuit (ASIC), or one or more integrated circuits for controlling the execution of the program of the present invention. It may also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.

[0109] The processor 501 may include a main processor, and may also include a baseband chip, a modem, etc.

[0110] The program for implementing the technical solution of the present invention is stored in the memory 500, and the operating system and other key services can also be stored. Specifically, the program can include program code, and the program code includes computer operation instructions. More specifically, the memory 500 can include a read-only memory (ROM), other types of static storage devices that can store static information and instructions, a random access memory (RAM), other types of dynamic storage devices that can store information and instructions, a disk memory, a flash memory, and so on.

[0111] The input device 503 can include devices for receiving data and information input by a user, such as a keyboard, a mouse, a camera, a scanner, a light pen, a voice input device, a touch screen, a pedometer, or a gravity sensor, etc.

[0112] The output device 504 can include devices for allowing information to be output to a user, such as a display screen, a printer, a speaker, etc.

[0113] The communication interface 502 can include devices of any transceiver type for communicating with other devices or communication networks, such as Ethernet, a radio access network (RAN), a wireless local area network (WLAN), etc.

[0114] The processor 501 executes the program stored in the memory 500 and calls other devices, and can be used to implement each step of the method for scenario analysis based on causal inference provided in the above embodiments of the present application.

[0115] Exemplary Computer Program Product and Storage Medium

[0116] In addition to the above methods and devices, an embodiment of the present application can also be a computer program product, which includes computer program instructions. When the computer program instructions are run by a processor, the processor is caused to execute the steps in the method for scenario analysis based on causal inference described in the embodiments of the present application.

[0117] The computer program product can be written in any combination of one or more programming languages for programming code to perform the operations of the embodiments of the present application. The programming languages include object-oriented programming languages, such as Java, C++, etc., and also include conventional procedural programming languages, such as the "C" language or similar programming languages. The program code can be executed completely on a user computing device, partially on a user device, executed as an independent software package, partially on a user computing device and partially on a remote computing device, or executed completely on a remote computing device or server.

[0118] In addition, an embodiment of the present application may also be a storage medium, on which a computer program is stored, and the computer program is executed by a processor to perform the steps in the scenario analysis method based on causal inference described in the embodiments of the present application.

[0119] For the foregoing method embodiments, for the sake of simple description, they are all expressed as a series of action combinations. However, those skilled in the art should know that the present application is not limited by the described action sequence, because according to the present application, certain steps may be in other sequences or performed simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily essential to the present application.

[0120] It should be noted that the embodiments in this specification are all described in a progressive manner. Each embodiment focuses on the differences from other embodiments. The same or similar parts among the embodiments can be referred to each other. For the device embodiments, since they are basically similar to the method embodiments, they are described relatively simply, and the relevant parts can be referred to the partial description of the method embodiments.

[0121] The steps in the methods of the embodiments of the present application can be adjusted, combined, and deleted according to actual needs, and the technical features recorded in each embodiment can be replaced or combined.

[0122] The modules and sub-modules in the devices and terminals in the embodiments of the present application can be combined, divided, and deleted according to actual needs.

[0123] In several embodiments provided by the present application, it should be understood that the disclosed terminals, devices, and methods can be implemented in other ways. For example, the terminal embodiments described above are merely illustrative. For example, the division of modules or sub-modules is only a logical function division. In actual implementation, there may be other division methods. For example, multiple sub-modules or modules can be combined or integrated into another module, or some features can be ignored or not executed. Another point is that the displayed or discussed mutual coupling or direct coupling or communication connection can be through some interfaces, and the indirect coupling or communication connection of devices or modules can be in electrical, mechanical, or other forms.

[0124] The modules or sub-modules described as separate components may or may not be physically separated. The components as modules or sub-modules may or may not be physical modules or sub-modules, that is, they can be located in one place, or distributed to multiple network modules or sub-modules. Some or all of the modules or sub-modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0125] In addition, in each embodiment of the present application, each functional module or sub-module can be integrated into a processing module, or each module or sub-module can exist physically alone, or two or more modules or sub-modules can be integrated into one module. The above-mentioned integrated module or sub-module can be implemented in the form of hardware or in the form of a software functional module or sub-module.

[0126] Those skilled in the art can further realize that the units and algorithm steps of each example described in combination with the embodiments disclosed herein can be implemented by electronic hardware, computer software, or a combination of the two. To clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described according to functions in the above description. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Skilled professionals can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of this application.

[0127] The steps of the method or algorithm described in combination with the embodiments disclosed herein can be directly implemented by hardware, a software unit executed by a processor, or a combination of the two. The software unit can be placed in a random access memory (RAM), internal memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, register, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the technical field.

[0128] Finally, it should also be noted that in this article, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the term "comprising", "including" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements not only includes those elements, but also includes other elements not expressly listed, or further includes elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "including one..." does not exclude the existence of additional identical elements in the process, method, article or device including the said element.

[0129] The foregoing description of the disclosed embodiments enables those skilled in the art to practice or use the present application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Thus, the present application is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A scenario analysis method based on causal inference, characterized in that Including: Obtaining a set of candidate reasons and a set of candidate conditions related to a target variable in a business environment, where the set of candidate reasons includes sample data corresponding to at least one candidate reason respectively, and the set of candidate conditions includes sample data corresponding to at least one candidate condition respectively; Based on the set of candidate reasons and the set of candidate conditions, extracting a set of effective reasons from the set of candidate reasons, and constructing the set of candidate conditions and the candidate reasons that do not belong to the set of effective reasons, where the set of effective reasons includes at least one effective reason having a causal effect on the target variable; Based on the set of candidate conditions and the set of effective reasons, extracting effective conditions having a conditional causal effect on the target variable from the set of candidate conditions; Based on the effective conditions and the effective reasons, obtaining effective sub-scenarios in the business environment that affect the target variable, where the effective sub-scenarios are used to adjust the related business of the target variable.

2. The scenario analysis method based on causal inference according to claim 1, wherein The extracting effective conditions having a conditional causal effect on the target variable from the set of candidate conditions based on the set of candidate conditions and the set of effective reasons includes: For each effective reason in the set of effective reasons: Calculating the conditional average causal effect value of all effective reasons on the target variable under each candidate condition in the set of candidate conditions respectively; and taking the candidate conditions with the conditional average causal effect value greater than a second threshold as the effective conditions.

3. The method for scenario analysis based on causal inference according to claim 2, wherein The calculating the conditional average causal effect value of all effective reasons on the target variable under each candidate condition in the set of candidate conditions respectively; The taking the candidate conditions with the conditional average causal effect value greater than a second threshold as the effective conditions includes: Traversing each candidate condition in the set of candidate conditions: Extracting a sub-data set that meets the candidate condition and all the effective conditions determined in history from the set of candidate reasons and the set of candidate conditions; based on the sub-data set, using the causal effect calculation algorithm to calculate the conditional average causal effect value of the effective reason on the target variable; if the conditional average causal effect value is greater than the second threshold, determining the candidate condition as the effective condition.

4. The method for scenario analysis based on causal inference according to claim 3, wherein During the process of traversing any candidate condition in the set of candidate conditions, the second threshold is the sum of the conditional average causal effect value of the effective reason on the target variable and a preset deviation threshold under all the effective conditions determined in history.

5. The method for scenario analysis based on causal inference according to claim 3, wherein The obtaining effective sub-scenarios in the business environment that affect the target variable based on the effective conditions and the effective reasons includes: During the process of traversing any candidate condition in the set of candidate conditions, constructing an effective sub-scenario based on the effective reasons and all the effective conditions determined in history.

6. The method for scenario analysis based on causal inference according to claim 1, wherein The obtaining a set of candidate reasons and a set of candidate conditions related to a target variable in a business environment includes: Obtain the original cause sample data and original condition sample data related to the target variable in the business environment; Perform one-hot encoding on the categorical data in the original cause sample data, and perform one-hot encoding after binning the continuous variables in the original cause sample data to obtain the set of candidate causes to be screened; And, perform one-hot encoding on the categorical data in the original condition sample data, and perform one-hot encoding after binning the continuous variables in the original condition sample data to obtain the set of candidate conditions to be screened.

7. The method for scenario analysis based on causal inference according to claim 1, wherein The extracting the set of effective causes from the set of candidate causes to be screened based on the set of candidate causes to be screened and the set of candidate conditions to be screened includes: Based on the set of candidate causes to be screened and the set of candidate conditions to be screened, calculate the average causal effect value of each of the candidate causes to be screened on the target variable; Take the candidate causes whose average causal effect value is greater than the first threshold as the effective causes, and integrate all the effective causes into the set of effective causes.

8. A scenario analysis device based on causal inference, characterized in that, Including: A data acquisition module, configured to acquire a set of candidate causes to be screened and a set of candidate conditions to be screened related to a target variable in a business environment, wherein the set of candidate causes to be screened includes sample data corresponding to at least one candidate cause to be screened, and the set of candidate conditions to be screened includes sample data corresponding to at least one candidate condition to be screened; A cause screening module, configured to extract a set of effective causes from the set of candidate causes to be screened based on the set of candidate causes to be screened and the set of candidate conditions to be screened, and construct the set of candidate conditions to be screened and the candidate causes that do not belong to the set of effective causes into a set of candidate conditions, wherein the set of effective causes includes at least one effective cause having a causal effect on the target variable; A condition screening module, configured to extract effective conditions having a conditional causal effect on the target variable from the set of candidate conditions based on the set of candidate conditions and the set of effective causes; A scenario acquisition module, configured to acquire effective sub-scenarios affecting the target variable in the business environment based on the effective conditions and the effective causes, wherein the effective sub-scenarios are used to adjust the related services of the target variable.

9. An electronic device, characterized in that, Including: A memory and a processor; The memory is connected to the processor and is used to store programs; The processor is configured to implement the scenario analysis method based on causal inference according to any one of claims 1-7 by running the programs in the memory.

10. A storage medium, characterized in that, A computer program is stored on the storage medium, and when the computer program is run by a processor, the scenario analysis method based on causal inference according to any one of claims 1-7 is implemented.