A method, device, equipment and medium for cleaning trade physical quantity data

Initialize and filter trade data through preset data formats and cleaning rules, identify and correct missing values ​​and outliers, and use the unit value method and regression model method for data correction, which solves the problem of insufficient flexibility and efficiency in trade data cleaning. , achieving efficient and accurate data cleaning results.

CN116842320BActive Publication Date: 2024-10-29TSINGHUA UNIVERSITY
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202310821997.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-07-05
Publication Date
2024-10-29
Estimated Expiration
2043-07-05

AI Technical Summary

Technical Problem

Existing technologies lack flexibility and efficiency in trade data cleaning and cannot effectively handle diversified needs, resulting in the accuracy and effectiveness of data analysis being affected.

Method used

Initialize trade data through preset data formats and cleaning rules, filter unified rules, identify missing values ​​and outliers item by item, and select preset cleaning algorithms for data correction according to different situations, including unit value method and regression model method. Increase the flexibility and efficiency of your cleaning process.

Benefits of technology

It improves the flexibility and efficiency of the data cleaning process, ensures that the cleaning results are close to the real value, meets the needs of diversified data analysis, and improves the accuracy and reliability of trade data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116842320B_ABST
    Figure CN116842320B_ABST
Patent Text Reader

Abstract

The present invention relates to the technical field of data cleaning, and discloses a method, device, equipment and medium for cleaning physical quantity data of trade, wherein the method comprises: obtaining product trade data of a preset type according to a preset data format, and initializing the product trade data; unifying the initialized product trade data according to a preset unified rule, and screening the unified product trade data according to a preset screening principle, identifying missing value data and abnormal value data; sub-iteming the missing value data and abnormal value data, selecting a corresponding preset cleaning algorithm according to the sub-item results, and performing data correction on the missing value data or abnormal value data of different items. The present invention can improve the flexibility of the cleaning process, improve the cleaning efficiency, ensure that the cleaning result with the minimum modification is close to the true value, and meet the diversified needs of subsequent data analysis by sub-iteming the missing value data and abnormal value data and selecting the corresponding cleaning algorithm for data cleaning.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of data cleaning, and in particular to a method, device, equipment and medium for cleaning trade physical quantity data. Background Art

[0002] In recent years, there has been a growing interest in assessing the impact of trade on people’s lives and the planet. Trade plays a vital role in redistributing resources and wealth between countries and regions. Over the past few decades, resource trade has accounted for an increasing share of global resource extraction, reaching 24.8% in 2017. Therefore, there is a need to quantify the material flows that accompany trade, which involve different processes.

[0003] The United Nations Commodity Trade Information Database (UN Comtrade), established in the early 1960s, is one of the most extensive and accurate databases of international trade statistics. However, various early studies have shown that missing values ​​in UN Comtrade statistics can lead to statistical problems, resulting in serious trade misinterpretations and the severity of the situation worsens as the proportion of missing values ​​increases. This problem exists for all commodities, countries and years. Lack of data will lead to an underestimate of material flows and environmental impacts, and will also lead to a reversal of net flows (for example, from a net importer to a net exporter). Therefore, there is an urgent need to address the problems associated with missing values ​​and outliers. Among them, missing physical values ​​mainly exist in high-value-added commodities, and some governments may require the quantity of these items to be kept confidential and only record the value quantity rather than the exact quantity. At the same time, missing physical values ​​are more common in commodities that are not reported in kilograms. Therefore, failure to properly analyze these data may lead to a serious underestimate of the impact of these commodities on the environment and resource use.

[0004] At present, for the data cleaning work of the platform big data source, preset or fixed cleaning rules are usually used to optimize and clean all or part of the data extracted from the big data platform. During the cleaning process, the corresponding data content is transformed and processed according to the preset cleaning optimization strategy. However, the data cleaning work of the big data platform in the prior art only calculates and processes the data obtained by the big data platform through fixed cleaning rules or cleaning algorithms, and cannot flexibly use the cleaning rules under the situation of diversified needs, resulting in the cleaning process being too rigid and inflexible, which reduces the cleaning efficiency. Summary of the invention

[0005] In view of this, the present invention provides a method, device, equipment and medium for cleaning trade physical quantity data to solve the problems of insufficient flexibility and low operating efficiency in trade data cleaning.

[0006] In a first aspect, the present invention provides a method for cleaning trade physical quantity data, the method comprising:

