ccrl
English | 中文说明
ccrl is a Python package implementing the method described in the paper:
Haoze Wu, Shisheng Zhong, Minghang Zhao, Xuyun Fu, Yongjian Zhang, Song Fu, "Continual contrastive reinforcement learning: Towards stronger agent for environment-aware fault diagnosis of aero-engines through long-term optimization under highly imbalance scenarios", Advanced Engineering Informatics, DOI: 10.1016/j.aei.2025.103297.
- Repository:
https://github.com/haozewu/ccrl - Paper DOI:
10.1016/j.aei.2025.103297
The package is published as ccrl on PyPI. This repository contains its source code and documentation.
The CCRL pipeline implemented here includes:
- LSTM autoencoder pretraining
- contrastive representation learning
- D3QN-based type identification
- imbalanced reward design
- repeated imbalanced cross-validation
Installation
pip install ccrl
For local development:
pip install .
Quick Start
from ccrl import CCRLConfig, run_ccrl_diag
config = CCRLConfig()
config.data.pretrain_label = "normal"
result = run_ccrl_diag(
data_path="data/fault_dataset.pkl",
config=config,
repeats=1,
seed=2024,
log_dir="logs",
)
print(result.mean_f1, result.std_f1)
CLI
ccrl --data data/fault_dataset.pkl --repeats 1 --seed 2024 --log-dir logs
Input Data Format
The input file must be a pickle containing a dict[str, samples].
- each key is a class label, such as
normal,fault_a, orbearing_outer - each value must be convertible to a 3D array with shape
(num_samples, seq_len, feature_dim) - all classes must share the same
seq_lenandfeature_dim
Minimal example:
{
"normal": [
[[0.1, 1.2], [0.2, 1.1], [0.3, 1.0]],
[[0.0, 1.0], [0.1, 0.9], [0.2, 0.8]],
],
"fault_a": [
[[1.2, 0.1], [1.1, 0.2], [1.0, 0.3]],
[[0.9, 0.0], [0.8, 0.1], [0.7, 0.2]],
],
"fault_b": [
[[0.5, 2.0], [0.6, 1.9], [0.7, 1.8]],
[[0.4, 2.1], [0.5, 2.0], [0.6, 1.9]],
],
}
This example has:
num_classes = 3seq_len = 3feature_dim = 2
Save it as pickle:
import pickle
data = {
"normal": [
[[0.1, 1.2], [0.2, 1.1], [0.3, 1.0]],
[[0.0, 1.0], [0.1, 0.9], [0.2, 0.8]],
],
"fault_a": [
[[1.2, 0.1], [1.1, 0.2], [1.0, 0.3]],
[[0.9, 0.0], [0.8, 0.1], [0.7, 0.2]],
],
"fault_b": [
[[0.5, 2.0], [0.6, 1.9], [0.7, 1.8]],
[[0.4, 2.1], [0.5, 2.0], [0.6, 1.9]],
],
}
with open("data/fault_dataset.pkl", "wb") as f:
pickle.dump(data, f)
Configuration Notes
from ccrl import CCRLConfig
config = CCRLConfig()
config.data.class_order = ["normal", "fault_a", "fault_b"]
config.data.pretrain_label = "normal"
config.data.test_samples_per_class = 2
class_ordercontrols label encoding order and reporting orderpretrain_labelchooses which class is used for AE pretrainingtest_samples_per_classcontrols how many samples per class are drawn into the test split
Notes
This repository is the source distribution of the ccrl package, intended for research, reproduction, and further development. It is not an official release from the paper authors unless explicitly stated otherwise. Because this codebase has been extracted, refactored, and generalized for reuse, it may contain engineering adaptations, simplifications, or implementation mistakes. If anything in this repository conflicts with the paper, the original paper should be treated as the authoritative reference.
License
This project is released under the Apache License 2.0. See LICENSE.
Metadata
Release files for ccrl 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| ccrl-0.1.0.tar.gz | 17.1 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ccrl-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 34.6 kB
Release files / ccrl-0.1.0.tar.gz
| Download URL | ccrl-0.1.0.tar.gz |
|---|---|
| Size | 17.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9bbc37efe2454b0703bd2c2b0b6ef358c79397c548d52087bc88a7af0713e922
|
|
BLAKE2b-256 checksum How to use checksums |
d70fb18bbe2196c2f60f58c9640e07488fc9d9afea6d82ae20285ea4fd540b53
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.11
|
Release files / ccrl-0.1.0-py3-none-any.whl
| Download URL | ccrl-0.1.0-py3-none-any.whl |
|---|---|
| Size | 17.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f6431bdd926d805cd8dea4e815c2fc32a0bb4d4d4680fb5332c86b880fea73af
|
|
BLAKE2b-256 checksum How to use checksums |
8fb3d0b8775535bbcc993486d26544f851bcee1b2356f88f32db7279dd848e2d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.11
|
Security for ccrl 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.