Object classification method and apparatus, electronic device, and readable storage medium
Patent Information
- Application Number
- CN202111027881.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-02
- Publication Date
- 2026-08-18
- Estimated Expiration
- 2041-09-02
AI Technical Summary
目前,对于对象的分类,大多是通过单一的分类模型或者算法将未知类别的对象映射到给定的类别当中,分类的准确性较低,有待提高
[0040]The object classification method, apparatus, electronic device, and readable storage medium provided in this invention, after acquiring order data of a target object, extracts features from the order data to obtain order features of the target object. These order features are then input into a pre-trained first model to obtain combined features of the target object. Finally, the combined features and order features are input into a pre-trained second model to obtain the group category to which the target object belongs. Thus, through the combination of the first and second models, accurate object classification is achieved.
Smart Images

Figure CN115758261B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and more specifically, to an object classification method, apparatus, electronic device, and readable storage medium. Background Technology
[0002] Object classification is an important aspect of object mining, referring to assigning a category to an object to be classified according to predefined topic categories. Currently, most object classification methods map objects of unknown categories to given categories using a single classification model or algorithm, resulting in low accuracy and requiring improvement. Summary of the Invention
[0003] Based on the above research, the present invention provides an object classification method, apparatus, electronic device, and readable storage medium, which improves the accuracy of object classification.
[0004] Embodiments of the present invention can be implemented through the following:
[0005] In a first aspect, embodiments of the present invention provide an object classification method, the method comprising:
[0006] Retrieve order data for the target object;
[0007] Feature extraction is performed on the order data to obtain the order features of the target object;
[0008] The order features of the target object are input into a pre-trained first model to obtain the combined features of the target object;
[0009] The combined features of the target object and the order features are input into a pre-trained second model to obtain the group category to which the target object belongs.
[0010] In an optional implementation, before inputting the order features of the target object into a pre-trained first model to obtain the combined features of the target object, the method further includes:
[0011] Retrieve historical order data for the sample object;
[0012] Feature extraction is performed on the historical order data to obtain the historical order features of the sample object;
[0013] Based on the historical order characteristics of the sample objects, the initial first model is trained to obtain the first model.
[0014] In an optional implementation, the step of training an initial first model based on the historical order features of the sample objects to obtain a first model includes:
[0015] Construct a decision tree based on the historical order characteristics of the sample objects;
[0016] The objective function of the initial first model is minimized to determine the structure of the decision tree, thus obtaining the first model.
[0017] In an optional implementation, before inputting the combined features of the target object and the order features into a pre-trained second model to obtain the group category to which the target object belongs, the method further includes:
[0018] Obtain the combined features of the sample object output by the first model and the historical order features of the sample object;
[0019] Based on the combined features of the sample object output by the first model and the historical order features of the sample object, the initial second model is trained to obtain the second model.
[0020] In an optional implementation, the step of training the initial second model based on the combined features of the sample objects output by the first model and the historical order features of the sample objects to obtain the second model includes:
[0021] The combined features of the sample object output by the first model and the historical order features of the sample object are input into the initial second model to obtain the predicted value of the initial second model;
[0022] Calculate the loss between the predicted value and the label value of the sample object, determine whether the loss meets the preset condition, if not, backpropagate the loss, adjust the parameters of the initial second model to obtain an intermediate second model, until the loss between the predicted value and the label value output by the intermediate second model meets the preset condition, and obtain the second model.
[0023] In an optional implementation, the step of inputting the order features of the target object into a pre-trained first model to obtain the combined features of the target object includes:
[0024] The order features of the target object are input into the first model, and a greedy algorithm is used to obtain the split nodes of each branch of the decision tree in the first model;
[0025] Based on the split nodes of each branch of the decision tree, the combined features of the target object are obtained.
[0026] In an optional implementation, the step of inputting the order features of the target object into a pre-trained first model to obtain the combined features of the target object includes:
[0027] The order features are preprocessed to obtain preprocessed order features;
[0028] The preprocessed order features are input into the first model to obtain the combined features of the target object.
[0029] In an optional implementation, the order feature includes at least two sub-order features, and the step of preprocessing the order feature to obtain the preprocessed order feature includes:
[0030] Calculate the correlation between every two of the sub-order features;
[0031] Determine whether there is a target relevance greater than a preset threshold;
[0032] If they exist, the correlation between the two target sub-order features corresponding to the target correlation and other sub-order features is obtained respectively. The target sub-order feature corresponding to the highest correlation is removed to obtain the preprocessed order features.
[0033] In a second aspect, embodiments of the present invention provide an object classification device, comprising:
[0034] The data acquisition module is used to acquire order data of the target object;
[0035] The feature extraction module is used to extract features from the order data to obtain the order features of the target object;
[0036] The first processing module is used to input the order features of the target object into a pre-trained first model to obtain the combined features of the target object;
[0037] The second processing module is used to input the combined features of the target object and the order features into a pre-trained second model to obtain the group category to which the target object belongs.
[0038] Thirdly, embodiments of the present invention provide an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the object classification method described in any of the foregoing embodiments.
[0039] Fourthly, embodiments of the present invention provide a storage medium, the readable storage medium including a computer program, wherein the computer program, when running, controls the electronic device where the readable storage medium is located to execute the object classification method described in any of the foregoing embodiments.
[0040] The object classification method, apparatus, electronic device, and readable storage medium provided in this invention, after acquiring order data of a target object, extracts features from the order data to obtain order features of the target object. These order features are then input into a pre-trained first model to obtain combined features of the target object. Finally, the combined features and order features are input into a pre-trained second model to obtain the group category to which the target object belongs. Thus, through the combination of the first and second models, accurate object classification is achieved. Attached Figure Description
[0041] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation on the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0042] Figure 1 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention.
[0043] Figure 2 This is a flowchart illustrating an object classification method provided in an embodiment of the present invention.
[0044] Figure 3 This is a block diagram of an object classification device provided in an embodiment of the present invention.
[0045] Figure 4 This is another block diagram of the object classification device provided in an embodiment of the present invention.
[0046] Icons: 100 - Electronic device; 10 - Object classification device; 11 - Data acquisition module; 12 - Feature extraction module; 13 - First processing module; 14 - Second processing module; 15 - First model training module; 16 - Second model training module; 20 - Memory; 30 - Processor; 40 - Communication unit. Detailed Implementation
[0047] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. The components of the embodiments of the present invention described and shown in the accompanying drawings can generally be arranged and designed in various different configurations.
[0048] Therefore, the following detailed description of the embodiments of the invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely to illustrate selected embodiments of the invention. All other embodiments obtained by those skilled in the art based on the embodiments of the invention without inventive effort are within the scope of protection of the invention.
[0049] It should be noted that similar labels and letters in the following figures indicate similar items. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures.
[0050] In the description of this invention, it should also be noted that, unless otherwise explicitly specified and limited, the terms "set," "install," "connect," and "link" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; and they can refer to the internal connection of two components. Those skilled in the art can understand the specific meaning of the above terms in this invention based on the specific circumstances.
[0051] As described in the background section, object classification is an important aspect of object mining, referring to assigning a category to an object to be classified based on predefined topic categories. Currently, object classification mostly relies on a single classification model or algorithm, such as Support Vector Machines (SVM), K-Nearest Neighbor (KNN), or neural network models, to map objects of unknown categories to given categories. However, single classification models or algorithms have poor scalability in feature processing, resulting in low classification accuracy, which needs improvement.
[0052] Based on the above research, this embodiment provides an object classification method, apparatus, electronic device, and readable storage medium. By combining a first model and a second model, after acquiring order data for the target object, feature extraction is performed on the order data to obtain the target object's order features. These order features are then input into a pre-trained first model to obtain combined features of the target object. Finally, the combined features and order features are input into a pre-trained second model to determine the group category to which the target object belongs. This achieves effective object classification, providing a foundation for subsequent object profiling and the promotion of related businesses.
[0053] Please see Figure 1 , Figure 1 This is a structural block diagram of the electronic device 100 provided in this embodiment. For example... Figure 1As shown, the electronic device may include an object classification device 10, a memory 20, a processor 30, and a communication unit 40. The memory 20 stores machine-readable instructions that can be executed by the processor 30. When the electronic device 100 is running, the processor 30 and the memory 20 communicate with each other via a bus. The processor 30 executes the machine-readable instructions and performs the object classification method.
[0054] The memory 20, processor 30, and communication unit 40 are electrically connected directly or indirectly to each other to achieve signal transmission or interaction. For example, these components can be electrically connected to each other through one or more communication buses or signal lines. The object sorting device 10 includes at least one software functional module that can be stored in the memory 20 in the form of software or firmware. The processor 30 is used to execute the executable module (e.g., the software functional module or computer program included in the object sorting device 10) stored in the memory 20.
[0055] The memory 20 may be, but is not limited to, random access memory (RAM), read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), etc.
[0056] In some embodiments, processor 30 is used to perform one or more functions described in this embodiment. In some embodiments, processor 30 may include one or more processing cores (e.g., a single-core processor (S) or a multi-core processor (S)). By way of example only, processor 30 may include a central processing unit (CPU), an application-specific integrated circuit (ASIC), an application-specific instruction-set processor (ASIP), a graphics processing unit (GPU), a physical processing unit (PPU), a digital signal processor (DSP), a field-programmable gate array (FPGA), a programmable logic device (PLD), a controller, a microcontroller unit, a reduced instruction set computing (RISC) computer, or a microprocessor, or any combination thereof.
[0057] For ease of explanation, only one processor is described in electronic device 100. However, it should be noted that electronic device 100 in this embodiment may also include multiple processors, and therefore the steps performed by one processor as described in this embodiment may also be performed jointly or individually by multiple processors. For example, if the server's processor performs steps A and B, it should be understood that steps A and B may also be performed jointly by two different processors or individually by one processor. For example, one processor performs step A, and a second processor performs step B, or the first and second processors jointly perform steps A and B.
[0058] In this embodiment, the memory 20 is used to store the program, and the processor 30 is used to execute the program after receiving the execution instruction. The process definition method disclosed in any implementation of this embodiment can be applied to the processor 30, or implemented by the processor 30.
[0059] The communication unit 40 is used to establish a communication connection between the electronic device 100 and other devices via a network, and to send and receive data via the network.
[0060] In some implementations, the network can be any type of wired or wireless network, or a combination thereof. By way of example only, the network may include wired networks, wireless networks, fiber optic networks, telecommunications networks, intranets, the Internet, local area networks (LANs), wide area networks (WANs), wireless local area networks (WLANs), metropolitan area networks (MANs), public switched telephone networks (PSTNs), Bluetooth networks, ZigBee networks, or near field communication (NFC) networks, or any combination thereof.
[0061] In this embodiment, the electronic device 100 may be, but is not limited to, laptops, ultra-mobile personal computers (UMPCs), netbooks, personal digital assistants (PDAs), or other electronic devices. This embodiment does not impose any restrictions on the specific type of electronic device. In one implementation, the electronic device may also be a physical server or a service cluster composed of multiple physical servers. This embodiment does not impose any restrictions on the specific type of electronic device.
[0062] Understandably, Figure 1 The structure shown is for illustrative purposes only. The electronic device 100 may also have... Figure 1 Showing more or fewer components, or having with Figure 1 The different configurations shown. Figure 1 The components shown can be implemented using hardware, software, or a combination thereof.
[0063] based on Figure 1 The implementation architecture of this embodiment provides an object classification method, which is based on... Figure 1 The electronic device shown performs the following based on Figure 1 The structural diagram of the electronic device 100 shown illustrates in detail the steps of the object classification method provided in this embodiment. Please refer to the attached diagram. Figure 2 The object classification method provided in this embodiment includes steps S101 to S104.
[0064] Step S101: Obtain the order data of the target object.
[0065] The target object is the object to be classified, which can be a user object or any object to be classified.
[0066] Optionally, in this embodiment, the target object can be a user in the logistics industry. The target object's order data can include its waybill information, monthly settlement information, COD (cash on delivery) information, and warehousing information. Through the target object's order data, information such as the number of packages sent and received, and the costs associated with those packages can be obtained. This information allows for analysis of the target object's logistics needs, thereby identifying the target object's group category, such as groups with high logistics needs or groups with low logistics needs.
[0067] Optionally, in this embodiment, obtaining the order data of the target object may involve obtaining the order data of the target object within a preset historical time period. The historical time period can be set according to actual needs and is not specifically limited. For example, it may be the order data of the target object within the past year.
[0068] Step S102: Extract features from the order data to obtain the order features of the target object.
[0069] Once the order data of the target object is obtained, comprehensive data analysis can be performed on the order data. Feature engineering can be used to extract features from the order data to obtain the order features of the target object.
[0070] Optionally, in this embodiment, feature extraction is performed on the order data, and the resulting order features include monthly shipment volume, shipment cost, year-on-year and month-on-month fluctuations in shipment volume and shipment cost, cooperation status, and cash-on-delivery status.
[0071] Step S103: Input the order features of the target object into the pre-trained first model to obtain the combined features of the target object.
[0072] The first model can be k-Nearest Neighbor (KNN) classification algorithm, Gradient Boosting Decision Tree (GBDT), Random Forest, Gradient Boosting Decision Tree-based machine learning method (Catboost), or distributed gradient boosting library (eXtreme GradientBoosting, XGBoost), etc.
[0073] In this embodiment, after obtaining the order features of the target object, the order features are input into a pre-trained first model. The first model then combines the order features of the target object to obtain the combined features of the target object.
[0074] Step S104: Input the combined features of the target object and the order features into the pre-trained second model to obtain the group category to which the target object belongs.
[0075] In this process, after obtaining the combined features of the target object, the combined features and order features of the target object are input together into a pre-obtained second model. The second model then performs classification processing on the combined features and order features to obtain the group category to which the target object belongs.
[0076] This embodiment improves the data fitting ability of the second model and enhances the classification accuracy by inputting the combined features obtained from the first model and the original order features into the second model for processing.
[0077] Optionally, in this embodiment, the second model can also be the k-Nearest Neighbor (KNN) classification algorithm, Gradient Boosting Decision Tree (GBDT), Random Forest, Gradient Boosting Decision Tree-based machine learning method (Catboost), distributed gradient boosting library (eXtreme Gradient Boosting, XGBoost), Logistic Regression (LR) model, etc.
[0078] It should be noted that in this embodiment, the second model is different from the first model.
[0079] The object classification method provided in this embodiment combines a first model and a second model. After obtaining the order data of the target object, features are extracted from the order data to obtain the order features of the target object. The order features of the target object are then input into the pre-trained first model to obtain the combined features of the target object. After obtaining the combined features of the target object, the combined features and the order features are input into the pre-trained second model to obtain the group category to which the target object belongs. In this way, effective object classification is achieved.
[0080] In one alternative implementation, after obtaining the group category to which the user belongs, a user profile can be created based on the group category. In this way, better services can be provided to the user based on the user profile.
[0081] In an optional implementation, in order to improve the accuracy of classification, this embodiment may also perform data cleaning on the obtained order data before extracting features from the order data, so as to remove duplicate data and abnormal data.
[0082] After cleaning the order data, features can be extracted to obtain order features. To further ensure classification accuracy, in this embodiment, the order features can be preprocessed before being input into the first model. Based on this, the steps of inputting the order features of the target object into the pre-trained first model to obtain the combined features of the target object include:
[0083] The order features are preprocessed to obtain the preprocessed order features.
[0084] The preprocessed order features are input into the first model to obtain the combined features of the target object.
[0085] Since the order data we receive often contains a significant amount of abnormal data, when extracting features from this data, anomalous features may be extracted. If these anomalous features are not filtered out, they could negatively impact subsequent classification results, leading to biases. Therefore, in an optional implementation, preprocessing of order features can involve cleaning anomalous features. This cleaning can be done using machine learning algorithms for outlier detection to filter out all anomalous features, or by using clustering algorithms to divide the order features into several clusters. If a cluster contains very few samples and its centroid is far from all other clusters, then the features within that cluster are highly likely to be anomalous and should be filtered out.
[0086] In this embodiment, since the extracted order features include various sub-order features such as monthly shipment volume, shipment costs, year-on-year and month-on-month fluctuations in shipment volume and costs, cooperation status, and cash-on-delivery status, if the correlation between these sub-order features is too high, it will affect the accuracy of classification. Therefore, in this embodiment, the order features are preprocessed to obtain the preprocessed order features.
[0087] Calculate the correlation between features of every two sub-orders.
[0088] Determine whether there is a target relevance greater than a preset threshold.
[0089] If they exist, obtain the correlation between the two target sub-order features corresponding to the target relevance and other sub-order features, remove the target sub-order feature corresponding to the highest relevance, and obtain the preprocessed order features.
[0090] The correlation between two sub-order features can be obtained by calculating the Pearson correlation coefficient between them.
[0091] The Pearson correlation coefficient is used to measure the degree of correlation between two variables. Optionally, the Pearson correlation coefficient of each sub-order feature can be calculated using the following formula:
[0092]
[0093] Where E is the expected value or mean; D is the variance; Let X be the standard deviation of the sub-order feature. Let X be the standard deviation of the sub-order feature X; E((X-EX)(Y-EY)) is the covariance of the sub-order features X and Y.
[0094] The Pearson correlation coefficient ranges from -1 to 1. The larger the absolute value of the Pearson correlation coefficient, the higher the correlation between X and Y. When X and Y are linearly correlated, the correlation coefficient is either 1 (positive linear correlation) or -1 (negative linear correlation).
[0095] In this embodiment, for each sub-order feature, the Pearson correlation coefficient between the sub-order feature and the other sub-order features can be calculated using the above formula, thereby obtaining the correlation degree between the sub-order feature and the other sub-order features, and thus obtaining the correlation matrix of the sub-order feature.
[0096] Understandably, in this embodiment, the correlation matrix of each sub-order feature includes the correlation between that sub-order feature and all other sub-order features. Therefore, based on the correlation matrix of each sub-order feature, the correlation between any two sub-order features can be obtained. After obtaining the correlation between any two sub-order features, it is determined whether the correlation between any two sub-order features is greater than a preset threshold. If it is greater than the preset threshold, it indicates that the correlation between the sub-order features is high and has an impact on the classification result, so they need to be removed. If it is not greater than the preset threshold, it indicates that the correlation between the sub-order features is not high and has little impact on the classification result, so they can be retained.
[0097] Therefore, in this embodiment, after obtaining the correlation between every two sub-order features, it is possible to determine whether the correlation between every two sub-order features is greater than a preset threshold. The correlation greater than the preset threshold is taken as the target correlation. After obtaining the target correlation greater than the preset threshold, the correlation between the two target sub-order features corresponding to the target correlation and other sub-order features is obtained respectively. Then, the correlation between the two target sub-order features and other sub-order features is sorted, and the target sub-order feature corresponding to the highest correlation is removed.
[0098] For example, suppose there are sub-order features A, B, C, and D, where the correlation between sub-order feature A and sub-order feature B is 0.3, the correlation between sub-order feature A and sub-order feature C is 0.7, the correlation between sub-order feature A and sub-order feature D is 0.2, the correlation between sub-order feature B and sub-order feature C is 0.1, the correlation between sub-order feature B and sub-order feature D is 0.4, and the correlation between sub-order feature C and sub-order feature D is 0.4. Assuming a preset threshold of 0.5, then the sub-order feature... If the correlation between feature A and sub-order feature C is greater than a preset threshold, then the correlation between sub-order feature A and other sub-order features, and the correlation between sub-order feature C and other sub-order features are obtained. The correlation between sub-order feature A and other sub-order features includes the correlation between sub-order feature A and sub-order feature B, and the correlation between sub-order feature A and sub-order feature D. The correlation between sub-order feature C and other sub-order features includes the correlation between sub-order feature B and sub-order feature C, and the correlation between sub-order feature C and sub-order feature D. The correlation between sub-order feature A and other sub-order features, as well as the correlation between sub-order feature C and other sub-order features, are ranked. The correlation between sub-order feature C and sub-order feature D is (0.4) > the correlation between sub-order feature A and sub-order feature B is (0.3) > the correlation between sub-order feature A and sub-order feature D is (0.2) > the correlation between sub-order feature B and sub-order feature C is (0.1). Among them, the correlation between sub-order feature C and sub-order feature D is the highest, indicating that sub-order feature C has a high correlation not only with sub-order feature A but also with sub-order feature D. Therefore, sub-order feature C needs to be removed.
[0099] It should be noted that after sorting the relevance between two target sub-order features and other sub-order features, if the highest relevance between two target sub-order features and other sub-order features is the same, then the target sub-order feature corresponding to the second highest relevance is removed, and so on, so that highly correlated sub-order features can be removed.
[0100] In one optional implementation, for the convenience of data processing, when it is determined that the correlation between two sub-order features is greater than a preset threshold, either of the two sub-order features corresponding to the correlation greater than the preset threshold can be removed.
[0101] The preset threshold can be set according to actual needs, and there is no specific limitation. Optionally, in this embodiment, the preset threshold can be 0.4. If the correlation is greater than 0.4, it means that the sub-order features are highly correlated; if the correlation is not greater than 0.4, it means that the sub-order features are uncorrelated.
[0102] After removing the target sub-order features, linearly uncorrelated sub-order features are obtained, which are the preprocessed order features.
[0103] After obtaining the preprocessed order features, these features can be input into the first model for feature filtering and combination to obtain combined features. After obtaining the combined features, they can be input into the second model for classification processing to determine the group category to which the target object belongs.
[0104] To improve the accuracy of object classification, in this embodiment, the first model is an XGBoost model, and the second model is a Logistic Regression (LR) model. XGBoost is a gradient boosting tree ensemble model that maximizes speed and efficiency, capable of sampling both samples and features. LR is a regression model with good interpretability, fast execution speed, and strong feature interpretability, but it requires extensive feature engineering to pre-select high-performing features. The object classification method provided in this embodiment combines the XGBoost and LR models. The XGBoost model selects high-performing combined features, which are then input into the LR model, effectively improving the classification accuracy of the LR model.
[0105] Optionally, in this embodiment, the step of inputting the order features of the target object into a pre-trained first model to obtain the combined features of the target object includes:
[0106] The order features of the target object are input into the first model, and a greedy algorithm is used to obtain the split nodes of each branch of the decision tree in the first model.
[0107] Based on the split nodes of each branch of the decision tree, the combined features of the target object are obtained.
[0108] Greedy algorithms are a simpler and faster design technique for certain optimal solutions to problems. The characteristic of greedy algorithms is that they proceed step-by-step, making the optimal choice based on the current situation and a certain optimization metric, without considering all possible overall scenarios. This saves a significant amount of time that would otherwise be spent exhaustively searching for the optimal solution. Greedy algorithms use a top-down, iterative approach, making successive greedy choices. Each greedy choice simplifies the problem into a smaller subproblem, and through each greedy choice, an optimal solution can be obtained.
[0109] In this embodiment, after the order features are input into the first model, the optimal combination features are obtained by using the decision tree structure of the first model and a greedy algorithm to find the best splitting node of the leaf node of the decision tree.
[0110] It should be noted that when using a greedy algorithm to find the optimal splitting node for a leaf node in a decision tree, the leaf node will only split if the gain of the objective function of the first model after the split is greater than the gain of the function value before the split is greater than a set threshold.
[0111] In this embodiment, when searching for the optimal splitting node of a leaf node in a decision tree using a greedy algorithm, each leaf node continuously splits, forming multiple branches, each containing multiple splitting nodes. Therefore, the greedy algorithm can determine all branches of the decision tree and the splitting nodes on each branch. After obtaining all branches of the decision tree and the splitting nodes on each branch, the splitting nodes on each branch are combined to obtain the combined features.
[0112] The object classification method provided in this embodiment utilizes the inherent feature selection function of tree model algorithms. Through methods such as entropy and information gain, the optimal splitting node is selected at each split, thus selecting locally optimal combined features from the root to the leaves. After obtaining the combined features, inputting them into the LR model can improve the fitting ability of the LR model and effectively improve the classification accuracy.
[0113] To ensure classification accuracy, this embodiment requires training the first model (XGBoost model) before inputting the order features of the target object into the pre-trained first model to obtain the combined features of the target object. Optionally, this can be achieved through the following process:
[0114] Retrieve historical order data for the sample object.
[0115] Feature extraction is performed on historical order data to obtain the historical order features of the sample objects.
[0116] Based on the historical order characteristics of the sample objects, the initial first model is trained to obtain the first model.
[0117] The historical order data of the sample objects refers to the order data of the sample data within a specified time period in the past. The specified time period can be one year, two years, six months, etc., and there is no specific restriction. It can be set according to actual needs.
[0118] To enable the model to learn more comprehensive features and improve classification accuracy, in this embodiment, the historical order data of the sample objects includes historical order data of both positive and negative sample objects. For example, when identifying objects belonging to micro-enterprises, the historical order data of positive sample objects is the historical order data of objects belonging to micro-enterprises, while the historical order data of negative sample objects is the historical order data of objects belonging to other groups.
[0119] After obtaining the historical order data of the sample object, feature engineering can be used to extract features from the historical order data of the sample object to obtain the historical order features of the sample object.
[0120] Understandably, feature extraction of historical order data of sample objects includes feature extraction of historical order data of positive sample objects and feature extraction of historical order data of negative sample objects.
[0121] After extracting features from the historical order data of positive sample objects, the historical order features of positive sample objects can be obtained. Similarly, after extracting features from the historical order data of negative sample objects, the historical order features of negative sample objects can be obtained.
[0122] To improve the model's accuracy, in this embodiment, after obtaining the historical order features of both positive and negative sample objects, feature optimization can be performed on these features. For the historical order features of positive sample objects, the correlation of each sub-order feature within the historical order features is calculated, and then sub-order features with a correlation greater than a preset threshold are removed to obtain the optimized historical order features of the positive sample objects. Similarly, for the historical order features of negative sample objects, the correlation of each sub-order feature within the historical order features is calculated, and then sub-order features with a correlation greater than a preset threshold are removed to obtain the optimized historical order features of the negative sample objects.
[0123] After obtaining the optimized historical order features of both positive and negative sample objects, the optimized historical order features of the positive sample objects are labeled as positive samples, and the optimized historical order features of the negative sample objects are labeled as negative samples. For example, if the positive sample objects are from micro-enterprises and the negative sample objects are from non-micro-enterprises, then the positive sample label can be a micro-enterprise label, and the negative sample label can be a non-micro-enterprise label.
[0124] After labeling the historical order features of positive sample objects as positive samples and the historical order features of negative sample objects as negative samples, the historical order features of both positive and negative sample objects can be input into the initial first model for training to obtain the first model.
[0125] In this embodiment, the steps of inputting the historical order features of positive sample objects and the historical order features of negative sample objects into the initial first model for training to obtain the first model include:
[0126] Decision trees are constructed based on the historical order characteristics of the sample objects.
[0127] The objective function of the initial first model is minimized to determine the structure of the decision tree, thus obtaining the first model.
[0128] Specifically, when inputting the historical order features of positive sample objects and the historical order features of negative sample objects into the initial first model for training, the positive sample labels of the historical order features of positive sample objects and the negative sample labels of the historical order features of negative sample objects must be input into the initial first model for training at the same time.
[0129] After inputting the historical order features of positive sample objects and negative sample objects into the initial first model, a decision tree can be constructed based on all historical order features. Then, the objective function of the initial first model is minimized to determine the structure of the decision tree. Once the structure of the decision tree is determined, the model is trained.
[0130] The first model, XGBoost, is an improvement on the gradient boosting algorithm. It employs Newton's method to find the extremum of the loss function, expands the loss function to second-order Taylor expansion, and adds a regularization term to the loss function. The XGBoost loss function, i.e., the original objective function, is defined as:
[0131]
[0132] Where n is the number of training samples, l is the loss for a single sample, and y i Let ' be the predicted value of the i-th sample, yi be the true label value of the i-th sample, and φ be the model parameters. The regularization term Ω(f) k The complexity of the model is defined by ∑. k Ω(f k ) represents the sum of the time complexity of all k trees, f k This represents the k-th decision tree.
[0133] Where γ and λ are manually set coefficients, w is the vector formed by all leaf node values of the decision tree, and T is the number of leaf nodes. The regularization term Ω(f) consists of two terms: the number of leaf nodes and the modulus square of the leaf node value vector. The first term reflects the complexity of the decision tree structure, and the second term reflects the complexity of the decision tree predictions.
[0134] It should be noted that the two accumulated variables i and k in the objective function are different. i represents the number of samples, meaning that a loss is calculated for each sample, which is the difference between the predicted value of the k-th tree and the true label value. k represents the number of trees, where the complexity of each tree is accumulated.
[0135] During training, the objective function of the first model, the XGBoost model, consists of two parts: the gradient boosting algorithm loss and the regularization term. Similar to the gradient boosting algorithm, the XGBoost model uses an additive model to represent the strong learner. Assume y′ i,t-1 Let f be the prediction value of the strong learner for the i-th sample at the t-th iteration. During training, the function f of each weak learner is determined sequentially. t Adding this to the prediction function of the strong learner will minimize the following objective function:
[0136]
[0137] Among them, L t Let y be the objective function, n be the number of samples, l be the loss per sample, and y be the loss per sample. i Let Ω(f) be the true label value of the i-th sample. t ) represents the regularization term, and f represents the complexity of the t-th tree. t (X i Let t be the model of the t-th tree.
[0138] In this embodiment, by expanding the objective function using the second-order Taylor formula and minimizing the objective function value, f can be determined. t After determining f t Then, the number of decision trees and their structure are obtained. Once the tree structure of the decision trees is determined, the training of the model is complete, and the first model is obtained.
[0139] After obtaining the first model, a greedy algorithm is used to find the optimal split point of the leaf node of the decision tree. Then, the nodes of each branch of the decision tree are combined to obtain the combined features of positive sample objects and the combined features of negative sample objects, and then output them.
[0140] The object classification method provided in this embodiment, by constructing an XGBoost model and utilizing the feature filtering function of the XGBoost model, can ensure that after the model is trained, the features selected from the root to the leaf are all locally optimal combinations, thereby ensuring that the combined features input into the second model are all features with good performance.
[0141] To achieve the classification processing of the second model, in this embodiment, the second model also needs to be trained. Therefore, before inputting the combined features and order features of the target object into the pre-trained second model to obtain the group category to which the target object belongs, the method provided in this embodiment further includes:
[0142] Obtain the combined features of the sample object output by the first model, as well as the historical order features of that sample object.
[0143] Based on the combined features of the sample objects output by the first model and the historical order features of the sample objects, the initial second model is trained to obtain the second model.
[0144] The combined features of the sample objects output by the first model include the combined features of positive sample objects and the combined features of negative sample objects. Therefore, after obtaining the combined features of positive and negative sample objects, it is also necessary to obtain the historical order features of positive and negative sample objects.
[0145] After obtaining the historical order features and combined features of positive sample objects and negative sample objects, the initial second model can be trained based on the historical order features and combined features of positive sample objects and negative sample objects to obtain the second model.
[0146] Optionally, in this embodiment, the step of training the initial second model to obtain the second model includes:
[0147] The combined features of the sample object output by the first model and the historical order features of the sample object are input into the initial second model to obtain the predicted value of the initial second model.
[0148] Calculate the loss between the predicted value and the label value of the sample object, determine whether the loss meets the preset condition, if not, backpropagate the loss, adjust the parameters of the initial second model to obtain the intermediate second model, until the loss between the predicted value and the label value output by the intermediate second model meets the preset condition, and obtain the second model.
[0149] In this process, after obtaining the combined features of the sample objects output by the first model and the historical order features of those sample objects (i.e., after obtaining the historical order features and combined features of positive sample objects and negative sample objects), the historical order features and combined features of positive sample objects are concatenated to obtain the concatenated features of positive sample objects. Similarly, the historical order features and combined features of negative sample objects are concatenated to obtain the concatenated features of negative sample objects. Then, the concatenated features of positive sample objects and positive sample labels, and the concatenated features of negative sample objects and negative sample labels are combined to form a new dataset. This dataset is then divided into a test set and a training set according to a set ratio. The training set is input into the initial second model for training. Optionally, in this embodiment, the set ratio can be set according to actual needs; for example, the ratio of the test set to the training set can be 2:8, or 3:7. After the training set is input into the initial second model, for each sample object in the training set, the initial second model calculates a predicted value based on the concatenated features of that sample object. After obtaining the predicted value of the sample object, the loss between the predicted value and the label value (i.e., sample label) of the sample object is calculated. It is then determined whether the loss meets a preset condition. If not, the loss is backpropagated to adjust the parameters of the initial second model, resulting in an intermediate second model. After obtaining the intermediate second model, it recalculates the predicted value of the next sample object based on the historical order features and combination features of the next sample object, and calculates the loss between the predicted value and the label value of the next sample object. It then determines whether the recalculated loss meets a preset condition. If not, the recalculated loss is backpropagated to adjust the parameters of the intermediate second model until the loss between the predicted value and the label value output by the intermediate second model meets the preset condition, thus obtaining the second model.
[0150] Optionally, in this embodiment, a cross-entropy loss function can be used to calculate the loss between the predicted value and the label value. By minimizing the cross-entropy loss function, the model parameters are gradually adjusted to obtain the optimal model parameters. In this embodiment, the preset condition can be that the loss reaches convergence, that is, the loss value reaches the global minimum.
[0151] After training the second model using the training set, the trained second model can be tested using the test set to evaluate its classification ability.
[0152] The object classification method provided in this embodiment, by using a combination architecture of XGBoost and LR models, achieves an area under the curve (AUC) of 0.72 when classifying objects, and a Kolmogorov-Smirnov (KS) value of 0.48, which is used to evaluate the risk discrimination ability of the model, thus achieving relatively effective object classification.
[0153] After training the first and second models, they can be applied to object category recognition. To identify the category of an object, only order data such as waybill information, monthly settlement information, COD information, and warehousing information need to be obtained. Then, feature engineering is used to perform comprehensive data analysis, extracting order features such as monthly shipment volume, shipment costs, year-on-year and month-on-month fluctuations in shipment volume and costs, cooperation status, and cash-on-delivery status. After obtaining the order features, the correlation between each pair of sub-order features is calculated using the Pearson correlation coefficient. Based on a preset threshold, highly correlated order features are removed. The remaining order features are then input into the first model for filtering and combination to obtain new combined features. These combined features, along with the remaining order features, are then input into the second model for classification to determine the group category to which the object belongs.
[0154] The object classification method provided in this embodiment combines a first model and a second model. After obtaining the order data of the target object, it extracts features from the order data to obtain the order features of the target object. These order features are then input into a pre-trained first model to obtain the combined features of the target object. Finally, by inputting the combined features and the order features of the target object into a pre-trained second model, the group category to which the target object belongs can be determined. Thus, effective object classification is achieved.
[0155] Based on the same inventive concept, please refer to Figure 3 This embodiment also provides an object classification device 10, which is applied to... Figure 1 The illustrated electronic device, object sorting apparatus 10, includes at least one software function module that can be stored in the electronic device's memory 20 in the form of software or firmware. For example... Figure 1 As shown, the object classification device 10 provided in this embodiment includes a data acquisition module 11, a feature extraction module 12, a first processing module 13, and a second processing module 14.
[0156] The data acquisition module 11 is used to acquire the order data of the target object.
[0157] The feature extraction module 12 is used to extract features from the order data to obtain the order features of the target object.
[0158] The first processing module 13 is used to input the order features of the target object into the pre-trained first model to obtain the combined features of the target object.
[0159] The second processing module 14 is used to input the combined features and order features of the target object into the pre-trained second model to obtain the group category to which the target object belongs.
[0160] The object classification device provided in this embodiment combines a first model and a second model. After obtaining the order data of the target object, it extracts features from the order data to obtain the order features of the target object. These order features are then input into the pre-trained first model to obtain the combined features of the target object. Finally, by inputting the combined features and the order features of the target object into the pre-trained second model, the group category to which the target object belongs can be obtained. Thus, effective object classification is achieved.
[0161] In the optional implementation, please refer to the following: Figure 4 The object classification device 10 provided in this embodiment further includes a first model training module 15. Before inputting the order features of the target object into the pre-trained first model to obtain the combined features of the target object, the first model training module 15 is used for:
[0162] Retrieve historical order data for the sample object.
[0163] Feature extraction is performed on historical order data to obtain the historical order features of the sample objects.
[0164] Based on the historical order characteristics of the sample objects, the initial first model is trained to obtain the first model.
[0165] In an optional implementation, the first model training module 15 is specifically used for:
[0166] Decision trees are constructed based on the historical order characteristics of the sample objects.
[0167] The objective function of the initial first model is minimized to determine the structure of the decision tree, thus obtaining the first model.
[0168] In an optional implementation, the object classification device 10 provided in this embodiment further includes a second model training module 16. Before inputting the combined features and order features of the target object into the pre-trained second model to obtain the group category to which the target object belongs, the second model training module 16 is used for:
[0169] Obtain the combined features of the sample object output by the first model, as well as the historical order features of that sample object.
[0170] Based on the combined features of the sample objects output by the first model and the historical order features of the sample objects, the initial second model is trained to obtain the second model.
[0171] In an optional implementation, the second model training module 16 is used for:
[0172] The combined features of the sample object output by the first model and the historical order features of the sample object are input into the initial second model to obtain the predicted value of the initial second model;
[0173] Calculate the loss between the predicted value and the label value of the sample object, determine whether the loss meets the preset condition, if not, backpropagate the loss, adjust the parameters of the initial second model to obtain the intermediate second model, until the loss between the predicted value and the label value output by the intermediate second model meets the preset condition, and obtain the second model.
[0174] In an optional implementation, the first processing module 13 is specifically used for:
[0175] The order features of the target object are input into the first model, and a greedy algorithm is used to obtain the split nodes of each branch of the decision tree in the first model.
[0176] Based on the split nodes of each branch of the decision tree, the combined features of the target object are obtained.
[0177] In an optional implementation, the first processing module 13 is specifically used to: preprocess the order features to obtain preprocessed order features.
[0178] The preprocessed order features are input into the first model to obtain the combined features of the target object.
[0179] In an optional implementation, the order features include at least two sub-order features. The first processing module 13 is used to preprocess the order features to obtain the preprocessed order features, including the following steps:
[0180] Calculate the correlation between every two of the sub-order features;
[0181] Determine whether there is a target relevance greater than a preset threshold;
[0182] If they exist, the correlation between the two target sub-order features corresponding to the target correlation and other sub-order features is obtained respectively. The target sub-order feature corresponding to the highest correlation is removed to obtain the preprocessed order features.
[0183] The object classification device provided in this embodiment of the invention, after acquiring order data of a target object, extracts features from the order data to obtain order features of the target object. These order features are then input into a pre-trained first model to obtain combined features of the target object. Finally, the combined features and order features are input into a pre-trained second model to obtain the group category to which the target object belongs. Thus, through the combination of the first and second models, accurate object classification is achieved.
[0184] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the object classification device 10 described above can be referred to the corresponding process in the aforementioned method, and will not be elaborated further here.
[0185] Based on the above, this embodiment also provides a readable storage medium storing a computer program, which, when executed by a processor, implements the object classification method described in any of the foregoing embodiments.
[0186] The readable storage medium can be, but is not limited to, USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks, and other media capable of storing program code.
[0187] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working process of the readable storage medium described above can be referred to the corresponding process in the aforementioned method, and will not be elaborated further here.
[0188] In summary, the object classification method, apparatus, electronic device, and readable storage medium provided in this embodiment of the invention, after acquiring order data of a target object, extract features from the order data to obtain order features of the target object. By inputting the order features of the target object into a pre-trained first model, combined features of the target object are obtained. The combined features of the target object and the order features are then input into a pre-trained second model to obtain the group category to which the target object belongs. Thus, through the combination of the first and second models, accurate object classification is achieved.
[0189] In the several embodiments provided in this invention, it should be understood that the disclosed apparatus and methods can also be implemented in other ways. The apparatus and method embodiments described above are merely illustrative; for example, the flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods, and computer program products according to various embodiments of the invention. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than those marked in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram and / or flowchart, and combinations of blocks in block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.
[0190] In addition, the functional modules in the embodiments of the present invention can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.
[0191] If the aforementioned functions are implemented as software functional modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, electronic device, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks. It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. In the absence of further restrictions, an element defined by the phrase "comprising a..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0192] The above descriptions are merely various embodiments of the present invention, but the scope of protection of the present invention is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the present invention should be included within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
Claims
1. An object classification method, characterized in that, The method includes: Retrieve order data for the target object; Feature extraction is performed on the order data to obtain the order features of the target object; The order features are preprocessed to obtain preprocessed order features; wherein, the order features include at least two sub-order features, and the preprocessing includes: calculating the correlation between each pair of sub-order features; determining whether there is a target correlation greater than a preset threshold; if so, obtaining the correlation between the two target sub-order features corresponding to the target correlation and other sub-order features respectively, removing the target sub-order feature corresponding to the highest correlation, and obtaining the preprocessed order features; The preprocessed order features are input into a pre-trained first model. A greedy algorithm is used to obtain the splitting nodes of each branch of the decision tree in the first model. When the greedy algorithm is used to find the optimal splitting node of the leaf node of the decision tree, if the gain of the objective function of the first model after splitting is greater than the function value before splitting is greater than a set threshold, the leaf node of the decision tree is split. Based on the splitting nodes of each branch of the decision tree, the combined features of the target object are obtained. The combined features of the target object and the preprocessed order features are input into the pre-trained second model to obtain the group category to which the target object belongs.
2. The object classification method according to claim 1, characterized in that, Before obtaining the combined features of the target object, the method further includes: Retrieve historical order data for the sample object; Feature extraction is performed on the historical order data to obtain the historical order features of the sample object; Based on the historical order characteristics of the sample objects, the initial first model is trained to obtain the first model.
3. The object classification method according to claim 2, characterized in that, The step of training the initial first model based on the historical order features of the sample objects to obtain the first model includes: Construct a decision tree based on the historical order characteristics of the sample objects; The objective function of the initial first model is minimized to determine the structure of the decision tree, thus obtaining the first model.
4. The object classification method according to claim 1, characterized in that, Before inputting the combined features of the target object and the preprocessed order features into the pre-trained second model to obtain the group category to which the target object belongs, the method further includes: Obtain the combined features of the sample object output by the first model and the historical order features of the sample object; Based on the combined features of the sample object output by the first model and the historical order features of the sample object, the initial second model is trained to obtain the second model.
5. The object classification method according to claim 4, characterized in that, The step of training the initial second model based on the combined features of the sample object output by the first model and the historical order features of the sample object to obtain the second model includes: The combined features of the sample object output by the first model and the historical order features of the sample object are input into the initial second model to obtain the predicted value of the initial second model; Calculate the loss between the predicted value and the label value of the sample object, determine whether the loss meets the preset condition, if not, backpropagate the loss, adjust the parameters of the initial second model to obtain an intermediate second model, until the loss between the predicted value and the label value output by the intermediate second model meets the preset condition, and obtain the second model.
6. An object classification device, characterized in that, include: The data acquisition module is used to acquire order data of the target object; The feature extraction module is used to extract features from the order data to obtain the order features of the target object; The first processing module is used to preprocess the order features to obtain preprocessed order features. The order features include at least two sub-order features. The preprocessing includes: calculating the correlation between each pair of sub-order features; determining whether there is a target correlation greater than a preset threshold; if so, obtaining the correlation between the two target sub-order features corresponding to the target correlation and other sub-order features, removing the target sub-order feature corresponding to the highest correlation, and obtaining the preprocessed order features; inputting the preprocessed order features into a pre-trained first model, using a greedy algorithm to obtain the splitting nodes of each branch of the decision tree in the first model; when using the greedy algorithm to find the optimal splitting node of the leaf node of the decision tree, if the gain of the objective function of the first model after splitting is greater than a set threshold, the leaf node of the decision tree is split; and based on the splitting nodes of each branch of the decision tree, the combined features of the target object are obtained. The second processing module is used to input the combined features of the target object and the preprocessed order features into the pre-trained second model to obtain the group category to which the target object belongs.
7. An electronic device, characterized in that, It includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the object classification method according to any one of claims 1 to 5.
8. A readable storage medium, characterized in that, The readable storage medium includes a computer program, which, when executed, controls the electronic device containing the readable storage medium to perform the object classification method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Object category determination method and device, electronic equipment and computer storage medium
CN109697637A
Ultra-short-term wind speed prediction method
CN110210660A
Method and device for predicting destination, and storage medium
CN110689158A