[0007] Acquire product trade data of a preset type according to a preset data format, and delete data irrelevant to the preset type by initializing the product trade data;

[0008] Unify the initialized product trade data according to the preset unified rules, and screen the unified product trade data according to the preset screening principles to identify missing value data and abnormal value data;

[0009] Missing value data and outlier data are divided into items, and the corresponding preset cleaning algorithm is selected according to the item-by-item results, and data correction is performed on the missing value data or outlier data of different items.

[0010] The method for cleaning physical quantity data of trade provided by the embodiment of the present invention performs initialization processing and unified processing on the acquired product trade data, and screens the unified product trade data according to preset screening principles, identifies missing value data and abnormal value data, and sub-items the missing value data and abnormal value data, and selects the corresponding preset cleaning algorithm according to the sub-item results to correct the missing value data or abnormal value data of different items. The present invention can improve the flexibility of the cleaning process, improve the cleaning efficiency, ensure that the cleaning result with the minimum modification is close to the true value, and meet the diversified needs of subsequent data analysis by sub-iteming the missing value data and abnormal value data and selecting the corresponding cleaning algorithm for data cleaning.

[0011] In an optional implementation, the preset data formats include: xlsx format, xls format and csv format; the preset types include: trade product name, product customs code, trading country, trade year, trade quantity, trade net weight, trade direction, trade amount and product unit.

[0012] The present invention obtains different types of product trade data according to a preset format, wherein the product trade data includes multi-form, long-time series, and cross-regional flow data. The trade data is not limited, and the differences in data collection of each group are not limited. The multi-form large-scale trade data is standardized and unified, and has good flexibility and universality.

[0013] In an optional implementation, the preset unified rules include: unified rules for commodity codes and unified rules for trade volume data units; the unified rules for commodity codes are to verify whether there are changes in the product customs codes of each country in each year according to preset standards, and if there are changes, the product trade data of the country in that year will be reclassified based on the name of the trade product; the unified rules for trade volume data units are to screen trade quantities or product units according to preset unit standards, and if they are inconsistent with the preset unit standards, unit conversion will be performed.

[0014] The product trade data obtained by the present invention is mainly based on value rather than weight or quantity in customs reports of various countries, and there are wrong units, wrong classifications and wrong reports, and there is a lack of unit conversion. Therefore, after obtaining the product trade data, the data needs to be processed uniformly, and the data needs to be re-divided and the units converted according to unified standards to improve data cleaning efficiency.

[0015] In an optional implementation, the unified product trade data is screened according to a preset screening principle, and the process of identifying missing value data and outlier data includes: if the trade quantity, trade amount and net trade weight in the product trade data are all zero or blank, it is missing value data; if the trade quantity, trade amount and net trade weight in the product trade data are partially missing, or there is an abnormality in the trade quantity or trade amount, it is outlier data, among which, if the product trade data has a trade amount but lacks the trade quantity or net trade weight, it is the first type of outlier data, if the product trade data has a trade quantity or net trade weight but lacks the trade amount, it is the second type of outlier data, and if there is an abnormality, it is the third type of outlier data.

[0016] The present invention divides data into missing value data and abnormal value data according to data missing and abnormal situations, and can clean the data item by item through different cleaning algorithms to ensure that the cleaning result with the minimum modification is close to the true value, thereby obtaining the optimal cleaning result closest to the true value in cross-industry bilateral product trade statistics, and realizing the correction of abnormal values ​​in trade data containing multiple errors.

[0017] In an optional implementation, abnormal situations include: a first abnormal situation: in trade between the same countries, the trade volume of the same bilateral product is higher than a preset multiple of the median of other years; a second abnormal situation: in trade between the same countries, the trade unit value of the same bilateral product is higher than a preset multiple of the median of other years, and the trade unit value represents the trade value of the unit product, which is the ratio of the trade amount to the trade volume; a third abnormal situation: in trade between different countries, the trade unit value of the same bilateral product is higher than a preset multiple of the median of the trade unit value in the same year; if the above three abnormal situations are met at the same time, it is the third type of abnormal value data, otherwise it is regarded as normal data.

[0018] The present invention compares the data of the same pair of trading partners in different years and the data of different trading partners in the same year in many aspects. When all abnormal conditions are met, the data is regarded as outlier data. This can avoid screening out data that actually has differences but no abnormalities, thereby ensuring the accuracy and reliability of data screening.

