Logistic regression classifier generation, image classification methods, apparatuses, devices, and media
By generating a logistic regression decision tree through iterative logistic regression classification and encoding the sample data, the problem of high computational complexity of existing logistic regression classifiers is solved, achieving low-cost and efficient data classification.
Patent Information
- Application Number
- CN202110215791.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-02-26
- Publication Date
- 2026-01-23
- Estimated Expiration
- 2041-02-26
AI Technical Summary
Existing logistic regression classifiers have high computational complexity when dealing with linearly inseparable data. They introduce too many hyperparameters and cannot guarantee that the data is linearly separable, which increases computational costs.
Logistic regression decision trees are generated through iterative logistic regression classification. Sample data is encoded to construct a linear logistic regression classifier. The target logistic regression classifier is then trained using the encoded data, avoiding the use of kernel functions.
It reduces the computational cost of data classification, decreases computational complexity and the use of hyperparameters, ensures that data is linearly separable, and improves classification efficiency.
Smart Images

Figure CN113780325B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] Embodiments of the present disclosure relate to the technical field of computer technology, and particularly, to a logistic regression classifier generation method, an image classification method, an apparatus, a device and a medium. BACKGROUND
[0002] Data classification is a method for determining the category of data (e.g., image data). At present, when classifying data, the commonly used method is to classify linearly separable or approximately linearly separable data through a logistic regression classifier, or to introduce a kernel function into the logistic regression classifier to classify linearly inseparable data.
[0003] However, when classifying data in the above manner, the following technical problems often exist:
[0004] When classifying linearly inseparable data by using a logistic regression classifier with a kernel function introduced, the computational complexity is high, too many hyperparameters are introduced, and it cannot be guaranteed that the data projected by the kernel function is linearly separable, which may result in an increase in the computational cost of data classification. SUMMARY
[0005] The summary part of the present disclosure is used to introduce the concepts in a brief form, which will be described in detail in the specific embodiments part. The summary part of the present disclosure is not intended to identify key or essential features of the claimed technical solutions, nor is it intended to limit the scope of the claimed technical solutions.
[0006] Some embodiments of the present disclosure propose a logistic regression classifier generation method, an image classification method, an apparatus, a device and a medium to solve the technical problems mentioned in the background part.
[0007] In a first aspect, some embodiments of the present disclosure provide a logistic regression classifier generation method, which comprises: obtaining a training sample set, wherein the training samples in the training sample set comprise a sample feature set and a category label, and the training samples in the training sample set are image samples; generating a logistic regression decision tree according to iterative logistic regression classification of the training sample set, wherein the logistic regression decision tree comprises at least one split node, and the split node is a logistic regression classifier; encoding each training sample in the training sample set based on the logistic regression decision tree to generate an encoded feature vector, to obtain an encoded feature vector set; and training an initial logistic regression classifier by using the encoded feature vector set to generate a target logistic regression classifier.
[0008] Optionally, the generating the logistic regression decision tree according to the iterative logistic regression classification of the training sample set comprises: in response to determining that the training sample set does not satisfy a preset condition, performing logistic regression classification on the training sample set to obtain two training sample subsets and a logistic regression classifier; determining the logistic regression classifier as a split node of a leaf node of an initial decision tree, wherein the split node is used to split the leaf node into two leaf nodes and divide the training sample set into two training sample subsets; and in response to determining that the initial decision tree satisfies an iteration termination condition, determining the initial decision tree as the logistic regression decision tree, wherein each split node in the logistic regression decision tree has a unique identifier.
[0009] Optionally, the generating the logistic regression decision tree according to the iterative logistic regression classification of the training sample set further comprises: in response to determining that the initial decision tree does not satisfy the iteration termination condition, determining each of the two training sample subsets as a training sample set, and continuing to perform the processing steps.
[0010] Optionally, the encoding each training sample in the training sample set based on the logistic regression decision tree to generate an encoded feature vector comprises: encoding values in an initial feature vector of the training sample according to a classification of the training sample by each split node in the logistic regression decision tree to obtain an encoded feature vector, wherein a dimension of the initial feature vector is determined according to a number of split nodes in the logistic regression decision tree.
[0011] Optionally, the encoding values in an initial feature vector according to a classification of the training sample by each split node in the logistic regression decision tree comprises: in response to determining that the training sample passes through the split node, changing a value at a position corresponding to the split node in the initial feature vector to a value corresponding to a classification result of the training sample by the split node.
[0012] Optionally, the image sample is a face image sample or a handwritten character image sample, the sample feature set included in the image sample includes pixel values of each pixel in an image represented by the image sample, the class label included in the face image sample is a first preset label, and the class label included in the handwritten character image sample is a second preset label.
[0013] In a second aspect, some embodiments of the present disclosure provide an image classification method, which comprises: obtaining an image to be classified; encoding the image to be classified by using a logistic regression decision tree to generate an encoded feature vector; and inputting the encoded feature vector into a target logistic regression classifier to obtain a classification result of the image to be classified.
[0014] In a third aspect, some embodiments of the present disclosure provide a logistic regression classifier generation apparatus, which comprises: an obtaining unit configured to obtain a training sample set, wherein each training sample in the training sample set comprises a sample feature set and a class label, and each training sample in the training sample set is an image sample; a generating unit configured to generate a logistic regression decision tree according to iterative logistic regression classification of the training sample set, wherein the logistic regression decision tree comprises at least one split node, and each split node is a logistic regression classifier; an encoding unit configured to encode each training sample in the training sample set based on the logistic regression decision tree to generate an encoded feature vector, thereby obtaining an encoded feature vector set; and a training unit configured to train an initial logistic regression classifier by using the encoded feature vector set to generate a target logistic regression classifier.
[0015] Optionally, the generating unit of the logistic regression classifier generation apparatus is further configured to perform the following processing steps on the training sample set: in response to determining that the training sample set does not satisfy a preset condition, performing logistic regression classification on the training sample set to obtain two training sample subsets and a logistic regression classifier; determining the logistic regression classifier as a split node of a leaf node of an initial decision tree, wherein the split node is used to split the leaf node into two leaf nodes and divide the training sample set into two training sample subsets; and in response to determining that the initial decision tree satisfies an iteration termination condition, determining the initial decision tree as a logistic regression decision tree, wherein each split node in the logistic regression decision tree has a unique identifier.
[0016] Optionally, the generating unit of the logistic regression classifier generation apparatus is further configured to: in response to determining that the initial decision tree does not satisfy the iteration termination condition, continue to perform the processing steps by respectively determining each of the two training sample subsets as a training sample set.
[0017] Optionally, the encoding unit of the logistic regression classifier generation apparatus is further configured to: encode a value in an initial feature vector of each training sample in the training sample set according to a classification result of the training sample in each split node in the logistic regression decision tree, thereby obtaining an encoded feature vector, wherein a dimension of the initial feature vector is determined according to a number of split nodes in the logistic regression decision tree.
[0018] Optionally, the values in the initial feature vector are encoded according to the classification of the training sample by each split node in the logistic regression decision tree, including: in response to determining that the training sample passes through the split node, changing the value at the position in the initial feature vector corresponding to the split node to a value corresponding to the classification result of the training sample by the split node.
[0019] Optionally, the image sample is a face image sample or a handwritten character image sample, the sample feature set included in the image sample includes pixel values of each pixel in the image represented by the image sample, the class label included in the face image sample is a first preset label, and the class label included in the handwritten character image sample is a second preset label.
[0020] In a fourth aspect, some embodiments of the present disclosure provide an image classification apparatus, the apparatus comprising: an acquisition unit configured to acquire an image to be classified; an encoding unit configured to encode the image to be classified by using a logistic regression decision tree to generate an encoded feature vector; and an input unit configured to input the encoded feature vector into a target logistic regression classifier to obtain a classification result of the image to be classified.
[0021] In a fifth aspect, some embodiments of the present disclosure provide an electronic device, including: one or more processors; and a storage device having one or more programs stored thereon, when the one or more programs are executed by the one or more processors, the one or more processors implement the method described in any of the implementation manners of the first and second aspects.
[0022] In a sixth aspect, some embodiments of the present disclosure provide a computer readable medium having a computer program stored thereon, wherein the program is executed by a processor to implement the method described in any of the implementation manners of the first and second aspects.
[0023] The above embodiments of this disclosure have the following beneficial effects: the logistic regression classifier obtained by the logistic regression classifier generation method of some embodiments of this disclosure reduces the computational cost of data classification. Specifically, the reason for the high computational cost of the related logistic regression classifier when classifying data is that: when using the logistic regression classifier with the introduction of a kernel function to classify data, the computational complexity is high, too many hyperparameters are introduced, and it is impossible to guarantee that the data after projection using the kernel function is linearly separable. Based on this, the logistic regression classifier generation method of some embodiments of this disclosure firstly performs linear logistic regression classification iteratively on the sample data to construct a logistic regression decision tree; then, the sample data is encoded into a new feature space according to the generated logistic regression decision tree, so that the encoded sample data is linearly separable; finally, the initial logistic regression classifier is trained using the encoded sample data to obtain the final target logistic regression classifier. In the above method, a linear logistic regression classifier is used throughout the entire process. Because the linear logistic regression classifier has low computational complexity, almost no hyperparameters, and the data encoded by the logistic regression decision tree is linearly separable or approximately linearly separable data. Therefore, it can effectively avoid the problems of high computational complexity, excessive hyperparameters, and inability to guarantee linear separability of projected data when using a logistic regression classifier with kernel functions to classify data, thus reducing the computational cost of data classification. Attached Figure Description
[0024] The above and other features, advantages, and aspects of the embodiments of this disclosure will become more apparent from the accompanying drawings and the following detailed description. Throughout the drawings, the same or similar reference numerals denote the same or similar elements. It should be understood that the drawings are schematic, and elements are not necessarily drawn to scale.
[0025] Figure 1 This is a schematic diagram illustrating an application scenario of the logistic regression classifier generation method according to some embodiments of this disclosure;
[0026] Figure 2 This is a schematic diagram illustrating an application scenario of the image classification method according to some embodiments of this disclosure;
[0027] Figure 3 This is a flowchart of some embodiments of the logistic regression classifier generation method according to this disclosure;
[0028] Figure 4 This is a flowchart of some other embodiments of the logistic regression classifier generation method according to the present disclosure;
[0029] Figure 5 This is a flowchart of some embodiments of the image classification method according to the present disclosure;
[0030] Figure 6 is a structural schematic diagram of some embodiments of a logic regression classifier generation apparatus according to the present disclosure;
[0031] Figure 7 is a structural schematic diagram of some embodiments of an image classification apparatus according to the present disclosure;
[0032] Figure 8 is a structural schematic diagram of an electronic device suitable for implementing some embodiments of the present disclosure. DETAILED DESCRIPTION
[0033] Embodiments of the present disclosure will be described below in greater detail with reference to the accompanying drawings. While certain embodiments of the present disclosure are shown in the drawings, it is understood that the present disclosure can be embodied in various forms and should not be construed as being limited to the embodiments set forth herein. Rather, these embodiments are provided so that the present disclosure will be thoroughly and completely understood. It should be understood that the drawings and embodiments of the present disclosure are only for illustrative purposes and are not intended to limit the scope of protection of the present disclosure.
[0034] It should also be noted that, for ease of description, only parts related to the present application are shown in the drawings. The embodiments in the present disclosure and the features in the embodiments can be combined with each other without conflict.
[0035] It should be noted that the terms "first", "second", and the like mentioned in the present disclosure are only used to distinguish different devices, modules or units, and are not intended to limit the order or interdependence of the functions performed by these devices, modules or units.
[0036] It should be noted that the terms "one", "multiple" mentioned in the present disclosure are illustrative and not restrictive, and those skilled in the art should understand that unless otherwise explicitly stated in the context, it should be understood as "one or more".
[0037] The names of the messages or information exchanged between the devices in the embodiments of the present disclosure are only for illustrative purposes, and are not intended to limit the scope of the messages or information.
[0038] The present disclosure will be described in detail below with reference to the accompanying drawings and in conjunction with the embodiments.
[0039] Figure 1 is a structural schematic diagram of some embodiments of a logic regression classifier generation method of the present disclosure.
[0040] In Figure 1In an application scenario of the image classification method, first, the computing device 101 can obtain a training sample set 102, wherein a training sample in the training sample set 102 includes a sample feature set and a category label, and the training sample in the training sample set 102 is an image sample. Then, the computing device 101 can generate a logistic regression decision tree 103 according to iterative logistic regression classification on the training sample set 102, wherein the logistic regression decision tree 103 includes at least one split node, and the split node is a logistic regression classifier. Then, the computing device 101 can encode each training sample in the training sample set 102 based on the logistic regression decision tree 103 to generate an encoded feature vector, and obtain an encoded feature vector set 104. Finally, the computing device 101 can train an initial logistic regression classifier 105 by using the encoded feature vector set 104 to generate a target logistic regression classifier 106.
[0041] It should be noted that the computing device 101 can be hardware or software. When the computing device is hardware, it can be implemented as a distributed cluster composed of multiple servers or terminal devices, or as a single server or a single terminal device. When the computing device is software, it can be installed in the hardware devices listed above. It can be implemented as multiple software or software modules for providing distributed services, or as a single software or software module. No specific limitation is made herein.
[0042] It should be understood that Figure 1 The number of computing devices in the above is only illustrative. According to the implementation needs, there can be any number of computing devices.
[0043] Figure 2 FIG. 1 is a schematic diagram of an application scenario of an image classification method according to some embodiments of the present disclosure.
[0044] In the application scenario of the image classification method, Figure 2 In an application scenario of the image classification method, first, the computing device 201 can obtain a to-be-classified image 202. Then, the computing device 201 can encode the to-be-classified image 202 by using a logistic regression decision tree 203 to generate an encoded feature vector 204. Finally, the computing device 201 can input the encoded feature vector 204 into a target logistic regression classifier 205 to obtain a classification result 206 of the to-be-classified image 202.
[0045] It should be noted that the computing device 201 described above can be hardware or software. When the computing device is hardware, it can be implemented as a distributed cluster composed of multiple servers or terminal devices, or as a single server or a single terminal device. When the computing device is software, it can be installed in the hardware devices listed above. It can be implemented as multiple software or software modules, such as to provide distributed services, or as a single software or software module. No specific limitation is made here.
[0046] It should be understood that Figure 2 The number of computing devices in the above description is only illustrative. Any number of computing devices can be provided according to the needs of implementation.
[0047] With reference to Figure 3 , a flow 300 of some embodiments of a logistic regression classifier generation method according to the present disclosure is shown. The logistic regression classifier generation method includes the following steps:
[0048] Step 301, obtaining a training sample set.
[0049] In some embodiments, the subject of execution of the logistic regression classifier generation method (such as the computing device 101 shown in Figure 1 The training sample set can be obtained by the computing device 101 through wired or wireless connection. The wireless connection can include, but is not limited to, 3G / 4G connection, WiFi connection, Bluetooth connection, WiMAX connection, Zigbee connection, UWB (ultrawideband) connection, and other now known or future developed wireless connection methods. The training samples in the training sample set can include a sample feature set and a category label. The training samples in the training sample set can be image samples. The sample features in the sample feature set can be features obtained by pre-feature extraction on the data represented by the training samples. They can also be attribute information of the data represented by the training samples. The category label can be a label pre-labeled for the training samples to represent the category. The category label can be represented by numbers or letters, etc.
[0050] As an example, the image samples can be recyclable material image samples or wet garbage image samples. The sample features in the sample feature set included in the image samples can be color features, texture features, shape features, etc. The sample features can be obtained by pre-image feature extraction algorithm. The image feature extraction algorithm can be a histogram of oriented gradients feature extraction algorithm, a Gaussian function difference feature extraction algorithm, etc. The category label included in the recyclable material image samples can be -1. The category label included in the wet garbage image samples can be -2.
[0051] In some optional implementations of some embodiments, the image sample can be a face image sample or a handwritten character image sample. The set of sample features included in the image sample can include pixel values of respective pixels in an image represented by the image sample. The class label included in the face image sample can be a first preset label. The class label included in the handwritten character image sample can be a second preset label.
[0052] As an example, the first preset label can be 0, used to represent that the image sample is a face image sample. The first preset label can be 1, used to represent that the image sample is a handwritten character image sample.
[0053] At step 302, a logistic regression decision tree is generated according to the iterative logistic regression classification on the training sample set.
[0054] In some embodiments, the logistic regression decision tree can include at least one split node, and the split node can be a logistic regression classifier. The execution subject can generate the logistic regression decision tree according to the iterative logistic regression classification on the training sample set, and can perform the following processing steps on the training sample set:
[0055] First, in response to determining that the training sample set does not satisfy a preset condition, the training sample set is classified by logistic regression to obtain two training sample subsets and a logistic regression classifier. The preset condition can be that the class labels included in each training sample in the training sample set are all the same.
[0056] As an example, the training samples in the training sample set can be face image samples or handwritten character image samples. The training sample set can be {[pixel value set, 1], [pixel value set, 0], [pixel value set, 0], [pixel value set, 1], [pixel value set, 1], [pixel value set, 1], [pixel value set, 0], [pixel value set, 1]}. The class labels included in each training sample in the training sample set are different. Therefore, the training sample set does not satisfy the preset condition.
[0057] Optionally, in response to determining that the training sample set satisfies the preset condition, subsequent processing steps on the training sample set are terminated. In this way, when the class labels included in each training sample in the training sample set are all the same, i.e., the training sample set does not need to be classified, the classification of the training sample set and the construction of the corresponding branch in the initial decision tree can be terminated in time, saving computing resources.
[0058] As an example, the training sample set can be {[pixel value set, 1}, {pixel value set, 1}, {pixel value set, 1}, {pixel value set, 1}, {pixel value set, 1}}. Each training sample in the training sample set includes the same class label. Thus, the training sample set satisfies the preset condition.
[0059] In the second step, the logistic regression classifier is determined as a split node of a leaf node of the initial decision tree. The split node can be used to split the leaf node into two leaf nodes and divide the training sample set into two training sample subsets.
[0060] As an example, the training samples included in the leaf node of the initial decision tree can be {[pixel value set, 1}, {pixel value set, 0}, {pixel value set, 0}, {pixel value set, 1}, {pixel value set, 1}, {pixel value set, 1}, {pixel value set, 0}, {pixel value set, 1}}. The training samples included in the two leaf nodes can be {[pixel value set, 1}, {pixel value set, 0}, {pixel value set, 0}} and {[pixel value set, 1}, {pixel value set, 1}, {pixel value set, 1}, {pixel value set, 0}, {pixel value set, 1}}, respectively.
[0061] In the third step, in response to determining that the initial decision tree satisfies the iteration termination condition, the initial decision tree is determined as a logistic regression decision tree. Each split node in the logistic regression decision tree can have a unique identifier. The unique identifier can be represented by a number. The iteration termination condition can be that the total classification accuracy of the sample data in all leaf nodes of the initial decision tree is greater than a preset accuracy. The iteration termination condition can also be that the value of the loss function of the initial decision tree is less than a preset loss function value. The loss function can be a regularized maximum likelihood function. Thus, the construction of the initial decision tree can be terminated in time, and overfitting can be avoided.
[0062] As an example, the preset accuracy can be 85%.
[0063] In some optional implementations of some embodiments, in response to determining that the initial decision tree does not satisfy the iteration termination condition, the execution subject can determine each of the two training sample subsets as a training sample set and continue to perform the processing steps.
[0064] In step 303, each training sample in the training sample set is encoded based on the logistic regression decision tree to generate an encoded feature vector, and an encoded feature vector set is obtained.
[0065] In some embodiments, the execution subject encodes each training sample in the training sample set based on the logistic regression decision tree to generate an encoded feature vector, to obtain an encoded feature vector set, which can include the following steps:
[0066] In a first step, the encoding value of each split node for the training sample is determined according to the passing condition of the training sample at each split node in the logistic regression decision tree. The passing condition can be passing or not passing. Passing can mean that the training sample has passed the classification of the split node. Not passing can mean that the training sample has not passed the classification of the split node.
[0067] If the training sample passes a certain split node in the logistic regression decision tree, the encoding value of the split node for the training sample can be determined as 1. If the training sample does not pass a certain split node in the logistic regression decision tree, the encoding value of the split node for the training sample can be determined as 0.
[0068] In a second step, the encoding value of each split node for the training sample and the final classification result of the training sample by the logistic regression decision tree are combined according to a pre-set order to obtain an encoded feature vector. The pre-set order can be the order of the split nodes corresponding to the encoding values from top to bottom and left to right in the logistic regression decision tree.
[0069] As an example, the encoding values of each split node for the training sample in the logistic regression decision tree can be combined according to the order of the split nodes corresponding to the encoding values from top to bottom and left to right in the logistic regression decision tree to obtain an encoding value sequence. Then the final classification result of the training sample by the logistic regression decision tree is added to a target position of the encoding value sequence to obtain an encoded feature vector. The target position can be the tail or head of the encoding value sequence, etc. The classification result can be 1 or -1. 1 can be used to represent that the class of the training sample is "face image". -1 can be used to represent that the class of the training sample is "handwritten character image".
[0070] In step 304, the initial logistic regression classifier is trained using the encoded feature vector set to generate a target logistic regression classifier.
[0071] In some embodiments, the execution subject can train the initial logistic regression classifier using the encoded feature vector set to obtain logistic regression classifier parameters, thereby generating a target logistic regression classifier. The target logistic regression classifier is different from the logistic regression classifier in the split nodes of the logistic regression decision tree.
[0072] The above various embodiments of the present disclosure have the following beneficial effects: the computational cost of data classification is reduced by the logistic regression classifier generated by the logistic regression classifier generation method of some embodiments of the present disclosure. Specifically, the reason why the computational cost of the related logistic regression classifier is high when classifying data is that the logistic regression classifier with the introduced kernel function has high computational complexity, introduces too many hyperparameters, and cannot guarantee that the data projected by the kernel function is linearly separable. Based on this, the logistic regression classifier generation method of some embodiments of the present disclosure first performs linear logistic regression classification on the sample data iteratively to construct a logistic regression decision tree; then encodes the sample data into a new feature space according to the generated logistic regression decision tree, so that the encoded sample data is linearly separable; finally, the initial logistic regression classifier is trained using the encoded sample data to obtain the final target logistic regression classifier. In the above manner, a linear logistic regression classifier is used throughout the process. Since the linear logistic regression classifier has low computational complexity, almost no hyperparameters, and the data encoded by the logistic regression decision tree is linearly separable or approximately linearly separable. Therefore, the problems of high computational complexity, introduction of too many hyperparameters, and inability to guarantee linear separability of the projected data when classifying data using the logistic regression classifier with the introduced kernel function can be effectively avoided, and the computational cost of data classification is reduced.
[0073] Further reference is made to Figure 4 which shows the flow 400 of another embodiment of the logistic regression classifier generation method. The flow 400 of the logistic regression classifier generation method includes the following steps:
[0074] Step 401, obtaining a training sample set.
[0075] Step 402, generating a logistic regression decision tree according to the iterative logistic regression classification of the training sample set.
[0076] In some embodiments, the specific implementation manner of steps 401-402 and the technical effects brought by the specific implementation manner can be referred to Figure 3 The steps 301-302 in the corresponding embodiments will not be described here again.
[0077] Step 403, encoding the values in the initial feature vector of the training sample according to the classification of the training sample by each split node in the logistic regression decision tree to obtain an encoded feature vector.
[0078] In some embodiments, the execution subject of the above logistic regression classifier generation method (such as the logistic regression classifier generation method itself, a computer system, etc.) can be referred to Figure 1The computing device 101) can encode the values in the initial feature vector of the training sample according to the classification of the training sample by each split node in the logistic regression decision tree described above, to obtain an encoded feature vector. The dimension of the initial feature vector can be determined according to the number of split nodes in the logistic regression decision tree. Each dimension of the initial feature vector corresponds to a split node in the logistic regression decision tree.
[0079] The split nodes in the logistic regression decision tree can be sequentially numbered in order from top to bottom and from left to right according to their positions in the logistic regression decision tree. The starting number can be 1, and the split nodes can be sequentially numbered by increasing by 1 each time. Each split node can be associated with a dimension of the initial feature vector according to its number. For example, the split node numbered 2 corresponds to the second dimension of the initial feature vector. Each dimension of the initial feature vector can be pre-set to zero. The classification can be the classification result of the training sample by the split node. The classification result can be a "face image" or a "handwritten character image". The initial feature vector of each training sample in the training sample set can be encoded according to the values in the initial feature vector of each training sample by each split node in the logistic regression decision tree, to obtain a set of encoded feature vectors.
[0080] In some optional implementations of some embodiments, the execution subject can also change the value at the position corresponding to the split node in the initial feature vector to a value corresponding to the classification result of the training sample by the split node, according to the classification result of the training sample by the split node, in response to determining that the training sample passes through the split node. The value corresponding to the classification result can be pre-set.
[0081] As an example, when the classification result is "face image", the corresponding value can be 1. When the classification result is "handwritten character image", the corresponding value can be -1. The above encoded feature vector can be [-1,0,-1,0,0,0,1,0]. The above encoded feature vector is an 8-dimensional vector, which indicates that there are 8 split nodes in the above logistic regression decision tree. The numbers 0 in the 2nd, 4th to 6th, and 8th dimensions of the above encoded feature vector indicate that the above training sample did not pass the split nodes numbered 2, 4, 5, 6, and 8 in the above logistic regression decision tree. The numbers -1 in the 1st and 3rd dimensions of the above encoded feature vector indicate that the above training sample passed the split nodes numbered 1 and 3 in the above logistic regression decision tree, and the classification result of the above training sample by the split nodes numbered 1 and 3 is "handwritten character image". The fact that the 7th dimension of the above encoded feature vector is 1 indicates that the above training sample passed the 7th segment node in the above logistic regression decision tree, and the classification result of the 7th segment node for the above training sample is "face image".
[0082] Step 404: Train the initial logistic regression classifier using the encoded feature vector set to generate the target logistic regression classifier.
[0083] In some embodiments, the specific implementation of step 404 and its resulting technical effects can be found in [reference needed]. Figure 3 Step 304 in the corresponding embodiments will not be repeated here.
[0084] from Figure 4 It can be seen from this that, with Figure 3 Compared to the description of some corresponding embodiments, Figure 4 The flow 400 of the logistic regression classifier generation method in some corresponding embodiments illustrates the specific method of encoding sample data. As one of the inventive aspects of this disclosure, this sample data encoding method can reflect the segmentation nodes the sample data passes through in the logistic regression decision tree and the classification results of those segmentation nodes. This allows the encoded feature vector to reflect more information, further improving the accuracy of the classification results to a certain extent.
[0085] Further reference Figure 5 This illustrates a flowchart 500 of another embodiment of the image classification method. The flowchart 500 of the image classification method includes the following steps:
[0086] Step 501: Obtain the image to be classified.
[0087] In some embodiments, the entity executing the above image classification method (such as...) Figure 2The computing device 201 shown can obtain the image to be classified through a wired connection or a wireless connection. The image to be classified can be a face image or a handwritten character image.
[0088] At step 502, the image to be classified is encoded by using a logistic regression decision tree to generate an encoded feature vector.
[0089] In some embodiments, the image to be classified can be encoded by using a logistic regression decision tree to generate an encoded feature vector. The logistic regression decision tree can be a logistic regression decision tree with a decision tree structure. Figure 3 Or Figure 4 The encoded feature vector is generated by the method of some corresponding embodiments. The method of generating the encoded feature vector can refer to Figure 3 Step 303 in some corresponding embodiments or Figure 4 Step 403 in some corresponding embodiments, which will not be repeated here.
[0090] At step 503, the encoded feature vector is input into a target logistic regression classifier to obtain a classification result of the image to be classified.
[0091] In some embodiments, the encoded feature vector can be input into a target logistic regression classifier to obtain a classification result of the image to be classified. The target logistic regression classifier can be a logistic regression classifier with a decision tree structure. Figure 3 Or Figure 4 The method of some corresponding embodiments.
[0092] Some embodiments of the present disclosure provide a method of classifying an image to be classified by using a logistic regression decision tree and a target logistic regression classifier. The linear logistic regression classifier is used throughout the process, which can effectively avoid the problems of high computational complexity, introduction of too many hyperparameters, and inability to guarantee linear separability of projected data when using a logistic regression classifier with a kernel function to classify data, thereby reducing the computational cost of data classification.
[0093] Further reference is made to Figure 6 As an implementation of the method shown in the above figures, the present disclosure provides some embodiments of a logistic regression classifier generation device. These device embodiments correspond to the method embodiments shown in Figure 3 The device can be applied to various electronic devices.
[0094] As Figure 6As shown, the logic regression classifier generation apparatus 600 of some embodiments includes an obtaining unit 601, a generating unit 602, an encoding unit 603, and a training unit 604. The obtaining unit 601 is configured to obtain a training sample set, wherein each training sample in the training sample set includes a sample feature set and a category label, and each training sample in the training sample set is an image sample. The generating unit 602 is configured to generate a logic regression decision tree according to iterative logic regression classification on the training sample set, wherein the logic regression decision tree includes at least one split node, and each split node is a logic regression classifier. The encoding unit 603 is configured to encode each training sample in the training sample set based on the logic regression decision tree to generate an encoded feature vector, thereby obtaining an encoded feature vector set. The training unit 604 is configured to train an initial logic regression classifier using the encoded feature vector set to generate a target logic regression classifier.
[0095] In some optional implementations of some embodiments, the generating unit 602 of the logic regression classifier generation apparatus 600 can be further configured to perform the following processing steps on the training sample set: in response to determining that the training sample set does not satisfy a preset condition, performing logic regression classification on the training sample set to obtain two training sample subsets and a logic regression classifier; determining the logic regression classifier as a split node of a leaf node of an initial decision tree, wherein the split node is used to split the leaf node into two leaf nodes and divide the training sample set into the two training sample subsets; and in response to determining that the initial decision tree satisfies an iteration termination condition, determining the initial decision tree as a logic regression decision tree, wherein each split node in the logic regression decision tree has a unique identifier.
[0096] In some optional implementations of some embodiments, the generating unit 602 of the logic regression classifier generation apparatus 600 can be further configured to, in response to determining that the initial decision tree does not satisfy the iteration termination condition, continue to perform the above processing steps by respectively determining each of the two training sample subsets as a training sample set.
[0097] In some optional implementations of some embodiments, the encoding unit 603 of the logic regression classifier generation apparatus 600 can be further configured to encode a value in an initial feature vector of each training sample in the training sample set according to a classification of the training sample by each split node in the logic regression decision tree, thereby obtaining an encoded feature vector, wherein a dimension of the initial feature vector is determined according to a number of split nodes in the logic regression decision tree.
[0098] In some optional implementations of some embodiments, the encoding the numerical values in the initial feature vector according to the classification of the training sample by each split node in the logistic regression decision tree can include: in response to determining that the training sample passes through the split node, changing the numerical value at the position in the initial feature vector corresponding to the split node to a numerical value corresponding to the classification result of the training sample by the split node.
[0099] In some optional implementations of some embodiments, the image sample can be a face image sample or a handwritten character image sample, the sample feature set included in the image sample can include pixel values of each pixel in an image represented by the image sample, the category label included in the face image sample can be a first preset label, and the category label included in the handwritten character image sample can be a second preset label.
[0100] It can be understood that the units described in the apparatus 600 correspond to the respective steps in the method described with reference to Figure 3 . Thus, the operations, features, and advantages described above with respect to the method also apply to the apparatus 600 and the units included therein, and are not repeated here.
[0101] With further reference to Figure 7 , as an implementation of the methods shown in the above figures, the present disclosure provides some embodiments of an image classification apparatus, which correspond to the method embodiments shown in Figure 5 , and the apparatus can be specifically applied to various electronic devices.
[0102] As shown in Figure 7 , the image classification apparatus 700 of some embodiments includes an obtaining unit 701, an encoding unit 702, and an input unit 703. The obtaining unit 701 is configured to obtain an image to be classified. The encoding unit 702 is configured to encode the image to be classified using a logistic regression decision tree to generate an encoded feature vector. The input unit 703 is configured to input the encoded feature vector into a target logistic regression classifier to obtain a classification result of the image to be classified.
[0103] It can be understood that the units described in the apparatus 700 correspond to the respective steps in the method described with reference to Figure 5 . Thus, the operations, features, and advantages described above with respect to the method also apply to the apparatus 700 and the units included therein, and are not repeated here.
[0104] Reference is made below to Figure 8 , which shows a structural schematic diagram of an electronic device 800 suitable for implementing some embodiments of the present disclosure. Figure 8The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments of this disclosure.
[0105] like Figure 8 As shown, the electronic device 800 may include a processing device (e.g., a central processing unit, a graphics processor, etc.) 801, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 802 or a program loaded from a storage device 808 into a random access memory (RAM) 803. The RAM 803 also stores various programs and data required for the operation of the electronic device 800. The processing device 801, ROM 802, and RAM 803 are interconnected via a bus 804. An input / output (I / O) interface 805 is also connected to the bus 804.
[0106] Typically, the following devices can be connected to I / O interface 805: input devices 806 including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 807 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; and communication devices 809. Communication device 809 allows electronic device 800 to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 8 An electronic device 800 with various devices is shown; however, it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed alternatively. Figure 8 Each box shown can represent a device or multiple devices as needed.
[0107] In particular, according to some embodiments of this disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, some embodiments of this disclosure include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device 809, or installed from a storage device 808, or installed from a ROM 802. When the computer program is executed by the processing device 801, it performs the functions defined in the methods of some embodiments of this disclosure.
[0108] Note that the computer readable medium in some embodiments of the present disclosure can be a computer readable signal medium or a computer readable storage medium or any combination thereof. The computer readable storage medium can be, for example but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus or device, or any suitable combination of the foregoing. More specific examples of the computer readable storage medium can include, but are not limited to, an electrical connection having one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In some embodiments of the present disclosure, the computer readable storage medium can be any tangible medium that contains or stores a program used by or in connection with an instruction execution system, apparatus or device. In some embodiments of the present disclosure, the computer readable signal medium can include a data signal propagated in baseband or propagated as a carrier wave in a propagated data signal, in which the computer readable program code is contained. Such propagated data signal can take a variety of forms, including but not limited to electro-magnetic, optical or any suitable combination thereof. The computer readable signal medium can also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate or transport program for use by or in connection with an instruction execution system, apparatus or device. Program code contained in the computer readable medium can be transmitted by any suitable medium, including but not limited to wire, cable, RF (radio frequency), etc., or any suitable combination of the foregoing.
[0109] In some embodiments, the client, server, or both can communicate using any current known or future developed network protocol, such as HTTP (HyperText Transfer Protocol), and can be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include local area networks ("LAN"), wide area networks ("WAN"), the Internet, and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any current known or future developed networks.
[0110] The computer readable medium can be included in the electronic device; or can exist outside of the electronic device, and can be accessed via the electronic device. The computer readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to: obtain a training sample set, wherein a training sample in the training sample set comprises a sample feature set and a category label, and the training sample in the training sample set is an image sample; generate a logistic regression decision tree according to iterative logistic regression classification on the training sample set, wherein the logistic regression decision tree comprises at least one split node, and the split node is a logistic regression classifier; encode each training sample in the training sample set based on the logistic regression decision tree to generate an encoded feature vector, to obtain an encoded feature vector set; and train an initial logistic regression classifier using the encoded feature vector set to generate a target logistic regression classifier.
[0111] Computer program code for carrying out operations of some embodiments of the disclosure can be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C++ or the like, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code can execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the latter scenario, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or the connection can be made to an external computer (for example, through the Internet using an Internet Service Provider).
[0112] The flow diagrams and the block diagrams in the drawings are illustrations of architectures, functionalities, and operations of possible implementations of systems, methods, and computer program products according to various embodiments of present disclosure. In this regard, each block in the flow diagrams or block diagrams can represent a module, a segment, or a portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that in some alternative implementations, the functions noted in the block can occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently or the blocks may
[0113] The units described in some embodiments of the present disclosure can be implemented in the form of software, or can be implemented in the form of hardware. The described units can also be arranged in a processor, for example, can be described as: a processor includes an acquisition unit, a generation unit, an encoding unit and a training unit. Among them, the name of these units does not constitute a limitation to the unit itself in some cases, for example, the acquisition unit can also be described as "a unit for acquiring a training sample set".
[0114] The functions described above herein can be executed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that can be used include: field programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), system-on-chips (SOCs), complex programmable logic devices (CPLDs), and so forth.
Claims
1. A method for generating a logistic regression classifier, comprising: Obtain a training sample set, wherein the training samples in the training sample set include a sample feature set and a category label, and the training samples in the training sample set are image samples; Based on the iterative logistic regression classification of the training sample set, a logistic regression decision tree is generated, wherein the logistic regression decision tree includes at least one splitting node, and the splitting node is a logistic regression classifier; Based on the logistic regression decision tree, each training sample in the training sample set is encoded to generate an encoded feature vector, resulting in an encoded feature vector set, such that the encoded training samples are linearly separable. This includes: encoding the values in the initial feature vector of the training sample according to the classification of the training sample by each split node in the logistic regression decision tree, to obtain an encoded feature vector, wherein the dimension of the initial feature vector is determined according to the number of split nodes in the logistic regression decision tree. The initial logistic regression classifier is trained using the encoded feature vector set to generate the target logistic regression classifier; The step of generating a logistic regression decision tree based on iterative logistic regression classification of the training sample set includes: For the training sample set, the following processing steps are performed: In response to determining that the training sample set does not meet the preset conditions, logistic regression classification is performed on the training sample set to obtain two training sample subsets and a logistic regression classifier; The logistic regression classifier is determined as the splitting node of the leaf node of the initial decision tree, wherein the splitting node is used to split the leaf node into two leaf nodes and to divide the training sample set into two training sample subsets. In response to determining that the initial decision tree satisfies the iteration termination condition, the initial decision tree is determined as a logistic regression decision tree, wherein each split node in the logistic regression decision tree has a unique identifier.
2. The method according to claim 1, wherein, The step of generating a logistic regression decision tree based on iterative logistic regression classification of the training sample set further includes: In response to the determination that the initial decision tree does not meet the iteration termination condition, each of the two training sample subsets is determined as a training sample set, and the processing steps are continued.
3. The method according to claim 2, wherein, The step of encoding the values in the initial feature vector of the training samples based on the classification of the training samples by each split node in the logistic regression decision tree includes: In response to determining that the training sample passes through the segmentation node, the value at the position corresponding to the segmentation node in the initial feature vector is changed to the value corresponding to the classification result, based on the classification result of the segmentation node on the training sample.
4. The method according to claim 1, wherein, The image sample is a face image sample or a handwritten character image sample. The sample feature set included in the image sample includes the pixel values of each pixel in the image represented by the image sample. The category label included in the face image sample is a first preset label, and the category label included in the handwritten character image sample is a second preset label.
5. An image classification method, comprising: Obtain the image to be classified; The image to be classified is encoded using a logistic regression decision tree to generate an encoded feature vector, wherein the logistic regression decision tree is generated using the method described in any one of claims 1-4; The encoded feature vector is input into the target logistic regression classifier to obtain the classification result of the image to be classified, wherein the target logistic regression classifier is generated using the method described in any one of claims 1-4.
6. A logistic regression classifier generation device, comprising: The acquisition unit is configured to acquire a training sample set, wherein the training samples in the training sample set include a sample feature set and a category label, and the training samples in the training sample set are image samples. The generation unit is configured to generate a logistic regression decision tree based on iterative logistic regression classification of the training sample set, wherein the logistic regression decision tree includes at least one splitting node, the splitting node being a logistic regression classifier; An encoding unit is configured to encode each training sample in the training sample set based on the logistic regression decision tree to generate an encoded feature vector, thereby obtaining an encoded feature vector set. This includes: encoding the values in the initial feature vector of the training sample according to the classification of the training sample by each split node in the logistic regression decision tree to obtain an encoded feature vector, wherein the dimension of the initial feature vector is determined according to the number of split nodes in the logistic regression decision tree. The training unit is configured to train an initial logistic regression classifier using the encoded feature vector set to generate a target logistic regression classifier; The step of generating a logistic regression decision tree based on iterative logistic regression classification of the training sample set includes: For the training sample set, the following processing steps are performed: In response to determining that the training sample set does not meet the preset conditions, logistic regression classification is performed on the training sample set to obtain two training sample subsets and a logistic regression classifier; The logistic regression classifier is determined as the splitting node of the leaf node of the initial decision tree, wherein the splitting node is used to split the leaf node into two leaf nodes and to divide the training sample set into two training sample subsets. In response to determining that the initial decision tree satisfies the iteration termination condition, the initial decision tree is determined as a logistic regression decision tree, wherein each split node in the logistic regression decision tree has a unique identifier.
7. An image classification device, comprising: The acquisition unit is configured to acquire the image to be classified. The encoding unit is configured to encode the image to be classified using a logistic regression decision tree to generate an encoded feature vector, wherein the logistic regression decision tree is generated using the method described in any one of claims 1-4. An input unit is configured to input the encoded feature vector into a target logistic regression classifier to obtain a classification result for the image to be classified, wherein the target logistic regression classifier is generated using the method described in any one of claims 1-4.
8. An electronic device, comprising: One or more processors; Storage device, on which one or more programs are stored, When the one or more programs are executed by the one or more processors, the one or more processors implement the method as described in any one of claims 1-4.
9. A computer-readable medium having a computer program stored thereon, wherein, When the program is executed by the processor, it implements the method as described in any one of claims 1-4.
Citation Information
Patent Citations
Decision tree and logistic regression-based click rate pre-estimation method
CN108182597A
Interpretable graph neural network prediction method, system and device
CN112016620A
Unmanned vehicle positioning method and device based on multi-feature mapping and computer equipment
CN112016640A