Block chain address classification method and device, equipment and storage medium
By filtering positive, negative and unlabeled samples of blockchain addresses, the semi-supervised learning method combined with unsupervised and supervised models solves the problem of accuracy and inefficiency of blockchain address classification, and achieves the latest results. Efficient blockchain address classification.
Patent Information
- Application Number
- CN202310674686.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-06
- Publication Date
- 2024-12-06
AI Technical Summary
The strong encryption of blockchain addresses and very few features make it difficult for traditional statistical methods and machine learning methods to achieve accurate classification, and rely on manual tags inefficiently.
By obtaining positive samples, negative samples and unlabeled samples, unsupervised and supervised classification models are used to screen candidate negative samples, and the supervised classification model is trained in combination with semi-supervised learning methods to improve the classification accuracy of blockchain addresses.
It improves the accuracy and efficiency of blockchain address classification, avoids inefficiency problems caused by the addition of manual tags, and enhances the accuracy of model training.
Smart Images

Figure CN119089255A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a blockchain address classification method, device, equipment and storage medium. Background Art
[0002] The transactions of digital currencies in blockchain technology are usually completed based on blockchain addresses. By classifying blockchain addresses, illegal transactions on the blockchain can be identified, thereby better safeguarding the rights and interests of users.
[0003] However, blockchain addresses are hash values after encryption calculation, and there are few features that can be directly extracted. Therefore, when using traditional statistical methods or machine learning methods to classify blockchain addresses, it is often difficult to obtain good training results. For example, when using traditional statistical methods to establish panel data models, due to the small number of statistical features related to blockchain addresses, it is difficult to obtain good modeling results, and the accuracy of blockchain address classification is low. When using machine learning methods such as support vector machines, logistic regression, and gradient boosting algorithms, it is necessary to rely on manual labeling of a large number of blockchain addresses on the blockchain, which is inefficient. Summary of the invention
[0004] The present application provides a blockchain address classification method, apparatus, device and storage medium to at least improve the training effect of a model for classifying blockchain addresses, thereby improving the accuracy of blockchain address classification. The technical solution of the present application is as follows:
[0005] According to a first aspect of an embodiment of the present application, a blockchain address classification method is provided, comprising: obtaining a training set; the training set comprises a plurality of positive samples, a plurality of first negative samples and a plurality of unlabeled samples; the positive samples are used to characterize the transaction behavior characteristics of a trusted blockchain address; the first negative samples are used to characterize the transaction behavior characteristics of an untrusted blockchain address; the unlabeled samples are used to characterize the transaction behavior characteristics of an unclassified blockchain address; the plurality of unlabeled samples are respectively input into an unsupervised classification model and a supervised classification model to obtain a first candidate negative sample set corresponding to the unsupervised classification model and a second candidate negative sample set corresponding to the supervised classification model, and an intersection of the first candidate negative sample set and the second candidate negative sample set is determined as a second negative sample; based on the plurality of positive samples, the plurality of first negative samples, the second negative samples and the plurality of unlabeled samples, the supervised classification model is trained to obtain a target supervised classification model; the target supervised classification model is used to classify the blockchain addresses to be classified.
[0006] In an optional implementation, before obtaining the training set, the blockchain address classification method also includes: determining a ratio between the number of multiple first negative samples and the number of multiple positive samples; when the ratio is less than or equal to a preset ratio threshold, downsampling the multiple positive samples according to the ratio, and inputting the downsampled positive samples and the multiple first negative samples into an initial supervised classification model for training to obtain a supervised classification model; when the ratio is greater than the preset ratio threshold, inputting the multiple positive samples and the multiple first negative samples into the initial supervised classification model for training to obtain a supervised classification model.
[0007] In an optional implementation, a method for training a supervised classification model based on multiple positive samples, multiple first negative samples, second negative samples and multiple unlabeled samples to obtain a target supervised classification model specifically includes: training the supervised classification model based on multiple positive samples, multiple first negative samples and second negative samples to obtain a first supervised classification model; inputting the first unlabeled sample into the first supervised classification model for classification processing to obtain a classification result corresponding to the first unlabeled sample; the first unlabeled sample is used to characterize the unlabeled samples other than the second negative samples in the multiple unlabeled samples; when there is no third candidate negative sample set including at least one third candidate negative sample, the first supervised classification model is determined as the target supervised classification model; the third candidate negative sample is used to characterize the classification result as an untrusted first unlabeled sample; when there is a third candidate negative sample set, the intersection of the second candidate negative sample set and the third candidate negative sample set is determined as the third negative sample, and the first supervised classification model is trained based on the multiple positive samples, the multiple first negative samples, the second negative samples, the third negative samples and the first unlabeled sample to obtain the target supervised classification model.
[0008] In an optional implementation, the process of determining a first candidate negative sample set corresponding to an unsupervised classification model includes: inputting multiple unlabeled samples into the unsupervised classification model for classification processing, and obtaining multiple outliers corresponding one-to-one to the multiple unlabeled samples; determining the unlabeled samples whose outliers are greater than a preset outlier threshold as first candidate negative samples, and obtaining a first candidate negative sample set including at least one first candidate negative sample.
[0009] In an optional implementation, the blockchain address classification method also includes: obtaining multiple transaction information corresponding to multiple blockchain addresses one by one; the multiple blockchain addresses include multiple blockchain addresses carrying trusted labels, multiple blockchain addresses carrying untrusted labels, and multiple blockchain addresses without labels; performing feature engineering processing on the multiple transaction information to obtain multiple feature data corresponding to the multiple transaction information one by one; the feature engineering processing includes normalization processing and dummy variable processing; dividing the multiple feature data into k sub-training sets and test sets; the test set is used to test the classification accuracy of the target supervised classification model; k is a positive integer; each sub-training set is determined as a validation set, and the sub-training sets other than the validation set in the k sub-training sets are determined as training sets, so as to obtain k validation sets and k training sets with corresponding relationships.
[0010] In an optional implementation, the blockchain address classification method further includes: based on k training sets, respectively training k target supervised classification models; based on k validation sets, respectively determining the classification accuracy of the k target supervised classification models.
[0011] In an optional implementation, the blockchain address classification method also includes: obtaining transaction information of the blockchain address to be classified; performing feature engineering processing on the transaction information to obtain feature data corresponding to the transaction information; inputting the feature data into the target supervised classification model for classification processing to obtain the classification result of the blockchain address to be classified.
[0012] According to a second aspect of an embodiment of the present application, a blockchain address classification device is provided, including: an acquisition unit and a processing unit;
[0013] The acquisition unit is configured to execute acquisition of a training set; the training set includes a plurality of positive samples, a plurality of first negative samples, and a plurality of unlabeled samples; the positive samples are used to characterize the transaction behavior characteristics of a trusted blockchain address; the first negative samples are used to characterize the transaction behavior characteristics of an untrusted blockchain address; and the unlabeled samples are used to characterize the transaction behavior characteristics of an unclassified blockchain address;
[0014] A processing unit is configured to input a plurality of unlabeled samples into an unsupervised classification model and a supervised classification model respectively, obtain a first candidate negative sample set corresponding to the unsupervised classification model and a second candidate negative sample set corresponding to the supervised classification model, and determine an intersection of the first candidate negative sample set and the second candidate negative sample set as a second negative sample;
[0015] The processing unit is also configured to perform training on a supervised classification model based on multiple positive samples, multiple first negative samples, second negative samples, and multiple unlabeled samples to obtain a target supervised classification model; the target supervised classification model is used to classify the blockchain addresses to be classified.
[0016] In an optional implementation, the processing unit is further configured to execute:
[0017] Determine a ratio between the number of the plurality of first negative samples and the number of the plurality of positive samples;
[0018] When the ratio value is less than or equal to a preset ratio threshold, down-sampling the multiple positive samples according to the ratio value, and inputting the down-sampled positive samples and the multiple first negative samples into the initial supervised classification model for training to obtain a supervised classification model;
[0019] When the ratio value is greater than a preset ratio threshold, the plurality of positive samples and the plurality of first negative samples are input into the initial supervised classification model for training to obtain a supervised classification model.
[0020] In an optional implementation, the processing unit is specifically configured to execute:
[0021] Based on the multiple positive samples, the multiple first negative samples and the second negative samples, the supervised classification model is trained to obtain a first supervised classification model;
[0022] Inputting the first unlabeled sample into the first supervised classification model for classification processing to obtain a classification result corresponding to the first unlabeled sample; the first unlabeled sample is used to represent the unlabeled samples other than the second negative sample in the plurality of unlabeled samples;
[0023] When there is no third candidate negative sample set including at least one third candidate negative sample, determining the first supervised classification model as the target supervised classification model; the third candidate negative sample is used to characterize that the classification result is an untrusted first unlabeled sample;
[0024] When there is a third candidate negative sample set, the intersection of the second candidate negative sample set and the third candidate negative sample set is determined as the third negative sample, and the first supervised classification model is trained based on multiple positive samples, multiple first negative samples, the second negative samples, the third negative samples and the first unlabeled samples to obtain a target supervised classification model.
[0025] In an optional implementation, the processing unit is specifically configured to execute:
[0026] Inputting multiple unlabeled samples into an unsupervised classification model for classification processing, and obtaining multiple outliers corresponding to the multiple unlabeled samples one by one;
[0027] An unlabeled sample whose outlier value is greater than a preset outlier threshold is determined as a first candidate negative sample, and a first candidate negative sample set including at least one first candidate negative sample is obtained.
[0028] In an optional implementation, the acquisition unit is further configured to execute acquisition of multiple transaction information corresponding to multiple blockchain addresses one by one; the multiple blockchain addresses include multiple blockchain addresses carrying trusted labels, multiple blockchain addresses carrying untrusted labels, and multiple blockchain addresses without labels;
[0029] The processing unit is further configured to perform feature engineering processing on the plurality of transaction information to obtain a plurality of feature data corresponding to the plurality of transaction information one by one; the feature engineering processing includes normalization processing and dummy variable processing;
[0030] The processing unit is further configured to execute dividing the plurality of feature data into k sub-training sets and a test set; the test set is used to test the classification accuracy of the target supervised classification model; k is a positive integer;
[0031] The processing unit is further configured to respectively determine each sub-training set as a validation set, and determine the sub-training sets other than the validation set among the k sub-training sets as training sets, so as to obtain k validation sets and k training sets having a corresponding relationship.
[0032] In an optional implementation, the processing unit is further configured to execute training based on k training sets to obtain k target supervised classification models respectively; the processing unit is further configured to execute determination of the classification accuracy of the k target supervised classification models respectively based on k validation sets.
[0033] In an optional implementation, the acquisition unit is further configured to execute acquisition of transaction information of the blockchain address to be classified; the processing unit is further configured to perform feature engineering processing on the transaction information to obtain feature data corresponding to the transaction information; the processing unit is further configured to input the feature data into the target supervised classification model for classification processing to obtain the classification result of the blockchain address to be classified.
[0034] According to a third aspect of an embodiment of the present application, an electronic device is provided, comprising: a processor; a memory for storing processor-executable instructions; wherein the processor is configured to execute instructions to implement any optional blockchain address classification method as in the first aspect.
[0035] According to a fourth aspect of an embodiment of the present application, a computer-readable storage medium is provided, on which instructions are stored. When the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute any optional blockchain address classification method as described in the first aspect.
[0036] According to a fifth aspect of an embodiment of the present application, a computer program product is provided, including a computer program, which, when executed by an electronic device, implements any optional blockchain address classification method in the first aspect.
[0037] The technical solution of the first aspect provided by the embodiments of the present application brings at least the following beneficial effects: after obtaining a training set including multiple positive samples, multiple first negative samples and multiple unlabeled samples, the multiple unlabeled samples can be respectively input into the unsupervised classification model and the supervised classification model to obtain a first candidate negative sample set corresponding to the unsupervised classification model and a second candidate negative sample set corresponding to the supervised classification model, and the intersection of the first candidate negative sample set and the second candidate negative sample set is determined as the second negative sample, so as to further train the supervised classification model based on the multiple positive samples, the multiple first negative samples, the second negative samples and the multiple unlabeled samples to obtain a target supervised classification model for classifying the blockchain addresses to be classified.
[0038] Based on this, the present application can use a semi-supervised learning method to train a supervised classification model by combining labeled samples and unlabeled samples, avoiding the low efficiency problem caused by the traditional method of relying on manual labeling of a large number of samples, and can improve the efficiency of the model training process.
[0039] Furthermore, since the second negative sample is an unlabeled sample whose classification result based on the unsupervised classification model is untrusted and whose classification result based on the supervised classification model is untrusted. That is, when the second negative sample is screened from the unlabeled sample, it is achieved by secondary calibration of the unsupervised classification model and the supervised classification model, and has high accuracy. Therefore, when the present application further uses the second negative sample to train the model, it can avoid the problem of reduced model accuracy caused by incorrect sample labeling. Therefore, the present application can improve the training effect of the model for classifying blockchain addresses, thereby improving the accuracy of blockchain address classification.
[0040] It should be noted that the technical effects brought about by any implementation method in the second to fifth aspects can refer to the technical effects brought about by the corresponding implementation method in the first aspect, and will not be repeated here.
[0041] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] The drawings herein are incorporated into the specification and constitute a part of the specification, illustrate embodiments consistent with the present application, and together with the specification are used to explain the principles of the present application, and do not constitute an improper limitation on the present application.
[0043] Figure 1 It is a schematic diagram of an implementation architecture shown in an embodiment of the present application;
[0044] Figure 2It is a flowchart of a blockchain address classification method shown in an embodiment of the present application;
[0045] Figure 3 It is a schematic diagram of a blockchain address classification process shown in an embodiment of the present application;
[0046] Figure 4 It is a block diagram of a blockchain address classification device shown in an embodiment of the present application;
[0047] Figure 5 It is a block diagram of an electronic device shown in an embodiment of the present application. DETAILED DESCRIPTION
[0048] In order to enable ordinary persons in the art to better understand the technical solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying drawings.
[0049] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. On the contrary, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the attached claims.
[0050] Before introducing in detail the blockchain address classification method provided by this application, a brief introduction to the application scenarios and implementation environment involved in this application is first given.
[0051] With the continuous deepening of scientific and technological revolution and industrial transformation, the international industrial structure is being reshaped at an accelerated pace, the digital economy is constantly developing, and information technology has become the field with the largest R&D investment and the widest application. Blockchain technology has become an increasingly important part due to its decentralized technology, distributed data storage, peer-to-peer transmission, consensus mechanism and encryption algorithm. The transaction of digital currency in blockchain technology is usually completed based on blockchain addresses. In order to better protect the rights and interests of users, it is necessary to classify blockchain addresses to identify illegal transactions on the blockchain.
[0052] However, blockchain addresses are hash values after encryption calculation, and there are few features that can be directly extracted. Therefore, when using traditional statistical methods or machine learning methods to classify blockchain addresses, it is often difficult to obtain good training results.
[0053] For example, when using traditional statistical methods to establish a panel data model, it is difficult to obtain a good modeling effect due to the small number of statistical features related to blockchain addresses, and the accuracy of classifying blockchain addresses is low.
[0054] When using machine learning methods such as support vector machines, logistic regression and gradient boosting algorithms, it is necessary to manually add labels to a large number of blockchain addresses on the blockchain, which is inefficient. During the training process, a large amount of storage resources and computing resources are often consumed, which can easily lead to training failures due to insufficient resources.
[0055] When using semi-supervised learning algorithms such as positive-unlabeled learning (PU Learning) and semi-supervised support vector machines, the model training process can be completed by using a large amount of unlabeled data and a small amount of labeled data. However, semi-supervised learning algorithms generally use supervised learning algorithms as basic classifiers, and supervised learning algorithms rely on learning from historical data. When there is less labeled data and insufficient diversity, the accuracy of the parameters learned from historical data is not guaranteed. And if the samples input into the basic classifier carry incorrect labels, the accuracy of the classification results will also be reduced.
[0056] It can be seen that it is difficult for general technology to accurately classify blockchain addresses in order to better protect user rights.
[0057] In response to the above problems, the present application provides a blockchain address classification method. After obtaining a training set including multiple positive samples, multiple first negative samples and multiple unlabeled samples, the multiple unlabeled samples can be respectively input into an unsupervised classification model and a supervised classification model to obtain a first candidate negative sample set corresponding to the unsupervised classification model and a second candidate negative sample set corresponding to the supervised classification model, and the intersection of the first candidate negative sample set and the second candidate negative sample set is determined as the second negative sample, so as to further train the supervised classification model based on the multiple positive samples, the multiple first negative samples, the second negative samples and the multiple unlabeled samples to obtain a target supervised classification model for classifying the blockchain addresses to be classified.
[0058] Based on this, the present application can use a semi-supervised learning method to train a supervised classification model by combining labeled samples and unlabeled samples, avoiding the low efficiency problem caused by the traditional method of relying on manual labeling of a large number of samples, and can improve the efficiency of the model training process.
[0059] Furthermore, since the second negative sample is an unlabeled sample whose classification result based on the unsupervised classification model is untrusted and whose classification result based on the supervised classification model is untrusted. That is, when the second negative sample is screened from the unlabeled sample, it is achieved by secondary calibration of the unsupervised classification model and the supervised classification model, and has high accuracy. Therefore, when the present application further uses the second negative sample to train the model, it can avoid the problem of reduced model accuracy caused by incorrect sample labeling. Therefore, the present application can improve the training effect of the model for classifying blockchain addresses, thereby improving the accuracy of blockchain address classification.
[0060] Figure 1 This is the implementation architecture diagram of this application. Figure 1 As shown, the blockchain address classification system 100 provided in the embodiment of the present application may include an electronic device 101 and multiple blockchain nodes 102. The electronic device 101 may be communicatively connected to any blockchain node 102. Multiple blockchain nodes 102 may form a blockchain system, and different blockchain nodes 102 may be communicatively connected to each other.
[0061] For ease of understanding, this application takes the communication connection between an electronic device 101 and a blockchain node 102 as an example for explanation.
[0062] In one possible way, Figure 1 The electronic device 101 can support the configuration of unsupervised classification models and supervised classification models, etc., to provide services such as model training and blockchain address classification.
[0063] Optional, Figure 1 The electronic device 101 and the blockchain node 102 may be functional modules integrated into the same device, or may be two independently configured devices. This embodiment of the present application does not limit this.
[0064] It is easy to understand that when the electronic device 101 and the blockchain node 102 are functional modules integrated into the same device, the communication between the electronic device 101 and the blockchain node 102 is the communication between the modules inside the device. In this case, the communication process between the two is the same as "the communication process between the electronic device 101 and the blockchain node 102 when they are independently set up".
[0065] For ease of understanding, this application is mainly explained by taking the electronic device 101 and the blockchain node 102 as an example in which they are independently configured.
[0066] Optionally, the electronic device 101 may be an independent device outside the blockchain system composed of multiple blockchain nodes 102. Alternatively, the electronic device 101 may also be a blockchain node, and may form a blockchain system together with multiple blockchain nodes 102.
[0067] Optionally, Figure 1 The electronic device 101 may be a terminal, a server, or other devices that support functions such as model processing and blockchain address classification. Figure 1 The figure is merely an example of the device form of the electronic device 101 and does not constitute a limitation thereto.
[0068] In one possible way, Figure 1 The multiple blockchain nodes 102 in the blockchain network can constitute a blockchain network, which can be used to provide data storage services and data query services for medical institutions and banking institutions. The blockchain network can be regarded as a peer-to-peer (P2P) network.
[0069] In one possible manner, multiple blockchain nodes 102 may store the same blockchain. A blockchain generally includes multiple blocks and is a chain structure that maintains blocks, which can maintain a continuously growing, shareable, and tamper-proof data record. The blockchain may store historical transaction information of multiple blockchain addresses. For example, the blockchain may include: Figure 1 Multiple blocks are shown, including initial block 0, block 1, block 2, and block 3.
[0070] Optionally, the blockchain can be a private chain, a consortium chain, or a public chain. A private chain refers to a blockchain with strict access control. A consortium chain can also be called a community blockchain, which refers to a blockchain whose consensus process is controlled by pre-selected nodes. In a consortium chain, all or part of the functions are open only to the nodes that store the consortium chain, and each node in the consortium chain can customize read and write permissions, query permissions, etc. based on needs. A public chain refers to a blockchain in which any individual or group in the world can send transactions and participate in the consensus process.
[0071] Optionally, Figure 1 The blockchain node 102 may be a terminal, a server, or other equipment that supports functions such as blockchain maintenance. Figure 1 The above is only an example of the device form of the blockchain node 102 and does not constitute a limitation thereto.
[0072] Optionally, when the electronic device 101 and the blockchain node 102 are terminals, the terminal may be a mobile phone, tablet computer, desktop, laptop, handheld computer, notebook computer, ultra-mobile personal computer (UMPC), netbook, and personal digital assistant (PDA) and other devices. In addition, the terminal may also interact with the user through one or more methods such as keyboard, touchpad, touch screen, remote control, voice interaction or handwriting device. This application does not impose any special restrictions on the specific form of the terminal.
[0073] When the electronic device 101 and the blockchain node 102 are servers, the server may be a single server, or a server cluster consisting of multiple servers. In some implementations, the server cluster may also be a distributed cluster. This application does not limit the specific implementation of the server.
[0074] For ease of understanding, the blockchain address classification method provided by this application is specifically introduced below with reference to the accompanying drawings.
[0075] Figure 2 is a flowchart of a blockchain address classification method according to an exemplary embodiment. The blockchain address classification method is applied to Figure 1 The electronic device 101 in FIG. Figure 2 As shown, the blockchain address classification method includes: S201-S203.
[0076] S201. The electronic device obtains a training set.
[0077] The training set may include multiple positive samples, multiple first negative samples, and multiple unlabeled samples. The positive samples may be used to characterize the transaction behavior characteristics of a trusted blockchain address. The first negative samples may be used to characterize the transaction behavior characteristics of an untrusted blockchain address. The unlabeled samples may be used to characterize the transaction behavior characteristics of an unclassified blockchain address.
[0078] In one possible way, the blockchain address can be a string of multiple letters and / or numbers, which is used to support digital currency transactions on the blockchain. That is, the blockchain address can be a transaction address on the blockchain, and can also be called a wallet address.
[0079] Furthermore, a trusted blockchain address may be a blockchain address that complies with specific transaction rules and has not conducted any illegal transactions. An untrusted blockchain address may be a blockchain address that does not comply with specific transaction rules and has conducted any illegal transactions. Illegal transactions may be digital currency transactions used to support black and gray industries.
[0080] In one possible approach, the positive sample, the first negative sample, and the unlabeled sample may be feature data extracted from historical transaction information of a blockchain address, for example, feature data of multiple dimensions such as cross-sections and time series extracted from historical transaction information of a blockchain address.
[0081] In one possible manner, the electronic device may be configured with a storage module and input modules such as a keyboard and a mouse. The storage module may store resource files such as training sets pre-configured by the staff. Based on this, the staff may perform a training start operation through the input module configured by the electronic device. For example, click a training start button, etc. In response to the training start operation, the electronic device may read the training set stored in the storage module.
[0082] S202. The electronic device inputs multiple unlabeled samples into an unsupervised classification model and a supervised classification model respectively, obtains a first candidate negative sample set corresponding to the unsupervised classification model and a second candidate negative sample set corresponding to the supervised classification model, and determines the intersection of the first candidate negative sample set and the second candidate negative sample set as the second negative sample.
[0083] In a possible manner, the first candidate negative sample set may include at least one first candidate negative sample. The first candidate negative sample may be used to characterize that a classification result obtained based on an unsupervised classification model is an untrusted unlabeled sample.
[0084] In a possible manner, the second candidate negative sample set may include at least one second candidate negative sample. The second candidate negative sample may be used to characterize that the classification result obtained based on the supervised classification model is an untrusted unlabeled sample.
[0085] In one possible manner, the second negative sample can be used to characterize an unlabeled sample whose classification result obtained based on an unsupervised classification model is untrustworthy and whose classification result obtained based on a supervised classification model is untrustworthy. The number of the second negative samples can be one or more.
[0086] In one possible approach, the unsupervised classification model may be configured with pre-trained parameters that may be used to determine outliers in input data (e.g., positive samples, first negative samples, and unlabeled samples, etc.). For example, the unsupervised classification model may be an isolation forest model, or an angle-based outlier detection (ABOD) model, etc.
[0087] In one possible approach, the supervised classification model may be configured with pre-trained parameters, which may be used to predict the classification results of input data (e.g., positive samples, first negative samples, and unlabeled samples, etc.). The supervised classification model may be trained based on the initial supervised classification model and multiple positive samples and multiple first negative samples in the training set. For example, the initial supervised classification model may be an extreme gradient boosting (XGBoost) model or a light gradient boosting machine (LightGBM) model.
[0088] It should be noted that in order to accurately identify the characteristic data of untrusted blockchain addresses from multiple unlabeled samples, improve the training effect of the supervised classification model, and improve the classification accuracy of the supervised classification model, it is considered to use the unsupervised classification model and the supervised classification model for secondary calibration.
[0089] In one possible manner, the electronic device can classify multiple unlabeled samples based on an unsupervised classification model and a supervised classification model, respectively, and determine the unlabeled samples whose classification results based on the unsupervised classification model are untrusted and whose classification results based on the supervised classification model are untrusted as second negative samples. The specific implementation methods of this process include but are not limited to the following two methods.
[0090] The first method: the electronic device can input multiple unlabeled samples into an unsupervised classification model for classification processing, obtain multiple outliers corresponding to the multiple unlabeled samples, and determine the unlabeled samples whose outliers are greater than a preset outlier threshold as first candidate negative samples, and obtain a first candidate negative sample set including at least one first candidate negative sample. The preset outlier threshold can be pre-set in the electronic device by the staff.
[0091] The electronic device can classify multiple unlabeled samples based on a supervised classification model, and determine the unlabeled samples with untrusted classification results as second candidate negative samples, to obtain a second candidate negative sample set including at least one second candidate negative sample.
[0092] Further, the electronic device may determine the intersection of the first candidate negative sample set and the second candidate negative sample set as the second negative sample.
[0093] The second method: the electronic device can input multiple unlabeled samples into an unsupervised classification model for classification processing, obtain multiple outliers corresponding to the multiple unlabeled samples, and sort the multiple outliers in descending order to obtain an outlier sequence, so as to further determine the first preset number of unlabeled samples corresponding to the first first preset number of outliers in the outlier sequence as the first candidate negative samples, and obtain the first candidate negative sample set. The first preset number can be pre-set in the electronic device by the staff.
[0094] The electronic device can classify multiple unlabeled samples based on a supervised classification model, and determine the unlabeled samples with untrusted classification results as second candidate negative samples, to obtain a second candidate negative sample set including at least one second candidate negative sample.
[0095] Further, the electronic device may determine the intersection of the first candidate negative sample set and the second candidate negative sample set as the second negative sample.
[0096] S203: The electronic device trains a supervised classification model based on the multiple positive samples, the multiple first negative samples, the second negative samples, and the multiple unlabeled samples to obtain a target supervised classification model.
[0097] Among them, the target supervised classification model can be used to classify the blockchain addresses to be classified.
[0098] In one possible manner, the electronic device trains a supervised classification model based on multiple positive samples, multiple first negative samples, second negative samples, and multiple unlabeled samples to obtain a target supervised classification model.
[0099] In one possible manner, the electronic device can input multiple positive samples and multiple first negative samples in the training set, as well as second negative samples screened from multiple unlabeled samples, into the supervised classification model in batches for classification processing. After obtaining the classification results of each batch, the electronic device can determine the classification accuracy of each batch of classification results based on the labels (i.e., trusted and untrusted) carried by each positive sample, each first negative sample, and each second negative sample.
[0100] Based on this, after obtaining the classification results of each batch, the staff can refer to the classification accuracy of each batch of classification results and adjust the hyperparameters in the supervised classification model based on experience. After the electronic device completes the classification processing of each batch of sample data, it can obtain the target supervised classification model.
[0101] Based on the method described in S201-S203 above, the present application can use a semi-supervised learning method to train a supervised classification model by combining labeled samples and unlabeled samples, avoiding the low efficiency caused by relying on manual labeling of a large number of samples in the traditional method, and can improve the efficiency of the model training process. Furthermore, since the second negative sample is an unlabeled sample whose classification result obtained based on the unsupervised classification model is untrusted and whose classification result obtained based on the supervised classification model is untrusted. That is, when the second negative sample is screened from the unlabeled sample, it is achieved by secondary calibration of the unsupervised classification model and the supervised classification model, and has high accuracy. Therefore, when the present application further uses the second negative sample to train the model, it can avoid the problem of reduced model accuracy caused by incorrect sample labeling. Therefore, the present application can improve the training effect of the model for classifying blockchain addresses, thereby improving the accuracy of blockchain address classification.
[0102] In one embodiment, after the electronic device obtains the training set, the blockchain address classification method provided in the embodiment of the present application also includes: S301-S303.
[0103] S301: The electronic device determines a ratio between the number of a plurality of first negative samples and the number of a plurality of positive samples.
[0104] It should be noted that when using a model to classify blockchain addresses, the model is usually required to have a strong ability to identify untrusted blockchain addresses. However, in actual applications, trusted blockchain addresses are easy to collect and there are more of them, while untrusted blockchain addresses are not easy to collect and there are fewer of them, that is, the number of positive samples in the training set is generally large, while the number of first negative samples is small. In other words, there is generally a problem of large differences in the number of samples of different types and uneven distribution in the training set.
[0105] After the model is trained based on this training set, it generally tends to identify trusted blockchain addresses, that is, it has a strong ability to identify trusted blockchain addresses, but a weak ability to identify untrusted blockchain addresses. In this case, the training effect of the model is poor, and it is difficult to accurately classify blockchain addresses.
[0106] In one possible manner, in order to avoid the problem of poor model training effect caused by a large difference in number between the positive sample and the first negative sample, the electronic device can determine the number of multiple first negative samples and the number of multiple positive samples respectively, so as to further compare the number of multiple first negative samples with the number of multiple positive samples to obtain a ratio value between the number of multiple first negative samples and the number of multiple positive samples. Further, the electronic device can determine a comparison result between the ratio value and a preset ratio threshold value, so as to determine whether there is a large difference in number between the positive sample and the first negative sample.
[0107] The preset ratio threshold may be pre-set in the electronic device by the staff.
[0108] In a possible example, the number of the plurality of first negative samples is preset to be 80, and the number of the plurality of positive samples is preset to be 400, and the ratio value between the number of the plurality of first negative samples and the number of the plurality of positive samples is 0.2. If the preset ratio threshold is 0.8, the electronic device may obtain a comparison result that the ratio value is less than the preset ratio threshold. The comparison result may indicate that the number difference between the positive sample and the first negative sample is large.
[0109] S302. When the ratio value is less than or equal to a preset ratio threshold, the electronic device downsamples the multiple positive samples according to the ratio value, and inputs the downsampled positive samples and the multiple first negative samples into the initial supervised classification model for training to obtain a supervised classification model.
[0110] In one possible approach, the initial supervised classification model may be configured with pre-trained parameters, which may be used to predict classification results of input data (eg, positive samples, first negative samples, and unlabeled samples, etc.).
[0111] In one possible manner, when the ratio between the number of the first negative samples and the number of the positive samples is less than or equal to a preset ratio threshold, it can be indicated that the number difference between the first negative samples and the positive samples is large, and there is a problem of uneven distribution. In this case, the electronic device can determine the ratio as a sampling factor, or the product of the ratio and a preset coefficient as a sampling factor, etc. The preset coefficient can be preset by the staff.
[0112] Furthermore, the electronic device may downsample the multiple positive samples according to the sampling factor to obtain positive samples that are the same or similar in number to the multiple first negative samples. In this case, the number of positive samples obtained by downsampling is the same or similar in number to the multiple first negative samples, and there is no problem of uneven distribution between different types of samples. The electronic device may input the positive samples obtained by downsampling and the multiple first negative samples into the initial supervised classification model for training to obtain a supervised classification model.
[0113] S303: When the ratio value is greater than a preset ratio threshold, the electronic device inputs the plurality of positive samples and the plurality of first negative samples into an initial supervised classification model for training to obtain a supervised classification model.
[0114] In one possible way, when the ratio between the number of multiple first negative samples and the number of multiple positive samples is greater than a preset ratio threshold, it can be indicated that the difference in number between the first negative samples and the positive samples is small, and there is no problem of uneven distribution. Alternatively, the number of first negative samples is greater than the number of positive samples, which does not affect the ability of the trained model to identify untrusted blockchain addresses. In this case, the electronic device can input multiple positive samples and multiple first negative samples into the initial supervised classification model for training to obtain a supervised classification model.
[0115] In one possible manner, the electronic device may input multiple positive samples and multiple first negative samples in the training set into the initial supervised classification model in batches for classification processing. After obtaining the classification results of each batch, the electronic device may determine the classification accuracy of each batch of classification results based on the labels (i.e., trusted and untrusted) carried by each positive sample and each first negative sample.
[0116] Based on this, after obtaining the classification results of each batch, the staff can refer to the classification accuracy of each batch of classification results and adjust the hyperparameters in the initial supervised classification model based on experience. After the electronic device completes the classification processing of multiple positive samples and multiple first negative samples in the training set, a supervised classification model can be obtained.
[0117] In one embodiment, combining Figure 2 In the above S202, that is, when the electronic device determines the first candidate negative sample set corresponding to the unsupervised classification model, the embodiment of the present application provides an optional implementation method, including S401-S402.
[0118] S401: The electronic device inputs a plurality of unlabeled samples into an unsupervised classification model for classification processing, and obtains a plurality of outliers corresponding to the plurality of unlabeled samples one by one.
[0119] In one possible approach, the staff can configure pre-training parameters in the unsupervised classification model in advance. Based on this, the electronic device can input multiple unlabeled samples into the unsupervised classification model for classification processing. Specifically, the electronic device can use the tree structure of the unsupervised classification model to perform multiple segmentations on the multiple unlabeled samples, and separate the unlabeled samples after each segmentation.
[0120] During the whole process, unlabeled samples classified as untrusted are often separated from the majority of unlabeled samples after fewer segmentations. That is, unlabeled samples classified as untrusted are more likely to be segmented into separate leaf nodes. The unsupervised classification model can determine a large outlier for such unlabeled samples. Based on this, the electronic device can obtain multiple outliers corresponding to multiple unlabeled samples.
[0121] S402: The electronic device determines an unlabeled sample whose abnormal value is greater than a preset abnormal threshold as a first candidate negative sample, and obtains a first candidate negative sample set including at least one first candidate negative sample.
[0122] In one possible manner, the electronic device may compare the multiple abnormal values with the preset abnormal thresholds respectively. When an abnormal value is greater than the preset abnormal threshold, it may indicate that the unlabeled sample corresponding to the abnormal value is likely to be feature data of an untrusted blockchain address.
[0123] In this case, the electronic device may determine the unlabeled sample corresponding to the one outlier as the first candidate negative sample. Based on this, the electronic device may obtain a first candidate negative sample set including at least one first candidate negative sample.
[0124] In one embodiment, combining Figure 2 In the above S203, that is, the electronic device trains the supervised classification model based on multiple positive samples, multiple first negative samples, second negative samples and multiple unlabeled samples to obtain the target supervised classification model, the embodiment of the present application provides an optional implementation method, including S501-S504.
[0125] S501: The electronic device trains a supervised classification model based on multiple positive samples, multiple first negative samples, and second negative samples to obtain a first supervised classification model.
[0126] It should be understood that regarding the implementation of S501, reference may be made to the specific description in S303, which will not be repeated here.
[0127] S502: The electronic device inputs the first unlabeled sample into a first supervised classification model for classification processing to obtain a classification result corresponding to the first unlabeled sample.
[0128] The first unlabeled sample can be used to characterize the unlabeled samples other than the second negative sample among the multiple unlabeled samples.
[0129] It should be noted that in order to further improve the model's ability to identify untrusted blockchain addresses, it is necessary to collect more negative samples to train the model. Based on this, the electronic device can remove the second negative sample from the multiple unlabeled samples to obtain the first unlabeled sample, and further input the first unlabeled sample into the first supervised classification model for classification processing to obtain the classification result corresponding to the first unlabeled sample, thereby facilitating the screening of more negative samples.
[0130] S503: When there is no third candidate negative sample set including at least one third candidate negative sample, the electronic device determines the first supervised classification model as the target supervised classification model.
[0131] The third candidate negative sample can be used to characterize the classification result as an untrusted first unlabeled sample.
[0132] In one possible manner, when there is no third candidate negative sample set including at least one third candidate negative sample, that is, there is no first unlabeled sample whose classification result is untrusted, it can be indicated that no more negative samples can be collected to train the first supervised classification model. In this case, the electronic device can determine the first supervised classification model as the target supervised classification model.
[0133] S504. When there is a third candidate negative sample set, the electronic device determines the intersection of the second candidate negative sample set and the third candidate negative sample set as a third negative sample, and trains the first supervised classification model based on multiple positive samples, multiple first negative samples, the second negative samples, the third negative samples and the first unlabeled samples to obtain a target supervised classification model.
[0134] In one possible way, when there is a third candidate negative sample set including at least one third candidate negative sample, that is, when there is a first unlabeled sample whose classification result is untrusted, it can be indicated that more negative samples can be collected to train the first supervised classification model. In order to verify the correctness of the classification result of the third candidate negative sample, consider using a secondary calibration method based on the supervised classification model and the first supervised classification model. That is, the electronic device can determine the intersection of the second candidate negative sample set and the third candidate negative sample set as the third negative sample.
[0135] In this case, the third negative sample is an unlabeled sample whose classification result based on the supervised classification model is untrusted and whose classification result based on the first supervised classification model is untrusted, and its classification result has a high accuracy. Therefore, when the present application further uses the third negative sample to train the model, the problem of reduced model accuracy caused by incorrect sample labeling can be avoided.
[0136] Furthermore, the electronic device may train the first supervised classification model based on multiple positive samples, multiple first negative samples, the second negative samples, the third negative samples and the first unlabeled sample to obtain a target supervised classification model.
[0137] Specifically, the electronic device can repeatedly perform the above process, that is, based on multiple positive samples, multiple first negative samples, second negative samples and third negative samples, the first supervised classification model is trained to obtain a second supervised classification model, and the third negative sample in the first unlabeled sample is cleared to obtain a second unlabeled sample, so as to further input the second unlabeled sample into the second supervised classification model for classification processing to obtain a classification result corresponding to the second unlabeled sample. Furthermore, the electronic device can determine whether to stop training or repeat the above process by determining whether there is a second unlabeled sample whose classification result is untrusted, so as to obtain a target supervised classification model.
[0138] In a possible example, the implementation process of combining S202 and S501-S504 can be implemented by the following pseudo code. Wherein, i is the number of iterations. P is the existing positive samples, that is, multiple positive samples in the training set. U is multiple unlabeled samples in the training set. N is the existing negative samples, that is, multiple first negative samples in the training set. C i is the classification model after the i-th iteration. is the classification result of the classification model for unlabeled samples after the i-th iteration, and the corresponding relationship set between the unlabeled samples. i is the unlabeled sample after the i-th iteration. μ is the downsampling partition threshold, i.e., the preset ratio threshold. σ is the negative sample partition threshold, i.e., the preset anomaly threshold. D i Input C for the i-th iteration i Sample data for Q i For The extracted negative samples, such as the second candidate negative sample set and the third candidate negative sample set. i is a reliable negative sample after the i-th iteration, such as a set consisting of a plurality of first negative samples and a second negative sample, or a set consisting of a plurality of first negative samples, a second negative sample, and a third negative sample. i is the negative sample after secondary calibration at the i-th iteration, such as the second negative sample and the third negative sample. target is the target supervised classification model. Where i is a positive integer. The pseudo code implementation process is shown in S1-S8 below:
[0139] S1. Initialize the number of iterations i = 1;
[0140] S2. Specify an unsupervised classification model (such as isolation forest) as the initial classification model, that is, C1 = IsolationForest (P, U, N);
[0141] S3. Initialize reliable negative samples RN1 = N;
[0142] S4. The classification result of the classification model after initialization of the first iteration for the unlabeled samples is That is, the classification results of the unsupervised classification model for multiple unlabeled samples in the training set;
[0143] S5. According to the negative sample segmentation threshold σ, from The negative samples predicted by the classification model (i.e., the first candidate negative sample set) are obtained, that is,
[0144] S6. Initialize the unlabeled samples after the first iteration (or U);
[0145] S7. When the number of extractable negative samples is not 0, that is, from Extract Q1 from |Q i |>0,
[0146] i=i+1;
[0147] a. Using the positive and negative samples after the i-1th iteration (i.e., P and RN i-1 ), train the classification model and make predictions (i.e., classification processing);
[0148] a1. If For P∪RN i-1 Downsample and get D i =Undersample(P)∪RN i-1 ;
[0149] Otherwise, D i =P∪RN i-1 ;
[0150] a2. Use a supervised classification model (such as XGBoost) to train the i-th classification model C i =XGBoost(D i ); using C i Predict the unlabeled samples in the i-1th iteration, that is
[0151] a3. Extract the negative samples from the prediction results obtained in a2, that is
[0152] b. Expand negative sample data after secondary calibration;
[0153] b1. Determine the intersection of the negative samples in the i-th classification result and the negative samples in the i-1-th classification result, that is, RQ i =Q i ∩Q i-1 ;
[0154] b2. Remove the negative samples after secondary calibration from U i Eliminate, that is, U i =U i-1 -RQ i ;
[0155] b3. Add the negative samples after secondary calibration to the reliable negative samples, i.e. RN i =RN i-1 +RQ i ;
[0156] c. Repeat the above process until the iteration ends, that is, |Q i |=0 time.
[0157] S8. Obtain the target supervised classification model C target =C i (C1(P,U,N)) and returns.
[0158] In one embodiment, the blockchain address classification method provided in the embodiment of the present application also includes S601-S604.
[0159] S601. The electronic device obtains multiple transaction information corresponding to multiple blockchain addresses.
[0160] Among them, the multiple blockchain addresses may include multiple blockchain addresses carrying trusted labels, multiple blockchain addresses carrying untrusted labels, and multiple blockchain addresses without labels.
[0161] In one possible approach, the transaction information corresponding to a blockchain address may be log information of one or more digital currency transactions that the blockchain address participated in. One digital currency transaction may involve one or more blockchain addresses, that is, one or more blockchain addresses may have the same transaction information.
[0162] One possible approach is to combine Figure 1, the staff can perform an information acquisition operation through the input module configured by the electronic device to obtain the blockchain stored on the blockchain node. In response to the information acquisition operation, the electronic device can send an information acquisition request to the blockchain node. When the blockchain is a private chain or a consortium chain, the information acquisition request can carry relevant authentication data. Accordingly, the blockchain node can receive the information acquisition request from the electronic device and send the blockchain to the electronic device. Accordingly, the electronic device can receive the blockchain from the blockchain node, traverse the entire blockchain, extract multiple blockchain addresses in the blockchain, and multiple log information corresponding to the multiple blockchain addresses.
[0163] In one possible manner, the staff can perform a tag adding operation through an input module configured in the electronic device, thereby adding a trusted tag to the extracted partial blockchain address, and adding an untrusted tag to the extracted partial blockchain address. In response to the user's tag adding operation, the electronic device can generate a trusted tag or an untrusted tag for the blockchain address corresponding to the tag adding operation.
[0164] In one possible way, the electronic device can extract the transaction information corresponding to each blockchain address from the log information corresponding to each blockchain address. The transaction information can be log information of multiple dimensions such as cross-section and time series. Based on this, the electronic device can obtain multiple transaction information corresponding to multiple blockchain addresses one by one. And the multiple blockchain addresses can include multiple blockchain addresses carrying trusted labels, multiple blockchain addresses carrying untrusted labels, and multiple blockchain addresses without labels.
[0165] S602. The electronic device performs feature engineering processing on the multiple transaction information to obtain multiple feature data corresponding to the multiple transaction information.
[0166] Among them, feature engineering processing can include normalization processing and dummy variable processing.
[0167] In one possible manner, the electronic device may perform a preliminary screening of each transaction information to obtain the numerical data and character data in each transaction information. Further, the electronic device may perform normalization processing on the numerical data in each transaction information and perform dummy variable processing on the character data in each transaction information to obtain multiple feature data corresponding to the multiple transaction information.
[0168] Based on this, the present application can achieve the effects of dimensionless, normalized and character dummy coding of each transaction information, thereby obtaining feature data that is convenient for model calculation.
[0169] Optionally, the normalization process may be implemented based on logarithmic function conversion, linear conversion, inverse cotangent function conversion, etc. The embodiment of the present application does not limit this.
[0170] S603: The electronic device divides the plurality of feature data into k sub-training sets and test sets.
[0171] The test set can be used to test the classification accuracy of the target supervised classification model. k is a positive integer. For example, K can be 10 or 20.
[0172] In one possible manner, the electronic device may randomly select a second preset number of feature data from a plurality of feature data, and form a test set with the selected second preset number of feature data. The second preset number may be set in the electronic device in advance by the staff based on experience. Subsequently, the staff may perform a label adding operation on each feature data in the test set through an input module configured in the electronic device.
[0173] Based on this, after obtaining the target supervised classification model, the electronic device inputs each feature data in the test set into the target supervised classification model for classification processing, and obtains the classification results of each feature data in the test set, so as to further combine the labels of each feature data in the test set to determine the classification accuracy of the target supervised classification model, thereby accurately evaluating the generalization ability of the target supervised classification model. In addition, the error rate of the target supervised classification model on the training set can be compared with the error rate on the test set to determine that the model has no overfitting problem.
[0174] In one possible approach, the electronic device may remove feature data divided into a test set from the plurality of feature data, and divide the remaining feature data into k sub-training sets. Subsequently, the electronic device may train the target supervised classification model based on the k sub-training sets using a k-fold cross-validation method, thereby avoiding the overfitting problem of the target supervised classification model and improving the generalization ability of the target supervised classification model.
[0175] In a possible manner, the number of feature data included in each sub-training set may be the same, and the sub-training sets may not include the same feature data.
[0176] S604: The electronic device determines each sub-training set as a verification set, and determines the sub-training sets other than the verification set among the k sub-training sets as training sets, to obtain k verification sets and k training sets having a corresponding relationship.
[0177] In a possible example, there are three sub-training sets, namely, sub-training set a, sub-training set b and sub-training set c, preset. That is, k is 3. Then the electronic device can determine sub-training set a, sub-training set b and sub-training set c as validation sets respectively, and obtain three validation sets. The electronic device can determine sub-training set b and sub-training set c as the training sets corresponding to sub-training set a, and determine sub-training set a and sub-training set c as the training sets corresponding to sub-training set b, and determine sub-training set a and sub-training set b as the training sets corresponding to sub-training set c, and obtain three training sets. Based on this, the electronic device can obtain three validation sets and three training sets with corresponding relationships. Subsequently, the electronic device can train the target supervised classification model based on the three validation sets and three training sets according to the k-fold cross-validation method.
[0178] In one embodiment, the blockchain address classification method provided in the embodiment of the present application also includes S701-S702.
[0179] S701. The electronic device trains k target supervised classification models based on k training sets.
[0180] In one possible manner, the electronic device may respectively execute steps S201 - S203 based on k training sets to train k target supervised classification models.
[0181] S702: The electronic device determines the classification accuracy of k target supervised classification models based on the k validation sets.
[0182] It should be noted that, based on different sample data and using the same training process, the classification accuracy of the k target supervised classification models may be different. Consider determining the target supervised classification model with the highest classification accuracy among the k target supervised classification models as the model for blockchain address classification.
[0183] In one possible approach, the electronic device may input the feature data in the k validation sets into the corresponding target supervised classification models for classification processing, and further combine and determine the classification accuracy of each target supervised classification model.
[0184] In one possible approach, the staff can adjust the hyperparameters of each target supervised classification model based on the classification effect of each target supervised classification model on the validation set, so that the target supervised classification model reaches the optimal value on the validation set, and finally select the target supervised classification model with the highest classification accuracy.
[0185] In one embodiment, the blockchain address classification method provided in the embodiment of the present application also includes S801-S803.
[0186] S801. The electronic device obtains transaction information of the blockchain address to be classified.
[0187] In one possible manner, the staff may perform an editing operation through an input module configured in the electronic device to edit the blockchain address to be classified. In response to the editing operation, the electronic device may determine the blockchain address to be classified. The staff may also perform a classification operation directed to the blockchain address to be classified through the input module configured in the electronic device. In response to the classification operation, the electronic device may obtain transaction information of the blockchain address to be classified from the blockchain node.
[0188] S802: The electronic device performs feature engineering processing on the transaction information to obtain feature data corresponding to the transaction information.
[0189] It should be understood that for the specific implementation of S802, reference may be made to the description in S602, which will not be repeated here.
[0190] S803. The electronic device inputs the feature data into the target supervised classification model for classification processing to obtain the classification result of the blockchain address to be classified.
[0191] In one embodiment, Figure 3 As shown, an embodiment of the present application provides a schematic diagram of a blockchain address classification process. In the data collection and basic feature stage, the electronic device can collect blockchain addresses and historical information (also called log information) corresponding to the blockchain addresses from the blockchain to further extract transaction information corresponding to the blockchain addresses, thereby obtaining data in multiple dimensions such as cross-sections and time series associated with the transaction behavior characteristics of the blockchain addresses.
[0192] During the feature engineering processing stage, the electronic device can perform preliminary screening of each transaction information, normalize the numerical data in each transaction information, and perform dummy variable processing on the character data in each transaction information to obtain multiple feature data corresponding to multiple transaction information.
[0193] In the model training stage, the electronic device can randomly split the data set consisting of multiple feature data into k sub-training sets and test sets. The electronic device can use the k-fold cross-validation method to split the k sub-training sets into a training set consisting of k-1 sub-training sets and a validation set consisting of 1 sub-training set. In addition, the electronic device can repeat the previous process k times and output the trained model.
[0194] Specifically, the electronic device can determine each sub-training set as a validation set, and determine the sub-training sets other than the validation set among the k sub-training sets as training sets, to obtain k validation sets and k training sets that have a corresponding relationship. The electronic device can train k target supervised classification models based on the k training sets, and further determine the classification accuracy of the k target supervised classification models based on the k validation sets, and determine the target supervised classification model with the highest classification accuracy as the trained model, and output the trained model.
[0195] In the model testing phase, the electronic device can use the trained model to predict the test set data and verify the model accuracy. That is, after obtaining the trained model, the electronic device can input each feature data in the test set into the trained model for classification processing, and obtain the classification results of each feature data in the test set, so as to further combine the labels of each feature data in the test set to determine the classification accuracy of the trained model, so as to accurately evaluate the generalization ability of the trained model.
[0196] Furthermore, the electronic device can synthesize the model test results and output the model. That is, the electronic device can compare the error rate of the trained model on the test set with the error rate on the training set. If the difference between the error rate on the test set and the error rate on the training set is less than a preset value, the electronic device can determine that the trained model does not have an overfitting problem and output the model. Subsequently, the electronic device can use the output model to classify blockchain addresses.
[0197] In an embodiment of the present application, after obtaining a training set including multiple positive samples, multiple first negative samples and multiple unlabeled samples, the electronic device can input the multiple unlabeled samples into an unsupervised classification model and a supervised classification model respectively, to obtain a first candidate negative sample set corresponding to the unsupervised classification model and a second candidate negative sample set corresponding to the supervised classification model, and determine the intersection of the first candidate negative sample set and the second candidate negative sample set as the second negative sample, so as to further train the supervised classification model based on the multiple positive samples, the multiple first negative samples, the second negative samples and the multiple unlabeled samples, and obtain a target supervised classification model for classifying the blockchain addresses to be classified.
[0198] Based on this, the present application can use a semi-supervised learning method to train a supervised classification model by combining labeled samples and unlabeled samples, avoiding the low efficiency problem caused by the traditional method of relying on manual labeling of a large number of samples, and can improve the efficiency of the model training process.
[0199] Furthermore, since the second negative sample is an unlabeled sample whose classification result based on the unsupervised classification model is untrusted and whose classification result based on the supervised classification model is untrusted. That is, when the second negative sample is screened from the unlabeled sample, it is achieved by secondary calibration of the unsupervised classification model and the supervised classification model, and has high accuracy. Therefore, when the present application further uses the second negative sample to train the model, it can avoid the problem of reduced model accuracy caused by incorrect sample labeling. Therefore, the present application can improve the training effect of the model for classifying blockchain addresses, thereby improving the accuracy of blockchain address classification.
[0200] The above mainly introduces the solution provided by the embodiment of the present application from the perspective of the method. In order to achieve the above functions, the electronic device includes a hardware structure and / or software module corresponding to the execution of each function. It should be easily appreciated by those skilled in the art that, in combination with the units and algorithm steps of each example described in the embodiments disclosed herein, the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present application.
[0201] The embodiment of the present application can divide the functional modules of the electronic device according to the above method. For example, the electronic device can include functional modules corresponding to the functional divisions, or two or more functions can be integrated into one processing module. The above integrated modules can be implemented in the form of hardware or in the form of software functional modules. It should be noted that the division of modules in the embodiment of the present application is schematic and is only a logical functional division. There may be other division methods in actual implementation.
[0202] For example, an embodiment of the present application also provides a blockchain address classification device.
[0203] Figure 4 is a block diagram of a blockchain address classification device according to an exemplary embodiment. Figure 4 , the blockchain address classification device may include: an acquisition unit 901 and a processing unit 902;
[0204] The acquisition unit 901 is configured to execute acquisition of a training set; the training set includes a plurality of positive samples, a plurality of first negative samples, and a plurality of unlabeled samples; the positive samples are used to characterize the transaction behavior characteristics of a trusted blockchain address; the first negative samples are used to characterize the transaction behavior characteristics of an untrusted blockchain address; and the unlabeled samples are used to characterize the transaction behavior characteristics of an unclassified blockchain address;
[0205] The processing unit 902 is configured to input the multiple unlabeled samples into the unsupervised classification model and the supervised classification model respectively, obtain a first candidate negative sample set corresponding to the unsupervised classification model and a second candidate negative sample set corresponding to the supervised classification model, and determine the intersection of the first candidate negative sample set and the second candidate negative sample set as the second negative sample;
[0206] The processing unit 902 is further configured to perform training on a supervised classification model based on multiple positive samples, multiple first negative samples, second negative samples, and multiple unlabeled samples to obtain a target supervised classification model; the target supervised classification model is used to classify the blockchain addresses to be classified.
[0207] In an optional implementation, the processing unit 902 is further configured to execute:
[0208] Determine a ratio between the number of the plurality of first negative samples and the number of the plurality of positive samples;
[0209] When the ratio value is less than or equal to a preset ratio threshold, down-sampling the multiple positive samples according to the ratio value, and inputting the down-sampled positive samples and the multiple first negative samples into the initial supervised classification model for training to obtain a supervised classification model;
[0210] When the ratio value is greater than a preset ratio threshold, the plurality of positive samples and the plurality of first negative samples are input into the initial supervised classification model for training to obtain a supervised classification model.
[0211] In an optional implementation, the processing unit 902 is specifically configured to execute:
[0212] Based on the multiple positive samples, the multiple first negative samples and the second negative samples, the supervised classification model is trained to obtain a first supervised classification model;
[0213] Inputting the first unlabeled sample into the first supervised classification model for classification processing to obtain a classification result corresponding to the first unlabeled sample; the first unlabeled sample is used to represent the unlabeled samples other than the second negative sample in the plurality of unlabeled samples;
[0214] When there is no third candidate negative sample set including at least one third candidate negative sample, determining the first supervised classification model as the target supervised classification model; the third candidate negative sample is used to characterize that the classification result is an untrusted first unlabeled sample;
[0215] When there is a third candidate negative sample set, the intersection of the second candidate negative sample set and the third candidate negative sample set is determined as the third negative sample, and the first supervised classification model is trained based on multiple positive samples, multiple first negative samples, the second negative samples, the third negative samples and the first unlabeled samples to obtain a target supervised classification model.
[0216] In an optional implementation, the processing unit 902 is specifically configured to execute:
[0217] Inputting multiple unlabeled samples into an unsupervised classification model for classification processing, and obtaining multiple outliers corresponding to the multiple unlabeled samples one by one;
[0218] An unlabeled sample whose outlier value is greater than a preset outlier threshold is determined as a first candidate negative sample, and a first candidate negative sample set including at least one first candidate negative sample is obtained.
[0219] In an optional implementation, the acquisition unit 901 is further configured to execute acquisition of multiple transaction information corresponding to multiple blockchain addresses one by one; the multiple blockchain addresses include multiple blockchain addresses carrying trusted labels, multiple blockchain addresses carrying untrusted labels, and multiple blockchain addresses without labels;
[0220] The processing unit 902 is further configured to perform feature engineering processing on the plurality of transaction information to obtain a plurality of feature data corresponding to the plurality of transaction information one by one; the feature engineering processing includes normalization processing and dummy variable processing;
[0221] The processing unit 902 is further configured to execute dividing the plurality of feature data into k sub-training sets and a test set; the test set is used to test the classification accuracy of the target supervised classification model; k is a positive integer;
[0222] The processing unit 902 is further configured to respectively determine each sub-training set as a validation set, and determine the sub-training sets other than the validation set among the k sub-training sets as training sets, so as to obtain k validation sets and k training sets having a corresponding relationship.
[0223] In an optional implementation, the processing unit 902 is further configured to execute training based on k training sets to obtain k target supervised classification models respectively; the processing unit 902 is further configured to execute determination of the classification accuracy of the k target supervised classification models respectively based on k validation sets.
[0224] In an optional implementation, the acquisition unit 901 is further configured to execute acquisition of transaction information of the blockchain address to be classified; the processing unit 902 is further configured to perform feature engineering processing on the transaction information to obtain feature data corresponding to the transaction information; the processing unit 902 is further configured to execute input of the feature data into the target supervised classification model for classification processing to obtain the classification result of the blockchain address to be classified.
[0225] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0226] Figure 5 It is a block diagram of an electronic device according to an exemplary embodiment.
[0227] like Figure 5 As shown, the electronic device 200 includes but is not limited to: a processor 210 and a memory 220 .
[0228] The memory 220 is used to store executable instructions of the processor 210. It can be understood that the processor 210 is configured to execute instructions to implement the blockchain address classification method in the above embodiment.
[0229] It should be noted that those skilled in the art can understand that Figure 5 The electronic device structure shown in the figure does not constitute a limitation on the electronic device, and the electronic device may include Figure 5 More or fewer components may be shown, or certain components may be combined, or the components may be arranged differently.
[0230] The processor 210 is the control center of the electronic device. It uses various interfaces and lines to connect various parts of the entire electronic device. It executes various functions of the electronic device and processes data by running or executing software programs and / or modules stored in the memory 220, and calling data stored in the memory 220, so as to monitor the electronic device as a whole. The processor 210 may include one or more processing units; optionally, the processor 210 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 210.
[0231] The memory 220 can be used to store software programs and various data. The memory 220 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application program required by at least one functional module, etc. In addition, the memory 220 can include a high-speed random access memory, and can also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.
[0232] In an exemplary embodiment, a computer-readable storage medium including instructions is also provided, such as a memory 220 including instructions, and the above instructions can be executed by the processor 210 of the electronic device 200 to implement the blockchain address classification method in the above embodiment.
[0233] Optionally, the computer-readable storage medium may be a non-temporary computer-readable storage medium, for example, the non-temporary computer-readable storage medium may be a read-only memory (ROM), a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0234] In an exemplary embodiment, the present application also provides a computer program product including one or more instructions, which can be executed by the processor 210 of the electronic device 200 to complete the blockchain address classification method in the above embodiment.
[0235] It should be noted that when the instructions in the above-mentioned computer-readable storage medium or one or more instructions in the computer program product are executed by the processor 210 of the electronic device 200, the various processes of the above-mentioned blockchain address classification method embodiment are implemented, and the same technical effect as the above-mentioned blockchain address classification method can be achieved. In order to avoid repetition, it will not be repeated here.
[0236] Through the description of the above implementation methods, technical personnel in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.
[0237] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of modules or units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0238] The units described as separate components may or may not be physically separated, and the components shown as units may be one physical unit or multiple physical units, that is, they may be located in one place or distributed in multiple different places. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0239] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0240] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes to the general technology or the full classification part or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium, including a number of instructions to enable a device (which can be a single-chip microcomputer, chip, etc.) or a processor (processor) to execute the full classification part or part of the steps of each embodiment method of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, ROM, RAM, disk or CD and other media that can store program code.
[0241] The above are only specific implementations of the present application, but the protection scope of the present application is not limited thereto, and any changes or substitutions within the technical scope disclosed in the present application should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A blockchain address classification method, characterized in that: include: Get the training set; The training set includes a plurality of positive samples, a plurality of first negative samples and a plurality of unlabeled samples; The positive samples are used to characterize the transaction behavior characteristics of the trusted blockchain address; The first negative sample is used to characterize the transaction behavior characteristics of an untrusted blockchain address; The unlabeled samples are used to characterize the transaction behavior characteristics of unclassified blockchain addresses; Inputting the multiple unlabeled samples into an unsupervised classification model and a supervised classification model respectively, obtaining a first candidate negative sample set corresponding to the unsupervised classification model and a second candidate negative sample set corresponding to the supervised classification model, and determining an intersection of the first candidate negative sample set and the second candidate negative sample set as a second negative sample; Based on the multiple positive samples, the multiple first negative samples, the second negative samples and the multiple unlabeled samples, the supervised classification model is trained to obtain a target supervised classification model; The objective is to use a supervised classification model to classify blockchain addresses to be classified.
2. The blockchain address classification method according to claim 1, characterized in that: After obtaining the training set, the method further includes: Determine a ratio between the number of the plurality of first negative samples and the number of the plurality of positive samples; When the ratio value is less than or equal to a preset ratio threshold, down-sampling the multiple positive samples according to the ratio value, and inputting the positive samples and the multiple first negative samples obtained by down-sampling into an initial supervised classification model for training to obtain the supervised classification model; When the ratio value is greater than the preset ratio threshold, the multiple positive samples and the multiple first negative samples are input into the initial supervised classification model for training to obtain the supervised classification model.
3. The blockchain address classification method according to claim 1, characterized in that: The step of training the supervised classification model based on the multiple positive samples, the multiple first negative samples, the second negative samples, and the multiple unlabeled samples to obtain a target supervised classification model includes: Based on the multiple positive samples, the multiple first negative samples and the second negative samples, the supervised classification model is trained to obtain a first supervised classification model; Inputting the first unlabeled sample into the first supervised classification model for classification processing to obtain a classification result corresponding to the first unlabeled sample; the first unlabeled sample is used to represent the unlabeled samples among the multiple unlabeled samples except the second negative sample; When there is no third candidate negative sample set including at least one third candidate negative sample, determining the first supervised classification model as the target supervised classification model; the third candidate negative sample is used to characterize that the classification result is the untrusted first unlabeled sample; When the third candidate negative sample set exists, the intersection of the second candidate negative sample set and the third candidate negative sample set is determined as the third negative sample, and the first supervised classification model is trained based on the multiple positive samples, the multiple first negative samples, the second negative samples, the third negative samples and the first unlabeled samples to obtain the target supervised classification model.
4. The blockchain address classification method according to any one of claims 1 to 3, characterized in that: The process of determining the first candidate negative sample set corresponding to the unsupervised classification model includes: Inputting the multiple unlabeled samples into the unsupervised classification model for classification processing to obtain multiple outliers corresponding to the multiple unlabeled samples one by one; The unlabeled samples whose outliers are greater than a preset outlier threshold are determined as first candidate negative samples, and the first candidate negative sample set including at least one of the first candidate negative samples is obtained.
5. The blockchain address classification method according to claim 1, characterized in that: Also includes: Acquire multiple transaction information corresponding to multiple blockchain addresses one by one; the multiple blockchain addresses include multiple blockchain addresses carrying trusted labels, multiple blockchain addresses carrying untrusted labels, and multiple blockchain addresses without labels; Performing feature engineering processing on the multiple transaction information to obtain multiple feature data corresponding to the multiple transaction information one by one; the feature engineering processing includes normalization processing and dummy variable processing; Divide the plurality of feature data into k sub-training sets and a test set; the test set is used to test the classification accuracy of the target supervised classification model; k is a positive integer; Each of the sub-training sets is determined as a validation set, and the sub-training sets other than the validation set among the k sub-training sets are determined as the training set, so as to obtain k validation sets and k training sets having a corresponding relationship.
6. The blockchain address classification method according to claim 5, characterized in that: Also includes: Based on the k training sets, k supervised classification models of the targets are obtained by training respectively; Based on the k validation sets, the classification accuracies of the k target supervised classification models are determined respectively.
7. The blockchain address classification method according to any one of claims 1 to 3, characterized in that: Also includes: Obtaining transaction information of the blockchain address to be classified; Performing feature engineering processing on the transaction information to obtain feature data corresponding to the transaction information; The feature data is input into the target supervised classification model for classification processing to obtain a classification result of the blockchain address to be classified.
8. A blockchain address classification device, characterized in that: include: Acquisition unit and processing unit; The acquisition unit is configured to acquire a training set; the training set includes a plurality of positive samples, a plurality of first negative samples, and a plurality of unlabeled samples; the positive samples are used to characterize transaction behavior characteristics of a trusted blockchain address; The first negative sample is used to characterize the transaction behavior characteristics of an untrusted blockchain address; The unlabeled samples are used to characterize the transaction behavior characteristics of unclassified blockchain addresses; The processing unit is configured to input the multiple unlabeled samples into an unsupervised classification model and a supervised classification model respectively, obtain a first candidate negative sample set corresponding to the unsupervised classification model and a second candidate negative sample set corresponding to the supervised classification model, and determine an intersection of the first candidate negative sample set and the second candidate negative sample set as a second negative sample; The processing unit is further configured to perform training on the supervised classification model based on the multiple positive samples, the multiple first negative samples, the second negative samples and the multiple unlabeled samples to obtain a target supervised classification model; The objective is to use a supervised classification model to classify blockchain addresses to be classified.
9. An electronic device, characterized in that: include: processor; a memory for storing instructions executable by the processor; Wherein, the processor is configured to execute the instructions to implement the blockchain address classification method as described in any one of claims 1-7.
10. A computer-readable storage medium having instructions stored thereon, characterized in that: When the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to perform the blockchain address classification method as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Federal model training method and device
CN115907002A