[0019] In an optional embodiment, the preset cleaning algorithm includes: a unit value method and a regression model method; the unit value method is to correct the missing data based on the functional relationship between the trade amount and the trade quantity or the net weight of trade; the regression model method is to obtain the functional relationship between the trade quantity or trade amount and the trade year by constructing a regression model, and calculate the trade quantity or trade amount corresponding to the current trade year based on the functional relationship.

[0020] When performing data cleaning on missing value data and abnormal value data, the present invention uses two cleaning algorithms as options, and selects different cleaning algorithms for processing according to the data missing and abnormal situations. This can simplify the data cleaning process while ensuring the accuracy of data cleaning, thereby improving the data cleaning efficiency.

[0021] In an optional implementation, the missing value data and the abnormal value data are itemized, and the process of selecting the corresponding preset cleaning algorithm according to the itemized results includes: according to the missing and abnormal conditions of the missing value data and the abnormal value data, the first type of abnormal value data and the second type of abnormal value data are used as the first item of data, and the missing value abnormal data and the third type of abnormal value data are used as the second item of data; for the first item of data, the unit value method is used for correction, and the process is: obtaining the first unit value of the first type of abnormal value data or the second type of abnormal value data corresponding to the two trading partner countries in the previous year and the second unit value in the next year, and obtaining the average unit value of the same trade flow in the reporting country of the data in that year, and selecting the value between the first unit value, the second unit value and the average unit value. The median of is taken as the unit value of the country's trade with its partner countries, and the trade quantity or net trade weight corresponding to the trade amount of the first type of outlier data, or the trade amount corresponding to the trade quantity or net trade weight of the second type of outlier data is calculated based on the unit value; for the second data, the unit value method and regression model are used for correction, and the process is: construct a function fitting model between the trade quantity or trade amount and the trade year, and calculate the model parameters of the function fitting model through the preset regression model, and obtain the trade quantity or trade amount corresponding to the trade year by bringing the model parameters into the function fitting model, and based on the obtained trade quantity or trade amount, the unit value method is used to correct other data in the product trade data except the trade quantity or trade amount.

[0022] The present invention divides the missing value data and the abnormal value data into sub-items according to the missing value data and the abnormal value data, wherein the first item of data only lacks part of the physical value data, so it can be restored and corrected by the unit value method. The second item of data lacks all the physical value data: trade quantity, trade amount and trade net weight, or the data has abnormal conditions, so accurate data recovery and correction cannot be performed only by the simple unit value method, so a machine learning algorithm is introduced to obtain the functional relationship between the missing trade quantity or trade value and the trade year through historical data, and then obtain the corresponding missing trade quantity or trade value according to the current trade year, and further restore and correct other data through the unit value, so as to ensure that the minimum modified cleaning result is close to the true value, and then obtain the optimal cleaning result closest to the true value in the cross-industry bilateral product trade statistics, so as to realize the correction of abnormal values ​​in trade data containing multiple errors, provide available data support for cross-regional trade analysis and decision-making evaluation, and improve the accuracy and effectiveness of evaluation analysis.

[0023] In a second aspect, the present invention provides a trade physical quantity data cleaning device, comprising:

[0024] A data acquisition module, used to acquire product trade data of a preset type according to a preset data format, and to delete data irrelevant to the preset type by initializing the product trade data;

[0025] A data screening module is used to unify the initialized product trade data according to preset unified rules, and screen the unified product trade data according to preset screening principles to identify missing value data and abnormal value data;

[0026] The data cleaning module is used to divide the missing value data and outlier data into sub-items, select the corresponding preset cleaning algorithm according to the sub-item results, and perform data correction on the missing value data or outlier data of different items.

[0027] The trade physical quantity data cleaning device provided in the embodiment of the present invention performs initialization processing and unified processing on the acquired product trade data, and screens the unified product trade data according to the preset screening principle, identifies missing value data and abnormal value data, and divides the missing value data and abnormal value data into sub-items, and selects the corresponding preset cleaning algorithm according to the sub-item results, and performs data correction on the missing value data or abnormal value data of different items. The present invention can improve the flexibility of the cleaning process, improve the cleaning efficiency, ensure that the minimum modified cleaning result is close to the true value, and meet the diversified needs of subsequent data analysis by dividing the missing value data and abnormal value data into sub-items and selecting the corresponding cleaning algorithm for data cleaning.

[0028] In a third aspect, the present invention provides a computer device, comprising: a memory and a processor, the memory and the processor being communicatively connected to each other, the memory storing computer instructions, and the processor executing the trade physical quantity data cleaning method of the first aspect or any corresponding embodiment thereof by executing the computer instructions.

