Fish scale anti-cheating method and system
By combining intelligent data cleaning and multi-dimensional feature extraction with a random forest model, the problem of static cheating detection in fish scales was solved, and a fish scale anti-cheating system with high accuracy and robustness was achieved.
Patent Information
- Application Number
- CN202511761289.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-27
- Publication Date
- 2026-03-10
AI Technical Summary
Existing technologies are ineffective at identifying static cheating items in fish scales, and their accuracy in identifying fish of different types, sizes, and levels of struggle is low, resulting in poor robustness.
By extracting multidimensional feature vectors through intelligent data cleaning, combining them with a random forest classification model for prediction, and introducing a confidence filtering mechanism, we can achieve effective identification and high robustness of static cheating.
It effectively identifies static cheating, improves the accuracy and generalization ability of identification, the reliability of results and the reliability of the system, and is adaptable to fish of different types, sizes and states.
Smart Images

Figure CN121632308A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of electronic weighing technology, and in particular to a method and system for preventing cheating on fish scales. Background Technology
[0002] Electronic scales are widely used in fisheries transactions and seafood markets. In these settings, some unscrupulous vendors cheat by using non-fish items (such as ice, stones, or metal blocks) to impersonate or mix with the fish during the weighing process, thus increasing the total weight. Traditional electronic scales can only display static weight and cannot effectively detect this type of fraud.
[0003] In existing technologies, some attempts have been made to identify live fish by analyzing the weight change curve (i.e., weight signal sequence) during the weighing process. However, existing technical solutions have obvious drawbacks and limitations: Weak ability to identify static cheats: Existing methods rely heavily on dynamic fluctuations in weight. When cheaters use completely stationary cheats (such as stones or frozen ice blocks with a weight similar to that of a fish), their weight curves are indistinguishable from those of a stably placed object. Existing algorithms cannot distinguish them from a fish that remains stationary on the scale, leading to misjudgments or missed judgments.
[0004] Single feature dimension: Existing technologies usually only focus on a few shallow features such as fluctuation amplitude and frequency, failing to fully explore the rich information contained in the weight signal sequence, such as dynamic change trend, signal stability, statistical distribution characteristics, etc., resulting in limited feature discrimination ability of the model.
[0005] Poor robustness: The wavy patterns of fish vary greatly depending on their species, size, and degree of struggle. Simple threshold judgments or rule-based algorithms are prone to decreased recognition accuracy due to individual differences in fish, and their generalization ability is weak.
[0006] Therefore, there is an urgent need in this field for a fish scale anti-cheating technology solution that can overcome the above-mentioned defects, accurately identify static and dynamic cheating, and has high robustness. Summary of the Invention
[0007] Based on the technical problems existing in the prior art, this invention proposes a method and system for preventing cheating on fish scales.
[0008] The present invention proposes a method for preventing cheating on fish scales, comprising the following steps: S1: Data acquisition and preprocessing: Acquire the raw weight signal sequence collected by the weighing sensor within a preset time period; S2: Intelligent data cleaning: Clean the original weight signal sequence to remove invalid initial fluctuation data segments and locate valid weighing data segments; S3: Multidimensional feature extraction: Extract a feature vector containing at least ten dimensions from the cleaned effective weighing data segment; the feature vector includes basic fluctuation features, dynamic change features, and composite statistical features; S4: Machine learning model prediction: Input the feature vector into a pre-trained random forest classification model for prediction to obtain the classification result and its confidence level; S5: Confidence Filtering and Result Output: Filter the classification result based on the confidence level. If the confidence level is higher than the preset threshold, output the final classification result; otherwise, output a prompt that manual review is required.
[0009] Furthermore, the intelligent data cleaning described in step S2 specifically includes: S21: Determine the sequence length. If the length is less than the threshold, skip the cleaning process. S22: Calculate the average of a predetermined number of data points at the end of the sequence as a stable weight value; S23: Set a dynamic threshold at a certain percentage (e.g., 95%) of the stable weight value; S24: Start scanning from the beginning of the sequence to find the first position where N consecutive (e.g., 3) data points are all greater than or equal to the dynamic threshold; S25: The data segment following this position is considered a valid weighing data segment.
[0010] Furthermore, the multidimensional feature vector mentioned in step S3 includes: Basic volatility characteristics: maximum volatility (difference between maximum and minimum values), standard deviation, coefficient of variation (ratio of standard deviation to mean), and data series length.
[0011] Dynamic change characteristics: zero crossover count (the number of times the signal crosses its mean), average first derivative (characterizing the average rate of change), maximum fluctuation frequency (the proportion of the absolute value of the first derivative exceeding a certain threshold), and rapid vibration intensity (the average value of the first derivative corresponding to large fluctuations).
[0012] Composite statistical characteristic: the ratio of total weight to estimated number of items (if applicable).
[0013] Furthermore, in step S4, the random forest classification model is obtained through the following training process: T1: Prepare the training dataset, which contains a large number of weight signal sequence samples labeled as "fish" and "not fish"; T2: Perform steps S2 and S3 for each sample to generate feature vector-label pairs; T3: Standardize the feature vectors; T4: Train a random forest classifier using the standardized feature vectors and optimize the hyperparameters.
[0014] A fish scale anti-cheating system, used to implement the above method, includes: Prediction Service Module: A RESTful API service built on the Flask framework, providing health check interfaces, single prediction interfaces, and batch prediction interfaces to receive weight data sent by external weighing devices and return prediction results.
[0015] The core prediction module loads the trained random forest model and normalizer, receives data from the prediction service module, and sequentially executes data parsing, intelligent data cleaning, multi-dimensional feature extraction, model prediction, and confidence filtering logic.
[0016] Machine Learning Training Module: Used for training and updating models, including a data loader, data cleaner, feature extractor, and model trainer, capable of learning from historical data and generating or optimizing predictive models.
[0017] Compared with the prior art, the present invention provides a method and system for preventing cheating on fish scales, which has the following beneficial effects: Effective identification of static cheating: This invention introduces an "intelligent data cleaning" step to locate the effective data segment after the weight has stabilized. Even for completely still fish and completely still cheating objects, the multidimensional features extracted by this invention (such as the coefficient of variation, signal characteristics before zero crossover, etc.) can capture the subtle differences between the two in terms of stabilization process and small signal noise. Combined with a powerful machine learning model, it achieves effective differentiation of static cheating and solves the core pain point of existing technologies.
[0018] High accuracy and robustness: By extracting a ten-dimensional feature vector encompassing fluctuations, dynamics, and statistical characteristics, the model receives extremely rich information input. The random forest model can automatically learn the complex, non-linear mapping relationship between these features and "fish / non-fish," exhibiting good adaptability to fish of different species, sizes, and states, significantly improving recognition accuracy and generalization ability.
[0019] The results are reliable and trustworthy: a confidence filtering mechanism has been introduced. The model not only outputs the classification result of "yes" or "no", but also the confidence probability of its judgment. When the model is uncertain about a certain result (such as when the confidence level is below 90%), the system will prompt that manual verification is required, avoiding misjudgments that may be caused by low-confidence predictions and improving the practicality and reliability of the system.
[0020] Systematization and Engineering: This invention encapsulates the algorithm into a modular system, providing services through APIs for easy integration with various electronic scale hardware. The existence of the training module allows the model to be continuously iterated and optimized, adapting to new cheating methods, forming a complete closed loop from data to model to service. Attached Figure Description
[0021] Figure 1 This is a diagram illustrating the overall architecture of a fish scale anti-cheating system proposed in this invention. Figure 2 This is a flowchart illustrating the overall process of an anti-cheating method for fish scales proposed in this invention. Figure 3 This is a flowchart of the intelligent data cleaning steps in a fish scale anti-cheating method proposed in this invention. Detailed Implementation
[0022] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments.
[0023] In the description of this invention, it should be understood that the terms "upper", "lower", "front", "rear", "left", "right", "top", "bottom", "inner", "outer", etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They are only for the convenience of describing this invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on this invention.
[0024] Example 1, refer to Figure 2 The anti-cheating method for fish scales in this embodiment is performed according to the following steps: Data Acquisition and Preprocessing: The load cell collects weight data at a certain frequency (e.g., 10Hz) for approximately 5-10 seconds, forming a raw weight signal sequence, such as [0,15,45,78,85,88,90,89,91,90,89,...]. This sequence is sent to the prediction interface via an HTTP POST request in the form of an array or a comma-separated string.
[0025] Intelligent data cleaning (reference) Figure 3 After receiving the data, the core prediction module calls the cleaning algorithm.
[0026] First, determine the data length. If it is less than 10, proceed directly to feature extraction.
[0027] Calculate the average of the last 5 points, for example, (89+91+90+89+90) / 5=89.8, as the stable value.
[0028] The dynamic threshold is set to 89.8 * 0.95 ≈ 85.3.
[0029] Starting the scan from the sequence, assuming it begins at index 2 with data [78, 85, 88], all values greater than 85.3, we extract the effective data segment [78, 85, 88, 90, 89, 91, 90, 89, ...]. This step removes the unstable data immediately after the fish lands, focusing on the stable and effective information.
[0030] Multidimensional feature extraction: Extract 10-dimensional features from the cleaned data segment.
[0031] Calculate the basic volatility characteristics: maximum value 91, minimum value 78, then maximum volatility = 13; standard deviation ≈ 4.2; mean ≈ 87.5, coefficient of variation ≈ 0.048; data length = assumed to be 50.
[0032] Calculate the dynamic change characteristics: Calculate the first derivative of the sequence, and count the number of times it crosses the mean of 87.5 as the zero crossover number; calculate the average of the absolute values of all derivatives to obtain the average first derivative; count the proportion of points with absolute derivative values greater than 10 as the maximum fluctuation frequency; calculate the average of the absolute values of the derivatives of these large fluctuation points as the rapid oscillation intensity.
[0033] Combine all features into a feature vector [13, 4.2, 0.048, 50, ...].
[0034] Machine learning model prediction: The feature vector is input into the loaded random forest model. The model first standardizes the features using the standard scaler saved during training, and then makes a prediction. Suppose the model outputs the prediction "is a fish", and the corresponding probability is [0.15, 0.85] (that is, the probability of not being a fish is 15%, and the probability of being a fish is 85%).
[0035] Confidence filtering and result output: The system sets the confidence threshold to 90%. Since the confidence level for "is a fish" is 85% < 90%, based on logic (in this embodiment, it is directly judged as not a fish only when the prediction is not a fish and the confidence level is > 90%; otherwise, it needs to be reviewed or judged as a fish), or adjusted according to business logic, it can be set here as follows: when the highest confidence level is below 90%, "suggest manual review" is returned. The final returned JSON result is: {'Prediction result':'suggest manual review','probability of being a fish: 0.85,'probability of not being a fish: 0.15'}.
[0036] Example 2, refer to Figure 1 This system consists of three core modules: 1. Prediction Service Module (http_server.py): This module serves as the system entry point and is built using the Flask framework.
[0037] After startup, listen on the specified port: The / health interface is used by load balancing or monitoring systems to check service status. The / predict interface receives a single data entry and calls the predict_single function of the core prediction module; The / predict / batch interface receives batch data and repeatedly calls single-line prediction to improve processing efficiency.
[0038] This module handles data format compatibility issues to ensure ease of use of the interface.
[0039] 2. Core prediction module (predict.py): This is the core engine of the algorithm.
[0040] When the service starts, the pre-trained fish_detection_model.pkl (random forest model) and scaler.pkl (normalizer) are loaded through the joblib library.
[0041] The predict_single function integrates the entire chain of logic from data parsing to result output, and its code structure corresponds completely to the steps in Example 1.
[0042] This module is designed to be stateless, which facilitates horizontal scaling.
[0043] 3. Machine learning training module (fish_detection_ml.py): This module is encapsulated in the form of the FishDetectionML class.
[0044] The `load_data_from_excel` method reads historical transaction data from a structured Excel file, including weight, raw sampled data string, and manually labeled tags.
[0045] Use the parse_sampling_data and clean_sampling_data methods to preprocess the training data in the same way as when making predictions.
[0046] Use the extract_features method to generate a feature vector dataset.
[0047] Finally, the RandomForestClassifier from the scikit-learn library was used for model training, and grid search (GridSearchCV) was used for hyperparameter tuning to obtain the model with optimal performance. The trained model and normalizer were persistently saved for loading by the prediction module.
[0048] The above description is only a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any equivalent substitutions or modifications made by those skilled in the art within the scope of the technology disclosed in the present invention, based on the technical solution and inventive concept of the present invention, should be covered within the scope of protection of the present invention.
Claims
1. A fish scale fraud prevention method for a fish scale fraud prevention method, characterized by, The method comprises the following steps: a data acquisition step of acquiring a raw weight signal sequence collected by the weighing sensor during the weighing process; an intelligent data cleaning step of cleaning the raw weight signal sequence to locate and intercept an effective weighing data segment; a multi-dimensional feature extraction step of extracting a feature vector containing multiple dimensions from the cleaned effective weighing data segment; a model prediction step of inputting the feature vector into a pre-trained machine learning classification model for prediction to obtain a classification result and a corresponding confidence level; a result output step of outputting a final anti-cheating judgment result based on the classification result and the confidence level.
2. The fish scale fraud prevention method according to claim 1, wherein, The intelligent data cleaning step specifically comprises: calculating a stable value of the data points at the end of the raw weight signal sequence; setting a dynamic threshold based on the stable value; starting from the beginning of the raw weight signal sequence, scanning to find the first position that meets a predetermined condition, the predetermined condition being that the values of the continuous N data points from this position are all greater than or equal to the dynamic threshold, where N is an integer greater than 1; regarding the data sequence after this position as the effective weighing data segment.
3. The fish scale anti-cheating method according to claim 2, characterized in that: the stable value is the arithmetic mean of the last M data points of the raw weight signal sequence, where M is an integer greater than 1; the dynamic threshold is the stable value multiplied by a preset proportion coefficient, and the proportion coefficient is between 0.9 and 1.0; the value of N is 3.
4. The fish scale fraud prevention method according to claim 1, wherein The feature vector extracted in the multi-dimensional feature extraction step includes at least ten of the following features: a total weight value corresponding to the raw weight signal sequence; basic fluctuation features including maximum fluctuation value, standard deviation, coefficient of variation, and data sequence length; dynamic change features including zero-crossing frequency, average first derivative, maximum fluctuation frequency, and rapid vibration intensity; composite statistical features including the ratio of weight to estimated number of fish.
5. The fish scale anti-cheating method according to claim 4, characterized in that: the zero-crossing frequency is the number of times the effective weighing data segment crosses its own mean value; the average first derivative is the arithmetic mean of the absolute values of the first derivative of the effective weighing data segment; the maximum fluctuation frequency is the proportion of the number of points whose first derivative absolute values exceed a first preset threshold to the total number of points; the rapid vibration intensity is the arithmetic mean of the absolute values of the derivatives of all data points whose first derivative absolute values exceed the first preset threshold.
6. The fish scale fraud prevention method according to claim 1, wherein The machine learning classification model in the model prediction step is a random forest model; and before model prediction, the step of normalizing the feature vector is further included.
7. The fish scale fraud prevention method according to claim 1, wherein The result output step specifically comprises: if the classification result is "non-fish" and its corresponding confidence level is higher than a preset threshold, output the judgment of "non-fish"; otherwise, output the judgment of "fish" or the prompt of "suggest manual review".
8. A fish scale anti-cheating system for implementing the method according to any one of claims 1 to 7, characterized in that, It comprises: a prediction service module for building a network API service, receiving an externally input weight signal sequence, and returning a prediction result; a core prediction module configured to load a pre-trained machine learning model and perform the logic of the intelligent data cleaning step, the multi-dimensional feature extraction step, the model prediction step, and the result output step; a machine learning training module configured to train and generate the machine learning model based on historical data.
9. The fish scale anti-cheating system according to claim 8, characterized in that: the prediction service module is built based on a Flask framework and provides a single prediction interface and a batch prediction interface; the core prediction module integrates a data analysis unit, a data cleaning unit, a feature extraction unit, a model prediction unit, and a confidence filtering unit; the machine learning training module includes a data loader, a data cleaner, a feature extractor, and a model trainer.