A multi-period recidivism behavior prediction method, device and medium
By using the Transformer model and multi-head attention mechanism, the problems of gradient vanishing and inflexible feature weight allocation in multi-period prediction of traditional models are solved, realizing efficient multi-period re-crime behavior prediction and improving the accuracy and stability of prediction.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- THE ACAD OF TIANJIN UNIV HEFEI
- Filing Date
- 2026-04-17
- Publication Date
- 2026-07-14
AI Technical Summary
Traditional single-period prediction models struggle to capture and predict multiple periodic features simultaneously. Recurrent neural networks are prone to gradient vanishing or gradient exploding problems when processing long-sequence mental data, and they lack the flexibility to assign importance weights to features at different time points.
A dual-channel encoder using the Transformer model extracts deep temporal semantic features from the mental evolution sequence and the external environmental factor sequence, respectively. Weights are calculated through cross-sequence attention layers, and residual connections and layer normalization are performed. Combined with multi-head attention mechanism and non-negative matrix factorization for denoising, multi-cycle recidivism prediction probabilities are generated.
It effectively avoids the gradient vanishing problem, improves the model's generalization ability in complex social scenarios, enhances feature representation and relationship modeling capabilities, and improves the accuracy and reliability of multi-period prediction.
Smart Images

Figure CN122390140A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of data mining and behavior prediction technology, and relates to a method, device and medium for predicting multi-period recidivism behavior based on the fusion of multiple influencing factor representations. Background Technology
[0002] Criminal behavior is not an isolated random event, but is closely linked to an individual's deep-seated social behavioral patterns and psychological evolutionary state, and these patterns continuously evolve with external environmental stimuli and the passage of time. Existing technologies, such as the invention patent with publication number CN120162545A, disclose a dynamic multi-factor dissociation analysis method for recidivism. This method uses an adversarial learning framework to generate a static representation generator, an evolutionary representation generator, and a discriminator. The dynamic and complex criminal network is input into the static and evolutionary representation generators for feature learning, generating static and evolutionary representations of recidivism at different time points. However, traditional single-cycle prediction methods typically only provide an assessment of criminal tendency at a single time point. This static, slice-like analysis severely ignores the changing patterns of behavior over time. In contrast, multi-cycle recidivism prediction can better reflect the dynamic characteristics of criminal behavior, encompassing short-term fluctuations, long-term evolutionary trends, and even seasonal patterns. Therefore, multi-cycle sequence prediction is particularly important in recidivism early warning, requiring the prediction model to have the ability to simultaneously identify and process behavioral characteristics at different time scales, thereby comprehensively improving the accuracy and reliability of the prediction.
[0003] However, traditional single-period prediction models struggle to capture and predict these multiple periodic features simultaneously. Although current recurrent neural networks (RNNs) and their mainstream variants (such as Long Short-Term Memory networks (LSTM) and gated recurrent units (GRUs) have shown certain advantages in processing time series data, directly applying them to highly complex multi-period recidivism prediction still faces many significant technical bottlenecks.
[0004] First, due to inherent limitations in network structure, recurrent neural network models are highly susceptible to vanishing or exploding gradients when processing long sequences of mental data. This means that as the number of time steps increases, the model struggles to effectively capture and learn long-range dependencies between distant elements in the sequence, severely limiting its ability to uncover long-term patterns of criminal behavior.
[0005] Secondly, traditional recurrent neural networks encode temporal information through a single hidden state. This mechanism leads to a severe "information bottleneck" during information transmission, preventing the model from flexibly adjusting the importance weights of features at different historical time points in different prediction stages. In real-world recidivism prediction scenarios, the contribution of specific behaviors (or different environmental stimuli) at different time points to the final criminal risk is dynamically changing, and existing models lack sufficient flexibility in allocating these dynamic feature weights.
[0006] In summary, how to break through the structural limitations of traditional time series models, effectively integrate individual internal mental evolution data with external multidimensional environmental factors, effectively capture multi-period prediction models with weights at multiple time points in long sequences, and achieve efficient denoising and feature extraction has become a key technical problem that urgently needs to be solved in this field. Summary of the Invention
[0007] The technical problem to be solved by this invention is how to improve the accuracy and reliability of multi-period prediction of criminal behavior.
[0008] The present invention solves the above-mentioned technical problems through the following technical solutions:
[0009] A method for predicting multi-cycle recidivism includes the following steps: Acquire raw mental evolution sequence data of individuals at different time slices, as well as sequence data of external environmental factors aligned with their time; The original mental evolution sequence and the external environmental factor sequence are respectively input into their respective independent encoders. The deep temporal semantic features of each sequence are extracted through a self-attention mechanism to obtain mental encoding representation and environmental encoding representation. Using environmental encoding representations as key and value terms, cross-sequence attention weights are calculated, and attention outputs are residually connected and layer normalized with mental encoding representations to generate mental evolution sequences that integrate environmental factor representations. A multi-head attention mechanism is introduced to compute attention in parallel in multiple representation subspaces and splice and fuse them. Then, through feedforward neural networks, residual connections and layer normalization processing, an enhanced fused mental evolution sequence is obtained. The enhanced fusion mental evolution sequence is sequentially subjected to time dimension decomposition, temporal feature extraction, linear concatenation, nonnegative matrix decomposition for denoising, and linear mapping prediction to output the multi-cycle re-crime prediction probability.
[0010] Furthermore, the sequential execution of time dimension decomposition, temporal feature extraction, linear concatenation, nonnegative matrix factorization for denoising, and linear mapping prediction specifically includes the following steps: The enhanced fusion mental evolution sequence is downsampled at equal intervals along the time dimension and decomposed into multiple interleaved subsequences; Each subsequence is input into an independent temporal feature extractor for temporal dependency modeling to obtain the temporal feature representation of each subsequence; The temporal feature representations of each subsequence are linearly concatenated according to the original time index to obtain a channel feature representation that mixes multiple time scales; Denoising the channel feature representation by nonnegative matrix decomposition in the channel dimension yields a low-rank feature representation. The low-rank feature representation is mapped to output the multi-cycle recidivism prediction probability.
[0011] Furthermore, the mental encoding representation and the environmental encoding representation are obtained in the following ways: Suppose an individual in time slice The following sequence of mental evolution is The sequence of external environmental factors is ,in Indicates the length of the time step. , These are respectively the mental characteristic dimension and the environmental characteristic dimension; Will and Each input is a separate encoder, and the output is a mental encoding representation. and environment coding representation ,in To unify the latent space feature dimensions after mapping.
[0012] Furthermore, the calculation of cross-sequence attention weights specifically involves: Represented by mental coding Learnable linear transformation Mapped to query matrix Represented by environment code Learnable linear transformations , Mapped to a key matrix Sum matrix ,in , , All parameters are learnable; calculate cross-sequence attention:
[0013] in, It is the dimension of the key vector. It is a scaling factor. Here is the attention weight matrix. .
[0014] Furthermore, the mental evolution sequence for generating integrated environmental factor representations specifically includes: First, the attention output is passed through the projection matrix. Perform a linear mapping, and then associate it with the mental encoding representation. Perform residual connections and layer normalization to generate a mental evolution sequence that incorporates environmental factor representations. As shown in the following formula:
[0015] in, .
[0016] Furthermore, the multi-head attention mechanism is represented using the following logic:
[0017] in, , For the number of attention heads, , , , All are the first The learnable projection matrix corresponding to each size This is the linear transformation matrix after concatenating the results of multi-head attention.
[0018] Furthermore, the prediction method employs a Transformer model, which consists of multiple encoders and decoders stacked together. Each encoder and decoder includes at least one multi-head self-attention module and a feedforward neural network module. Each module is followed by a residual connection module and a layer normalization module. The decoder also includes a cross-sequence attention module, which is directly connected to the encoder's output, for receiving feature representations from the encoder and establishing associations between different feature sources.
[0019] Furthermore, the equidistant downsampling specifically refers to: Along the time dimension with a fixed step size The enhanced fusion mental evolution sequence was downsampled at equal intervals and decomposed into The n interleaved subsequences, where the nth subsequence is... The subsequence is represented as , .
[0020] An electronic device includes a memory and a processor, the memory being used to store a program that supports the processor in executing the above-described multi-cycle recidivism prediction method, the processor being configured to execute the program stored in the memory.
[0021] A storage medium storing a computer program, which, when executed by a processor, performs the steps of the above-described multi-cycle recidivism prediction method.
[0022] The advantages of this invention are: This invention extracts original mental evolution sequence data and time-aligned external environmental factor sequence data from individual behavior in time slices. It uses a dual encoder of the Transformer model to extract deep temporal semantic features from the two sequences respectively. Based on a cross-sequence attention layer, it uses mental encoding representation as query terms and environmental encoding representation as key and value terms to calculate cross-sequence attention weights. The attention output is then residually connected and layer normalized with the mental encoding representation to generate a mental evolution sequence that integrates environmental factor representations. This ensures that the original mental features are not discarded during environmental correction. The corrected sequence is semantically represented as the superposition of "mental ontology" and "environmental correction amount". This not only effectively avoids the gradient vanishing or exploding problem in long sequence prediction, but also assigns higher weights to the key features in the input sequence that are most relevant to recidivism.
[0023] In this invention, the model incorporates all environmental information at the same time slice into the individual's corresponding mental evolution sequence with adaptive weights, realizing dynamic state transfer. This objectively reflects the laws in the real physical world and greatly improves the model's generalization ability in complex social scenarios.
[0024] This invention also introduces a multi-head attention mechanism, which performs attention calculations in parallel in multiple representation subspaces and splices and fuses the outputs of each subspace, enabling the model to capture multi-granular relationships between mental states and environmental factors from different semantic perspectives, thereby enhancing feature representation and relationship modeling capabilities.
[0025] This invention decomposes the corrected sequence into multiple sub-sequences by downsampling, and inputs them into a parallel temporal feature extractor. The extracted temporal features are merged along the channel dimension and then denoised using a non-negative matrix factorization algorithm. Finally, the probabilities of recidivism in the current and future periods are mapped and output. This further uncovers the multi-timescale dynamic patterns contained within and reduces the interference of channel redundancy noise on the prediction results. It effectively filters redundant information and environmental noise at the channel level, ensuring the accuracy and reliability of multi-period prediction results. Attached Figure Description
[0026] Figure 1 This is a schematic diagram of the execution logic of the multi-cycle recidivism prediction method according to Embodiment 1 of the present invention; Figures 2(a) to 2(d) are schematic diagrams of confusion matrices based on different prediction periods in Embodiment 1 of the present invention; Figure 3This is a correlation heatmap based on different prediction periods according to Embodiment 1 of the present invention; Figure 4 This is an ROC curve diagram based on different prediction periods in Embodiment 1 of the present invention; Figure 5 This is a precision-recall curve based on different prediction periods in Embodiment 1 of the present invention. Detailed Implementation
[0027] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below in conjunction with the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0028] The technical solution of the present invention will be further described below with reference to the accompanying drawings and specific embodiments: Example 1 like Figure 1 Specifically, a method for predicting multi-cycle recidivism is disclosed, including the following steps: S1, a representation constructed based on the fusion of environmental factors and mental data related to attention mechanisms: In this embodiment, the original mental evolution sequence data of an individual at different time slices is extracted, and the sequence data of external environmental factors aligned with its time are collected simultaneously. The entire environmental data is then integrated into the individual's mental evolution sequence through an attention mechanism for reconstruction and correction, constructing a mental evolution sequence that integrates environmental factor representations. Specifically, step S1 employs a Transformer model based on a dual-path encoding and cross-attention fusion structure. The Transformer model consists of multiple stacked encoders and decoders. Each encoder and decoder includes at least one multi-head self-attention module (i.e., an independent self-attention sublayer) and a feedforward neural network module (FFN). Each module is followed by a residual connection module and a layer normalization module to ensure the effective preservation of the original input information during deep propagation, while mitigating gradient vanishing, representation degradation, and optimization difficulties during deep network training.
[0029] In a preferred embodiment, the input features are first modeled for temporal dependencies by a multi-head self-attention module, then stably propagated through residual connections and layer normalization, and then transformed nonlinearly by a feedforward neural network module. Finally, the features are output to the next layer through residual connections and layer normalization. The resulting hierarchical processing structure enables the model to enhance its high-order semantic representation capabilities layer by layer.
[0030] Furthermore, the decoder also includes a cross-sequence attention module (i.e., a cross-attention fusion layer or a cross-sequence attention sublayer), which is directly connected to the encoder's output and is used to receive feature representations from the encoder and establish correlations between different feature sources.
[0031] In a preferred embodiment, after the cross-sequence attention module outputs, it is then aggregated and mapped using a standard multilayer perceptron built into the feedforward neural network module to obtain the enhanced sequence representation result. In this embodiment, the model can not only achieve multi-subspace feature extraction within a single layer, but also continuously strengthen the interaction and aggregation between features at different levels during multi-layer stacking, thereby improving the overall representation capability.
[0032] In this embodiment, the encoder first extracts features independently from the original mental evolution sequence and the external environmental factor sequence, and then performs conditional fusion of the two sequences in the cross-sequence attention module of the decoder. During the fusion stage, mental encoding is used as the query term, and environmental encoding is used as the key and value term. The conditional influence weights of environmental factors on mental states at each time step are calculated, and a mental evolution fusion sequence carrying environmental correction information is output. The specific process of S1 is as follows: S1.1, Obtain the original mental evolution sequence data of an individual at different time slices, as well as the sequence data of external environmental factors aligned with its time.
[0033] In a preferred embodiment, taking the multi-period prediction of recidivism tendencies of specific individuals as an example, relevant data about the offender is extracted as raw mental evolution data, including at least historical judgment records and criminal behavior characterization. Criminal behavior characterization refers to the legal definition and classification of the behavior of a criminal suspect or defendant to determine whether their behavior constitutes a crime and what kind of crime it constitutes. Relevant data about the external environment is also extracted as external environmental factor data, including at least regional environmental protection policies and notices of special governance actions. Individual behaviors are then segmented by time slices (e.g., time slice 1, time slice 2, time slice 3) to extract corresponding raw mental evolution sequence data and external environmental factor sequence data.
[0034] S1.2, the original mental evolution sequence and the external environmental factor sequence are input into their respective independent encoders, and the deep temporal semantic features of their respective sequences are extracted through a self-attention mechanism to obtain mental encoding representation and environmental encoding representation.
[0035] Specifically, let's assume an individual is in a time slice The following sequence of mental evolution is The sequence of external environmental factors is ,in Indicates the length of the time step. , These are respectively the mental characteristic dimension and the environmental characteristic dimension; Will and Each input is a separate encoder, and the parameters between the two encoders are not shared; mental sequence The corresponding encoder models the intrinsic evolution of an individual's mental state over time using a self-attention mechanism, extracts its deep temporal semantic features, and outputs a mental encoding representation. External environmental factor sequence The corresponding encoder extracts the dynamic change patterns of external environmental factors in the time dimension and their association with the context through a self-attention mechanism, outputting an environment-encoded representation. ,in To unify the latent space feature dimensions after mapping.
[0036] S1.3, the cross-sequence attention module uses mental encoding representation as query term and environmental encoding representation as key and value term, calculates cross-sequence attention weight, and performs residual connection and layer normalization on the attention output and mental encoding representation to generate a mental evolution sequence that integrates environmental factor representation.
[0037] Specifically, in the cross-sequence attention module of the decoder, it is represented by mental encoding. Learnable linear transformation Mapped to query matrix Represented by environment code Learnable linear transformations , Mapped to a key matrix Sum matrix ,in , , All parameters are learnable and adaptively optimized through end-to-end training. Cross-sequence attention is calculated using the following logic:
[0038] in, It is the dimension of the key vector. It is a scaling factor used to prevent the dot product result from being too large, causing the Softmax function to enter the gradient saturation region and improving the stability of model training. Here is the attention weight matrix. , The attention weight distribution of each time step of the mental sequence to the features of each time step of the environmental sequence is measured, which is used to measure the influence of different environmental states on the current mental state.
[0039] Furthermore, to ensure alignment between the cross-attention output and the feature dimensions of the original mental representation, this embodiment uses a projection matrix. Perform a linear mapping across attentional outputs, and then compare them with the original mental representation. Perform residual connections and layer normalization to generate a mental evolution sequence that incorporates environmental factor representations. As shown in the following formula:
[0040] in, This represents the mental evolution and fusion sequence after dynamic correction by environmental factors. In this embodiment, a corrected mental evolution sequence is generated through residual connections and layer normalization. On the one hand, it can ensure that the original mental features are not discarded during the environmental correction process, so that the corrected sequence is semantically represented as the superposition of "mental ontology" and "environmental correction amount"; on the other hand, the skip connection method provides a shorter path for gradient propagation, which helps to alleviate the gradient vanishing and optimization difficulties that may occur during the training of deep networks, while layer normalization further improves the stability of feature distribution, speeds up model convergence and enhances generalization ability.
[0041] In this embodiment, the mental evolution sequence carrying environmental correction information is obtained through steps S1.1-S1.3. This serves as the input for step S1.4.
[0042] This embodiment does not simply concatenate or weight the mental and environmental information, but rather uses a data-driven cross-attention allocation method to enable the model to adaptively learn "what environmental factors act on which mental state at which time step and with what intensity." In this way, the model integrates all environmental information within the same time slice into the individual's corresponding mental evolution sequence with adaptive weights, achieving dynamic state transfer. This reconstruction and correction mechanism objectively reflects the laws of the real physical world: for example, in a negative stimulus environment, the model may learn that certain high-risk environmental factors have higher attention weights on mental states at specific times, thereby accelerating the individual's evolution towards a high-risk mental state; while in a positive intervention environment, some environmental features may exhibit inhibitory effects, delaying or weakening the risk evolution trend. When multiple environmental factors coexist, the model can also adaptively characterize their combined effects of enhancement, weakening, or mutual cancellation through the competition and allocation of attention weights, thereby achieving fine-grained dynamic modeling of the individual's mental evolution process.
[0043] Step S1.4, Multi-head attention mechanism enhances feature representation: To further enhance the modeling capability of fusing mental and environmental sequences, this embodiment introduces a multi-head attention mechanism based on the aforementioned cross-sequence attention mechanism. Attention is independently computed and concatenated in multiple subspaces. By performing attention computation in parallel across multiple representation subspaces and concatenating the outputs of each subspace, the model can simultaneously capture multi-granular relationships between mental states and environmental factors from different semantic perspectives, thereby enhancing feature representation and relationship modeling capabilities.
[0044] Specifically, a multi-head attention mechanism is employed for the mental evolution fusion sequence. Attention is computed in parallel across multiple representation subspaces and then concatenated and fused. This is followed by processing through a feedforward neural network, residual connections, and layer normalization to obtain an enhanced fused mental evolution sequence. The multi-head attention mechanism is represented by the following logic:
[0045] in, , For the number of attention heads, , , , All are the first The learnable projection matrix corresponding to each size This is the linear transformation matrix after concatenating the multi-head attention results, used to remap the multi-head features to a unified latent space. In this embodiment, by mapping the input to multiple different representation subspaces, each attention head can extract associated features from the sequence from different perspectives, and after concatenation, form a richer joint representation, thereby improving the model's ability to recognize complex patterns.
[0046] Compared to traditional temporal modeling methods using single-head attention or fixed local receptive fields, this embodiment employs a multi-head attention enhancement structure that can simultaneously mine potential dependencies within a sequence across multiple subspaces. This effectively balances local detail changes with global trend information, and maintains the stability of deep feature propagation through residual connections and layer normalization. Consequently, the model can more accurately focus on key temporal information highly relevant to the target task, enhancing feature extraction and predictive capabilities under complex influencing factors.
[0047] Furthermore, during the model training phase, existing supervised learning methods can be used to perform end-to-end optimization of the aforementioned multi-head attention enhancement structure. Preferably, when the model output is a discrete label such as recidivism or risk level, the task can be treated as a classification task and trained using either the cross-entropy loss function or the weighted cross-entropy loss function. When the model output is a recidivism risk score, a continuous risk index, or a future periodic risk intensity value, the task can be treated as a regression task and optimized using either the mean squared error loss function, the mean absolute error loss function, or the Huber loss function. For model parameter updates, the Adam or AdamW optimizer can be used for optimization updates, combined with learning rate warm-up, decay scheduling, Dropout, and early stopping strategies to improve model training stability and generalization ability.
[0048] S2, based on multi-channel feature extraction and denoising prediction: After obtaining the enhanced fused mental evolution sequence, to further explore the multi-timescale dynamic patterns contained within and reduce the interference of channel redundancy noise on the prediction results, this embodiment also constructs a multi-period prediction module based on multi-channel feature extraction and denoising. This module sequentially performs time dimension decomposition, sub-sequence temporal feature extraction, channel mixing, non-negative matrix factorization denoising, and linear mapping prediction steps on the fused mental evolution sequence, forming a complete processing link from the enhanced fused representation to the multi-period re-crime prediction result. Specifically, the specific process of S2 is as follows: S2.1, the enhanced fusion mental evolution sequence is downsampled at equal intervals along the time dimension and decomposed into multiple interleaved subsequences.
[0049] Considering that sequences simultaneously contain short-term fluctuations, local mutations, and long-term dependencies across time spans, to avoid computational redundancy and feature coupling issues arising from directly modeling the complete long sequence, specifically, we first model along the time dimension with a fixed step size. The enhanced fusion mental evolution sequence was downsampled at equal intervals and decomposed into The n interleaved subsequences, where the nth subsequence is... The subsequence is represented as , The above downsampling decomposition method splits the original sequence into multiple shorter subsequences according to different time phases, and each subsequence retains the local dynamic pattern corresponding to a specific sampling interval on the original time axis.
[0050] In a preferred embodiment, such as Figure 1 by For example, the original time series can be decomposed into , and Three alternating subsequences, thus corresponding to respectively Figure 1The subsequences are channel 1, channel 2, and channel 3.
[0051] S2.2, each subsequence is input into an independent temporal feature extractor for time dependency modeling to obtain the temporal feature representation of each subsequence.
[0052] After the downsampling decomposition is completed, each subsequence is input into its own independent time-series feature extractor for time dependency modeling, so as to extract the local fluctuation features, potential periodic features and long-range dependency information within each subsequence as the time feature representation of each subsequence.
[0053] In a preferred embodiment, the temporal feature extractor employs a Temporal Convolutional Network (TCN), which consists of multiple dilated causal convolutional layers and residual blocks. The dilated causal convolutional layers can exponentially expand the receptive field with increasing network layer count while maintaining temporal causality, thereby efficiently capturing long-range temporal dependencies with low computational complexity. The residual blocks are used to enhance the training stability of deep networks and alleviate gradient degradation problems. The first... After the subsequences are extracted by the time-series feature extractor, the corresponding time feature representations are obtained. , Indicates the first The temporal features corresponding to each subsequence.
[0054] S2.3, the temporal feature representations of each subsequence are linearly concatenated according to the original time index to obtain the channel feature representation of mixed multi-timescale information.
[0055] like Figure 1 As shown, the temporal features corresponding to each subsequence are interleaved, rearranged, and spliced according to the original time index relationship to restore the feature arrangement order consistent with the original time axis, thereby obtaining a channel feature representation with mixed multi-timescale information. This embodiment re-aligns and fuses the local time patterns extracted from different interleaved subsequences, so that the resulting representation simultaneously contains complementary information under different time phases, enhancing the model's overall expressive ability for complex temporal patterns.
[0056] S2.4, perform nonnegative matrix decomposition to denoise the channel feature representation in the channel dimension to obtain a low-rank feature representation.
[0057] Considering the potential redundancy and noise interference in the channel dimension of the feature matrix after channel mixing, this embodiment further introduces Non-negative Matrix Factorization (NMF) technology for low-rank denoising in the channel dimension. Since NMF imposes a non-negative constraint on the decomposition result, it can represent the original channel features as a combination of several non-negative basis vectors with clear semantics. While preserving the main structural information, it effectively suppresses redundant channel responses and random noise components, thereby improving the compactness, interpretability, and robustness of the feature representation. After NMF denoising, a low-noise, low-rank feature representation is obtained.
[0058] In a preferred embodiment, the nonnegative matrix factorization denoising performs a low-rank decomposition of the channel feature representation in the channel dimension, and the rank of the decomposition is adaptively determined by cross-validation or singular value energy ratio.
[0059] S2.5 maps the low-rank feature representation and outputs the multi-period re-offending prediction probability.
[0060] Finally, the denoised low-rank features from step S2.4 are input into the linear prediction layer for mapping, outputting a multi-period re-crime prediction probability vector. ,in Indicates the number of prediction periods. Indicates the first The probability of a recidivism occurring within a prediction period. .
[0061] In this embodiment, step S2 further enables multi-timescale dynamic pattern extraction, channel redundancy suppression, and noise reduction based on the enhanced fusion mental evolution sequence. For example, when a predicted object exhibits significant abnormal behavioral fluctuations in the short term and shows a continuous risk accumulation trend over a longer time span, different interleaved subsequences can retain local dynamic information at their respective time phases. After extraction by TCN, these information are then uniformly recombined to simultaneously reflect both short-term abnormal patterns and long-term trends. After NMF denoising, the model can more stably extract core features related to recidivism and output risk probabilities for multiple future periods, improving the accuracy and stability of the prediction results.
[0062] Furthermore, in the model evaluation phase of this study, to scientifically quantify the performance evolution of the model over time, this embodiment divides the time series into several progressive prediction cycles. The specific business mapping is defined as follows: Cycle1 (First Cycle): This is the initial baseline stage, corresponding to the static single-point historical data of the target individual "before imprisonment" (at this time, the sequence features have not yet been developed).
[0063] Cycle2 (Second Cycle): This is the initial evolutionary stage, which integrates internal data from the individual's "initial and middle stages of imprisonment" as well as preliminary external environmental factors.
[0064] Cycle3 (Third Cycle): This is a key evolutionary stage, corresponding to a long sequence of mental and environmental interaction data linked to the individual's "release from prison".
[0065] Cycle4 (Fourth Cycle): This is the complete validation phase, which combines multi-dimensional long-sequence data spanning time and space throughout the entire process of an individual's reintegration into society.
[0066] Cycle 5 (Fifth Cycle): This is a longer-term trend prediction stage, which uses the vast historical features accumulated in the previous four cycles to predict the evolutionary probability of an individual in a longer future stage (such as long-term follow-up after dissemination of teachings).
[0067] In practical validation, the model demonstrated excellent predictive ability. The following conclusions can be intuitively drawn through four visualization analyses of the test set: (1) Confusion matrix performance: As shown in Figures 2(a) to 2(d), the number of correctly classified samples by the model increases significantly as the prediction time step progresses. For example, in the earlier cycle (Cycle 1), the confusion matrix shows that the true negative (TN) is 482 and the true positive (TP) is 299. At this time, there are still a certain number of false positives (FP=43) and false negatives (FN=176). However, when the prediction progresses to the later cycles (such as Cycle 3 and Cycle 4), the number of correctly classified samples on the diagonal increases significantly. In Cycle 4, TN reaches 496 and TP increases to 369. The number of misclassifications decreases significantly, indicating that the model becomes more accurate with the accumulation of data.
[0068] (2) Correlation heatmap representation: such as Figure 3 As shown, the correlation coefficient between predicted and actual values over multiple periods continuously approaches 1 as the period increases. The heatmap shows that the colors of the predicted and actual column regions continuously deepen, proving that the mixed features of environmental factors and time channels can highly fit the actual behavioral evolution patterns.
[0069] (3) ROC curve performance: such as Figure 4 As shown, this embodiment plots four ROC curves for Cycle 2 to Cycle 5. As the cycle progresses, the ROC curves clearly move towards the ideal upper left corner (i.e., FPR=0, TPR=1), with Cycle 5 exhibiting the highest AUC value. This demonstrates that in multi-cycle sequence prediction, utilizing data from more stages continuously enhances the model's classification performance.
[0070] (4) Performance of the PR (Precision-Recall) curve: such as Figure 5The multi-cycle PR curves shown demonstrate that even with a high recall rate, later cycles (such as Cycle 4 and Cycle 5) can still maintain extremely high precision.
[0071] Applying the multi-cycle recidivism prediction method proposed in this embodiment to actual business operations: when predicting crime behavior in a single cycle using only pre-imprisonment data (i.e., the initial state Cycle 1), the accuracy rate reaches 78.10%; if data from the beginning of imprisonment and during imprisonment are integrated for sequential prediction (i.e., advancing to Cycle 2), the accuracy rate jumps to 81.50%; after multi-cycle prediction throughout the beginning of imprisonment, during imprisonment, and upon release (i.e., advancing to Cycle 3), the accuracy rate further breaks through to 84.10%; finally, when comprehensively combining multi-dimensional and multi-node data from the beginning of imprisonment, during imprisonment, upon release, and subsequent resettlement and rehabilitation (i.e., the complete state Cycle 4), the model prediction accuracy climbs to a maximum of 86.50%. This progressive and accurate prediction data fully verifies the reliability of the invention, the robustness of the algorithm, and its extremely high practical application value.
[0072] Example 2 An apparatus includes a memory and a processor, the memory being used to store a program that supports the processor in executing the multi-cycle recidivism prediction method of Embodiment 1, the processor being configured to execute the program stored in the memory.
[0073] Example 3 A storage medium storing a computer program, which, when executed by a processor, performs the steps of the multi-period recidivism prediction method in Embodiment 1.
[0074] It should be noted that the logic and / or steps represented in the flowchart or otherwise described herein can be considered as a ordered list of executable instructions for implementing logical functions. This can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus, or device (such as a computer-based system, a processor-based system, or other system that can fetch and execute instructions from, or in conjunction with, such an instruction execution system, apparatus, or device). For the purposes of this specification, "computer-readable medium" can be any means that can contain, store, communicate, propagate, or transmit programs for use by, or in conjunction with, an instruction execution system, apparatus, or device. More specific examples (a non-exhaustive list) of computer-readable media include: electrical connections having one or more wires (electronic devices), portable computer disk drives (magnetic devices), random access memory (RAM), read-only memory (ROM), erasable and editable read-only memory (EPROM or flash memory), fiber optic devices, and portable optical disc read-only memory (CD-ROM). Alternatively, the computer-readable medium may be paper or other suitable media on which the program can be printed, since the program can be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, interpreting, or otherwise processing as necessary, and then stored in a computer memory.
[0075] It should be understood that various parts of the present invention can be implemented in hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented in software or firmware stored in memory and executed by a suitable instruction execution system. If implemented in hardware, as in another embodiment, it can be implemented using any one or a combination of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.
[0076] In the description of this specification, references to terms such as "in a preferred embodiment," "preferred," "in this embodiment," "specific," or "furthermore," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of the invention. In this specification, illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.
[0077] The above embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for predicting multi-cycle recidivism, characterized in that, Includes the following steps: Acquire raw mental evolution sequence data of individuals at different time slices, as well as sequence data of external environmental factors aligned with their time; The original mental evolution sequence and the external environmental factor sequence are respectively input into their respective independent encoders. The deep temporal semantic features of each sequence are extracted through a self-attention mechanism to obtain mental encoding representation and environmental encoding representation. Using environmental encoding representations as key and value terms, cross-sequence attention weights are calculated, and attention outputs are residually connected and layer normalized with mental encoding representations to generate mental evolution sequences that integrate environmental factor representations. A multi-head attention mechanism is introduced to compute attention in parallel in multiple representation subspaces and splice and fuse them. Then, through feedforward neural networks, residual connections and layer normalization processing, an enhanced fused mental evolution sequence is obtained. The enhanced fusion mental evolution sequence is sequentially subjected to time dimension decomposition, temporal feature extraction, linear concatenation, nonnegative matrix decomposition for denoising, and linear mapping prediction to output the multi-cycle re-crime prediction probability.
2. The method for predicting multi-period recidivism according to claim 1, characterized in that, The sequential execution of time dimension decomposition, temporal feature extraction, linear concatenation, non-negative matrix factorization for denoising, and linear mapping prediction specifically includes the following steps: The enhanced fusion mental evolution sequence is downsampled at equal intervals along the time dimension and decomposed into multiple interleaved subsequences; Each subsequence is input into an independent temporal feature extractor for temporal dependency modeling to obtain the temporal feature representation of each subsequence; The temporal feature representations of each subsequence are linearly concatenated according to the original time index to obtain a channel feature representation that mixes multiple time scales; Denoising the channel feature representation by nonnegative matrix decomposition in the channel dimension yields a low-rank feature representation. The low-rank feature representation is mapped to output the multi-cycle recidivism prediction probability.
3. The method for predicting multi-period recidivism according to claim 1, characterized in that, The mental encoding representation and the environmental encoding representation are obtained through the following methods: Suppose an individual in time slice The following sequence of mental evolution is The sequence of external environmental factors is ,in Indicates the length of the time step. , These are respectively the mental characteristic dimension and the environmental characteristic dimension; Will and Each input is a separate encoder, and the output is a mental encoding representation. and environment coding representation ,in To unify the latent space feature dimensions after mapping.
4. The method for predicting multi-period recidivism according to claim 3, characterized in that, The calculation of cross-sequence attention weights is specifically as follows: Represented by mental coding Learnable linear transformation Mapped to query matrix Represented by environment code Learnable linear transformations , Mapped to a key matrix Sum matrix ,in , , All parameters are learnable; calculate cross-sequence attention: in, It is the dimension of the key vector. It is a scaling factor. Here is the attention weight matrix. .
5. The method for predicting multi-period recidivism according to claim 4, characterized in that, The mental evolution sequence that generates and integrates environmental factors is specifically as follows: First, the attention output is passed through the projection matrix. Perform a linear mapping, and then associate it with the mental encoding representation. Perform residual connections and layer normalization to generate a mental evolution sequence that incorporates environmental factor representations. As shown in the following formula: in, .
6. The method for predicting multi-period recidivism according to claim 5, characterized in that, The multi-head attention mechanism can be represented using the following logic: in, , For the number of attention heads, , , , All are the first The learnable projection matrix corresponding to each size This is the linear transformation matrix after concatenating the results of multi-head attention.
7. The method for predicting multi-period recidivism according to claim 1, characterized in that, The prediction method uses a Transformer model, which consists of multiple encoders and decoders stacked together. Each encoder and decoder includes at least one multi-head self-attention module and a feedforward neural network module. Each module is followed by a residual connection module and a layer normalization module. The decoder also includes a cross-sequence attention module, which is directly connected to the encoder's output, for receiving feature representations from the encoder and establishing associations between different feature sources.
8. The method for predicting multi-period recidivism according to claim 2, characterized in that, The equidistant downsampling specifically refers to: Along the time dimension with a fixed step size The enhanced fusion mental evolution sequence was downsampled at equal intervals and decomposed into The n interleaved subsequences, where the nth subsequence is... The subsequence is represented as , .
9. An electronic device, comprising a memory and a processor, characterized in that, The memory is used to store a program that supports the processor in executing the multi-cycle recidivism prediction method according to any one of claims 1 to 8, the processor being configured to execute the program stored in the memory.
10. A storage medium storing a computer program, characterized in that, The computer program, when run by a processor, performs the steps of the multi-cycle recidivism prediction method according to any one of claims 1 to 8.