[0029] In a fourth aspect, the present invention provides a computer-readable storage medium having computer instructions stored thereon, the computer instructions being used to enable a computer to execute the method for cleaning trade physical quantity data according to the first aspect or any corresponding embodiment thereof. BRIEF DESCRIPTION OF THE DRAWINGS

[0030] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0031] Figure 1 is a flow chart of a method for cleaning trade physical quantity data according to an embodiment of the present invention;

[0032] Figure 2 is a structural block diagram of a device for cleaning trade physical quantity data according to an embodiment of the present invention;

[0033] Figure 3 It is a schematic diagram of the hardware structure of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION

[0034] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.

[0035] The embodiment of the present invention is applicable to the scenario of data cleaning of bilateral product trade data. In recent years, the proportion of missing values ​​(i.e., missing currency values, missing quantity values, and missing both) has increased. Missing weight data is the most common, and the following reasons may cause missing quantity values: 1) Customs reports of various countries are mainly based on value, not weight or quantity; 2) Wrong units, some countries do not measure the import and export volume of goods in weight units (for example, in volume or number units), so when summarizing and analyzing data, unit conversion may cause errors; 3) Lack of unit conversion, custom data is given in "quantity"; United Nations Commodity Trade Statistics are published in the form of "net weight". UN Comtrade may miss some data when filling in "net weight", resulting in "data loss"; 4) Wrong classification, product customs codes will be updated every five years, and some countries still use old customs codes when reporting, so the same product "quantity" will appear under different product types or codes; 5) Wrong reporting, some countries may have reporting errors when reporting data, over-reporting or under-reporting product "quantity", so the physical volume of trade data will appear too high or too low in a certain year. The embodiment of the present invention provides a method for cleaning physical quantity data of trade, which cleans the physical quantity data of bilateral product trade by item to achieve a flexible, accurate and efficient cleaning process.

[0036] The present invention provides an embodiment of a method for cleaning trade physical quantity data. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0037] In this embodiment, a method for cleaning trade physical quantity data is provided, which can be used in the above-mentioned mobile terminal, such as a computer, etc. Figure 1 is a flow chart of a method for cleaning trade physical quantity data according to an embodiment of the present invention. Figure 1 As shown, the process includes the following steps:

[0038] Step S101, obtaining product trade data of a preset type according to a preset data format, and deleting data irrelevant to the preset type by initializing the product trade data.

[0039] Specifically, in an embodiment of the present invention, product trade data is downloaded through the UN Comtrade official website or the required product trade data is downloaded according to relevant filtering items and saved in a preset data format. The source data downloaded from the UN Comtrade official website includes other column variable data, such as trade flow codes, etc. Therefore, the obtained product trade data is initialized, irrelevant column data is deleted, and the required data columns are retained. Among them, the preset data formats include xlsx format, xls format and csv format, and the product trade data includes the name of the trade product, the product customs code, the trading country (reporting country and partner country), the trade year, the trade quantity, the net trade weight, the trade flow, the trade amount and the product unit, which are only used as examples and are not limited to this. In general, the net trade weight is consistent with the trade quantity. If the unit is not a weight unit, the net trade weight is inconsistent with the trade quantity.

[0040] Step S102, unifying the initialized product trade data according to preset unification rules, and screening the unified product trade data according to preset screening principles to identify missing value data and abnormal value data.

[0041] Specifically, in the embodiment of the present invention, the acquired product trade data is unified according to preset unified rules, including: a unified rule for commodity codes and a unified rule for trade volume data units.

[0042] 1) The unified rules for commodity codes are to verify whether there are changes in the product customs codes of each country in each year according to the preset standards. If there are changes, the product trade data of the country in that year will be reclassified based on the trade product name. In the embodiment of the present invention, the HS code change report provided by the UN comtrade data platform is used as the standard, but not limited to this, to verify whether there are changes in the product customs codes reported by each country in each year; if there are changes, the product trade data of the country in that year will be reclassified based on the trade product name; if there are no changes, no adjustment is required.

[0043] 2) The unit unification rule of trade volume data is to filter the trade quantity or product unit according to the preset unit standard, and perform unit conversion if it is inconsistent with the preset unit standard. In the embodiment of the present invention, kilograms are used as the unit standard, but it is not limited to this. Filter the data whose trade quantity or product unit is not kilograms and replace the quantity. If the trade quantity is individual, piece, cubic meter, meter, pair, etc., the product density data is used to convert it into weight data in kg; if the product unit is not kilograms, the product unit conversion parameters are used to unify the data into consistent units.

[0044] In some optional implementations, the unified product trade data is screened according to preset screening principles to identify missing value data and outlier data. If the trade quantity, trade amount and net trade weight in the product trade data are all zero or blank, it is missing value data; if the trade quantity, trade amount and net trade weight in the product trade data are partially missing, or there is an abnormality in the trade quantity or trade amount, it is outlier data, among which, if the product trade data has a trade amount but lacks the trade quantity or net trade weight, it is the first type of outlier data, if the product trade data has a trade quantity or net trade weight but lacks the trade amount, it is the second type of outlier data, and if there is an abnormality, it is the third type of outlier data.

[0045] Among them, abnormal situations include: the first abnormal situation: in the trade between the same countries, the trade volume of the same bilateral product is higher than the preset multiple of the median of other years. In the embodiment of the present invention, the preset multiple is 3 to 8 times, but not limited to this; the second abnormal situation: in the trade between the same countries, the trade unit value of the same bilateral product is higher than the preset multiple of the median of other years, that is, higher than 3 to 8 times the median of the trade unit value of other years, and the trade unit value represents the trade value of the unit product, which is the ratio of the trade amount to the trade volume; the third abnormal situation: in the trade between different countries, the trade unit value of the same bilateral product is higher than the preset multiple of the median of the trade unit value in the same year, that is, higher than 3 to 8 times the median of the trade unit value in the same year. Among them, the first abnormal situation and the second abnormal situation are comparisons of data between the same pair of trading partners in different years, and the third abnormal situation is comparisons of data between different trading partners in the same year. If the above three abnormal situations are met at the same time, it is the third type of abnormal value data, otherwise it is regarded as normal data.

[0046] Step S103, the missing value data and the abnormal value data are divided into items, the corresponding preset cleaning algorithm is selected according to the item division results, and the missing value data or the abnormal value data of different items are corrected.

[0047] Specifically, in an embodiment of the present invention, the preset cleaning algorithms adopted include the unit value method and the regression model method. The unit value method corrects the missing data based on the functional relationship between the trade amount and the trade quantity or the net weight of trade. The regression model method obtains the functional relationship between the trade quantity or trade amount and the trade year by constructing a regression model, and calculates the trade quantity or trade amount corresponding to the current trade year based on the functional relationship.

[0048] In some alternative embodiments, the data missing situation affects the difficulty of data cleaning. If there is little data missing, restoration and correction can be performed based on the relationships between the existing data. If all the data is missing, a machine learning algorithm is introduced to predict one of the data, and then the other data is supplemented. Therefore, according to the data missing and abnormal situations of the missing value data and the outlier data, the first type of outlier data and the second type of outlier data are used as the first item of data, and the missing value outlier data and the third type of outlier data are used as the second item of data, and data cleaning is performed separately according to the itemized data.

[0049] In some alternative embodiments, for the first item of data, the unit value method is used for correction. The process is as follows: Obtain the first unit value of the previous year and the second unit value of the next year corresponding to the first type of outlier data or the second type of outlier data for two trading partner countries, and obtain the average unit value of the same trade flow of the data reporting country in the current year. Select the median among the first unit value, the second unit value, and the average unit value as the unit value of the trade between the country and the partner country. Calculate the trade quantity or trade net weight corresponding to the trade amount of the first type of outlier data based on the unit value, or calculate the trade amount corresponding to the trade quantity or trade net weight of the second type of outlier data. For example, for the first type of outlier data a and the second type of outlier data b, obtain the unit value (e) of the previous year (d) or the next year of the corresponding two trading partner countries, and the average unit value (f) of the same trade flow of the data reporting country in the current year. Select the median of the three as the unit value (g) of the trade between the country and the partner country. Divide the first type of outlier data a by the unit value (g) to obtain the trade quantity, and multiply the second type of outlier data b by the unit value (g) to obtain the trade amount. Among them, the median refers to sorting the unit value (d) of the previous year or the unit value (e) of the next year of the two trading partner countries, and the average unit value (f) of the same trade flow of the reporting country in the current year. Assuming d < f < e, the average unit value f in the middle of the sorting is the median, that is, the unit value (g) of the trade between the country and the trading partner country. The above is only an example and is not limited thereto. In addition, the data before the target trade year is not included in the cleaning and calculation scope.

[0050] In some optional implementations, the second item of data is corrected using the unit value method and regression model, and the process is as follows: construct a function fitting model between the trade quantity or trade amount and the trade year, and calculate the model parameters of the function fitting model through a preset regression model, and obtain the trade quantity or trade amount corresponding to the trade year by bringing the model parameters into the function fitting model, and based on the obtained trade quantity or trade amount, use the unit value method to correct other data in the product trade data except the trade quantity or trade amount. For example, construct the historical trade quantity y between country i and partner countries i The function fitting model with the trade year t is as follows:

[0051] y i =c+β i ·t+ε i

[0052] Among them, c is a constant term, β i is the parameter that needs to be estimated, ε i is assumed to be a random error value with mean equal to 0 and standard deviation σ, and σ is assumed to be constant for any t.

[0053] In some optional implementations, a support vector machine regression model is introduced, which is a machine learning algorithm whose basic idea is to find a nonlinear mapping function from input space to output space, map the training sample set to a high-dimensional feature space through this function, and perform linear regression on the original problem in the high-dimensional feature space. i With historical trade year t as training sample {t i ,y i}, t is the input variable, y∈R is the response output, and n is the number of training samples, so the following formula is obtained:

[0054]

[0055] Among them, w and b are the parameters to be estimated, so that f(t) and y are as close as possible. Assuming that the maximum deviation between f(t) and y is δ, when the training sample falls into the interval band of 2δ, it is considered to be predicted correctly. Therefore, the mathematical expression of the support vector machine regression model is:

[0056]

[0057] Among them, δ(·) is the insensitive loss function, which is defined as follows:

[0058]

[0059] The essence of the support vector machine SVR is to solve the following optimization problem under constraints:

[0060]

[0061]

[0062] In some optional implementations, the Lagrange multiplier method is used to solve the parameters, but it is not limited to this. Introduce the Lagrange multiplier: The Lagrangian function is obtained in sequence:

[0063]

[0064] make right Taking the partial derivative and setting it to 0, we get:

[0065]

[0066]

[0067]

[0068] Substituting the above formula into the Lagrangian function expression, we get:

[0069]

[0070]

[0071] Combining the function theory to solve it, we get:

[0072]

[0073] After obtaining the parameters through optimization, the predicted trade quantity is obtained by inputting the time variable trade year t. The unit value method is further used to complete the data such as trade amount and trade net weight.

[0074] The method for cleaning physical quantity data of trade provided by the embodiment of the present invention performs initialization processing and unified processing on the acquired product trade data, and screens the unified product trade data according to preset screening principles, identifies missing value data and abnormal value data, and sub-items the missing value data and abnormal value data, and selects the corresponding preset cleaning algorithm according to the sub-item results to correct the missing value data or abnormal value data of different items. The present invention can improve the flexibility of the cleaning process, improve the cleaning efficiency, ensure that the cleaning result with the minimum modification is close to the true value, and meet the diversified needs of subsequent data analysis by sub-iteming the missing value data and abnormal value data and selecting the corresponding cleaning algorithm for data cleaning.

[0075] This embodiment provides a trade physical quantity data cleaning device, such as Figure 2As shown, including:

[0076] The data acquisition module 201 is used to acquire product trade data of a preset type according to a preset data format, and delete data irrelevant to the preset type by initializing the product trade data.

[0077] The data screening module 202 is used to unify the initialized product trade data according to preset unification rules, and screen the unified product trade data according to preset screening principles to identify missing value data and abnormal value data.

[0078] The data cleaning module 203 is used to divide the missing value data and the abnormal value data into items, select the corresponding preset cleaning algorithm according to the item division results, and perform data correction on the missing value data or the abnormal value data of different items.

[0079] The further functional description of each of the above modules and units is the same as that of the above corresponding embodiments and will not be repeated here.

[0080] The trade physical quantity data cleaning device in this embodiment is presented in the form of a functional unit, where the unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and memory that executes one or more software or fixed programs, and / or other devices that can provide the above functions.

[0081] The embodiment of the present invention also provides a computer device having the above Figure 2 The trade physical volume data cleaning device shown.

[0082] See also Figure 3 , Figure 3 is a schematic diagram of the structure of a computer device provided by an optional embodiment of the present invention, such as Figure 3 As shown, the computer device includes: one or more processors 10, a memory 20, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. Various components are connected to each other using different buses for communication, and can be installed on a common mainboard or installed in other ways as needed. The processor can process the instructions executed in the computer device, including instructions stored in or on the memory to display the graphical information of the GUI on an external input / output device (such as, a display device coupled to the interface). In some optional embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple computer devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Figure 3 A processor 10 is taken as an example.

[0083] The processor 10 may be a central processing unit, a network processor or a combination thereof. The processor 10 may further include a hardware chip. The hardware chip may be a dedicated integrated circuit, a programmable logic device or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general purpose array logic or any combination thereof.

[0084] The memory 20 stores instructions executable by at least one processor 10, so that at least one processor 10 executes the method shown in the above embodiment.

[0085] The memory 20 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of the computer device, etc. In addition, the memory 20 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some optional embodiments, the memory 20 may optionally include a memory remotely arranged relative to the processor 10, and these remote memories may be connected to the computer device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0086] The memory 20 may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a flash memory, a hard disk or a solid state drive; the memory 20 may also include a combination of the above types of memory.

[0087] The computer device further comprises a communication interface 30 for the computer device to communicate with other devices or a communication network.

[0088] The embodiment of the present invention also provides a computer-readable storage medium. The method according to the embodiment of the present invention can be implemented in hardware, firmware, or can be implemented as a computer code that can be recorded in a storage medium, or can be implemented as a computer code that is originally stored in a remote storage medium or a non-temporary machine-readable storage medium and will be stored in a local storage medium through a network download, so that the method described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only storage memory, a random access memory, a flash memory, a hard disk or a solid-state hard disk, etc.; further, the storage medium can also include a combination of the above types of memories. It can be understood that a computer, a processor, a microprocessor controller, or programmable hardware includes a storage component that can store or receive software or computer code. When the software or computer code is accessed and executed by a computer, a processor, or hardware, the method shown in the above embodiment is implemented.

[0089] Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present invention, and such modifications and variations are all within the scope defined by the appended claims.

Claims

1. A method for cleaning trade physical quantity data, characterized in that: The method comprises: Acquire product trade data of a preset type according to a preset data format, and delete data irrelevant to the preset type by initializing the product trade data; The initialized product trade data is unified according to the preset unified rules, and the unified product trade data is screened according to the preset screening principles. If the trade quantity, trade amount and trade net weight in the product trade data are all zero or blank, it is missing value data; if the trade quantity, trade amount and trade net weight in the product trade data are partially missing, or there is an abnormality in the trade quantity or trade amount, it is abnormal value data. Among them, if the product trade data has a trade amount but lacks the trade quantity or trade net weight, it is the first type of abnormal value data; if the product trade data has a trade quantity or trade net weight but lacks the trade amount, it is the second type of abnormal value data. If there is an abnormal situation If there is any abnormal situation, it is the third type of abnormal value data, and the abnormal situation includes: the first abnormal situation: in the trade between the same countries, the trade volume of the same bilateral product is higher than the preset multiple of the median of other years; the second abnormal situation: in the trade between the same countries, the trade unit value of the same bilateral product is higher than the preset multiple of the median of other years, and the trade unit value represents the trade value of the unit product, which is the ratio of the trade amount to the trade volume; the third abnormal situation: in the trade between different countries, the trade unit value of the same bilateral product is higher than the preset multiple of the median of the trade unit value in the same year; if the above three abnormal situations are met at the same time, it is the third type of abnormal value data, otherwise it is regarded as normal data; The missing value data and outlier data are divided into items, and the corresponding preset cleaning algorithm is selected according to the item-by-item results, and the missing value data or outlier data of different items are corrected; The process of dividing the missing value data and the abnormal value data into items and selecting the corresponding preset cleaning algorithm according to the item division results includes: According to the missing value data and the abnormal value data, the first type of abnormal value data and the second type of abnormal value data are used as the first item of data, and the missing value data and the third type of abnormal value data are used as the second item of data; For the first item of data, the unit value method is used for correction, and the process is as follows: obtain the first unit value of the previous year and the second unit value of the next year of the two trading partner countries corresponding to the first type of abnormal value data or the second type of abnormal value data, and obtain the average unit value of the same trade flow of the country reporting the data in that year, select the median between the first unit value, the second unit value and the average unit value as the unit value of the country's trade with the partner country, and calculate the trade quantity or net trade weight corresponding to the trade amount of the first type of abnormal value data, or the trade amount corresponding to the trade quantity or net trade weight of the second type of abnormal value data based on the unit value; For the second item of data, the unit value method and regression model are used for correction, and the process is: construct a function fitting model between the trade quantity or trade amount and the trade year, and calculate the model parameters of the function fitting model through a preset regression model, and obtain the trade quantity or trade amount corresponding to the trade year by bringing the model parameters into the function fitting model, and based on the obtained trade quantity or trade amount, use the unit value method to correct other data in the product trade data except the trade quantity or trade amount.

2. The method according to claim 1, characterized in that The preset data formats include: xlsx format, xls format and csv format; The preset types include: trade product name, product customs code, trade country, trade year, trade quantity, trade net weight, trade direction, trade amount and product unit.

3. The method according to claim 2, characterized in that The preset unified rules include: unified rules for commodity codes and unified rules for trade volume data units; The unified commodity code rule is to verify whether the customs code of the product in each country in each year has changed according to the preset standard. If there is a change, the product trade data of the country in that year will be reclassified based on the name of the trade product; The trade volume data unit unification rule is to filter the trade quantity or product unit according to a preset unit standard, and perform unit conversion if it is inconsistent with the preset unit standard.

4. A trade physical quantity data cleaning device, characterized in that: The device comprises: A data acquisition module, used to acquire product trade data of a preset type according to a preset data format, and to delete data irrelevant to the preset type by initializing the product trade data; The data screening module is used to unify the initialized product trade data according to the preset unified rules, and screen the unified product trade data according to the preset screening principles. If the trade quantity, trade amount and net trade weight in the product trade data are all zero or blank, it is missing value data; if the trade quantity, trade amount and net trade weight in the product trade data are partially missing, or there is an abnormality in the trade quantity or trade amount, it is abnormal value data, among which, if the product trade data has a trade amount but lacks the trade quantity or net trade weight, it is the first type of abnormal value data, if the product trade data has a trade quantity or net trade weight but lacks the trade amount, it is the second type of abnormal value data, if If there are abnormal situations, it is the third type of abnormal value data, and the abnormal situations include: the first abnormal situation: in the trade between the same countries, the trade volume of the same bilateral product is higher than the preset multiple of the median of other years; the second abnormal situation: in the trade between the same countries, the trade unit value of the same bilateral product is higher than the preset multiple of the median of other years, and the trade unit value represents the trade value of the unit product, which is the ratio of the trade amount to the trade volume; the third abnormal situation: in the trade between different countries, the trade unit value of the same bilateral product is higher than the preset multiple of the median of the trade unit value in the same year; if the above three abnormal situations are met at the same time, it is the third type of abnormal value data, otherwise it is regarded as normal data; A data cleaning module is used to divide the missing value data and abnormal value data into items, select a corresponding preset cleaning algorithm according to the item division results, and perform data correction on the missing value data or abnormal value data of different items; The process of dividing the missing value data and the abnormal value data into items and selecting the corresponding preset cleaning algorithm according to the item division results includes: According to the missing value data and the abnormal value data, the first type of abnormal value data and the second type of abnormal value data are used as the first item of data, and the missing value data and the third type of abnormal value data are used as the second item of data; For the first item of data, the unit value method is used for correction, and the process is as follows: obtain the first unit value of the previous year and the second unit value of the next year of the two trading partner countries corresponding to the first type of abnormal value data or the second type of abnormal value data, and obtain the average unit value of the same trade flow of the country reporting the data in that year, select the median between the first unit value, the second unit value and the average unit value as the unit value of the country's trade with the partner country, and calculate the trade quantity or net trade weight corresponding to the trade amount of the first type of abnormal value data, or the trade amount corresponding to the trade quantity or net trade weight of the second type of abnormal value data based on the unit value; For the second item of data, the unit value method and regression model are used for correction, and the process is: construct a function fitting model between the trade quantity or trade amount and the trade year, and calculate the model parameters of the function fitting model through a preset regression model, and obtain the trade quantity or trade amount corresponding to the trade year by bringing the model parameters into the function fitting model, and based on the obtained trade quantity or trade amount, use the unit value method to correct other data in the product trade data except the trade quantity or trade amount.

5. A computer device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the trade physical quantity data cleaning method according to any one of claims 1 to 3 by executing the computer instructions.

6. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the trade physical quantity data cleaning method according to any one of claims 1 to 3.

Citation Information

Patent Citations

  • Big data cleaning method and system and related device

    CN109800220A