Skip to main content

candleprep

CPU-only synthetic candle corruption and verified repair-instruction datasets. Python 3.11+, MIT licensed. The core uses the standard library and imports without Torch, Transformers, pandas, a model, or a GPU.

Installation

Release 0.2.0 adds CandleDataset and automatic source downloading. After that release is uploaded to PyPI:

python -m pip install "candleprep[notebook]==0.2.0"

The optional notebook extra supplies pandas, matplotlib, IPython, datasets, and tqdm for display/conversion. It does not install a CUDA/PyTorch training stack. For CPU preparation alone, install candleprep==0.2.0 without extras. A source checkout can be installed with python -m pip install ..

Prepare and inspect in a few calls

from candleprep import CandleDataset

dataset = CandleDataset.prepare(output_dir="generated_data/v1", seed=4820)
dataset.display_samples(rows=5)
dataset.display_labels(rows=5)

No local source CSV is required. prepare() downloads the original TVC_GOLD, 360.csv from a pinned NLP-proj5 commit. Its SHA-256 is aa89b7a05abad8f3ee718c65607169a547ec215370cde15cfe98f8c3a895633c. The CSV is cached as output_dir/source.csv. Matching generated data is reused after source/settings/artifact verification; mismatches raise an error rather than silently overwriting a run. First use requires internet; verified caches can be reused offline.

Defaults are 10,000 train / 1,000 validation / 2,000 test examples and four source rows per window. Override train_size, validation_size, test_size, and window_size for a different dataset, using a different output_dir. An explicit source="path/to/custom.csv" still supports other local inputs.

display_samples() shows first/middle/last groups for both original and corrupt data. display_labels() executes positive labels and displays reconstruction against the oracle's original, alongside whole-window omission decisions. Display methods import their optional dependencies only when called.

Use the records for training and evaluation

training_records = dataset.records("train")  # only id, input, target
examples = dataset.examples(count=5)         # fixed validation cases
# predictions = ... model-generated JSON strings for dataset.records("test")
# report = dataset.evaluate(predictions, split="test")

candleprep.task.user_text(record) formats the static repair task plus corrupted CSV only. JSON scoring lives in candleprep.evaluation; it does not execute tools. dataset.evaluate() also returns category/composition breakdowns. The separately called dataset.execute_predictions(predictions, destination) is the final tool execution/reconstruction demonstration. Generation, LoRA, GPU management, and Trainer remain in the notebook.

The lower-level 0.1.0 API and CLI remain available:

from candleprep.datasets import generate_dataset, load_jsonl
generate_dataset("path/to/source.csv", "generated_data/custom")
python -m candleprep path/to/source.csv --output generated_data/custom
python -m candleprep --version

Data and output contract

Each input is raw CSV with a header and four consecutive original records. time, open, high, low, close, and Volume are required. ROC is optional: the source has 118 existing ROC blanks in 20,330 records. The original file is never cleaned in place or modified. Baseline audit found unique, increasing timestamps and no basic OHLC/volume violations. UTC offsets are explicit; normal irregular market intervals are allowed.

Labels contain exactly two fields:

{"recoverable": true, "operations": ["repair_number_spelling", "parse_number_words"]}
{"recoverable": false, "operations": []}

Negative examples stay in supervised data. A negative decision means omit the complete window during cleaning, including all its rows and fields.

train.jsonl, validation.jsonl, and test.jsonl contain only id, input, and target. IDs and targets are not prompt features. The corresponding *.references.jsonl files contain privileged originals, source row identities, history, and evaluation metadata. Never feed those sidecars to the model. manifest.json records the source hash, seed, exact counts, recipes, exclusions, operation coverage, source boundaries, and hashes of the exported files.

Split source records chronologically 70/10/20 before constructing non-overlapping windows. Every derivative of a source window stays in its partition. A fixed seed reproduces the same artifacts. Duplicate model-visible inputs and conflicting labels are rejected and counted. Lexical recipes receive substantial coverage; the manifest reports actual class proportions rather than assuming balance.

Supported behavior

Category Supported examples Information loss / unsupported recovery
Syntactic Remove declared ? @ ~ noise; repair doubled decimal points Arbitrary digits replaced, deleted, or transposed; lost decimal
Formatting $, USD/contracts/percent suffixes, decimal comma, explicit-offset alternate dates, whitespace, scientific notation Thousands grouping and ambiguous locale conventions
Structural Columns reordered with headers; cyclic row rotations with one identifiable timestamp; consistent comma/semicolon/pipe dialect Unknown cell swaps, lost/split/merged field boundaries
Semantic Explicit cents-to-base-unit scaling Unmarked sign/scale/outlier/context changes
Completeness Normalize optional missing-value representations Missing required values, truncated values, lost columns
Integrity Exact duplicate records by timestamp; chronological sorting Conflicting duplicates, overwritten timestamps, lost rows
Lexical English cardinal/sign/fractional forms, currency words, mixed digits/words, conjunctions, hyphens, case, spacing, controlled spelling variants Ambiguous/unsupported spellings, destroyed fractional content

English integers have magnitude below 10^15. Fractional parts use individually spoken digits, preserving exact decimal meaning. Examples include hundrad, hundrd, fify-three, fourty, and unique one-edit substitutions, insertions, deletions, transpositions, or repetitions. Spelling correction and parsing remain separate operations. The decimal-comma rule never assumes thousands separators. Alternate dates use DD/MM/YYYY HH:MM:SS%z; ISO timestamps preserve UTC instants.

All public recovery functions accept and return the same CSV text payload. Validator functions return unchanged text on success and raise RecoveryError on failure. Detection alone never creates an original value. detect_outliers currently checks domain constraints, not statistical anomaly detection.

Oracle and evaluation

The oracle deliberately sees originals and full corruption history. Public recovery tools receive only corrupted text and the fixed schema. The planner checks short recipe subsequences in reverse-history and declared dependency order, shortest first, with lexical operation-name tie-breaking. Every positive plan reconstructs the complete reference under exact Decimal values, UTC instants, row order, and original optional missingness. Unsupported recovery is distinct from programming errors, which propagate and stop generation.

This is a bounded supported-tool policy, not proof that no possible repair algorithm exists. Provenance marks information-destroying cases for omission. The model cannot necessarily identify a plausible numeric error from the input alone; that uncertainty must be analyzed in the experiment.

The CPU evaluation module implements four independent metrics: recoverability accuracy, ordered-operation accuracy on oracle-positive examples, strict full-answer accuracy, and format validity. Routine scoring never executes tools. A separate explicit final section executes model-predicted plans and reports reconstruction, false omissions, negative repair attempts, execution failures, and retained coverage.

Project scope

proj5.ipynb retains the starter's Transformers/PEFT Mistral-7B framework and contains visible training and experiment presentation. There is no small-training prerequisite: it trains the configured primary rank directly from offline labels. Five fixed validation cases are compared before and after SFT. Separate rank 8/16/32 validation and full-test jobs are currently enabled in notebook settings. Choose the primary rank using validation results, then report the test comparison. No model improvement or TAMU compatibility is claimed until actually measured.

The repository includes this library, its tests, the notebook, and the original CSV. Generated datasets, model artifacts, environments, and local logs are excluded by .gitignore. The notebook can download the original and generate its dataset automatically, including when run without a repository clone.

Metadata

Release files for candleprep 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for candleprep 0.2.0
File Size Uploaded Provenance Actions
candleprep-0.2.0.tar.gz 33.1 kB Without provenance Details for candleprep-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for candleprep 0.2.0
File Interpreter ABI Platform Actions
candleprep-0.2.0-py3-none-any.whl Python 3 none any Details for candleprep-0.2.0-py3-none-any.whl

Total release size: 72.6 kB

Release files / candleprep-0.2.0.tar.gz

Download URL candleprep-0.2.0.tar.gz
Size 33.1 kB
Tags Source
SHA-256 checksum
How to use checksums
d04cb9df60b616b8f252f9c50075a388528344a03a5133d02ac2128f49e2ad0e
BLAKE2b-256 checksum
How to use checksums
9ede9508ab10093689d39c0cd563c4d51ca15f3828a00b0289cd8968c1f007a3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9

Release files / candleprep-0.2.0-py3-none-any.whl

Download URL candleprep-0.2.0-py3-none-any.whl
Size 39.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7d9d7afef8ac2802c41f82f6b2f7c5445255dda44af64238f3c7331381adcc69
BLAKE2b-256 checksum
How to use checksums
6382e62a3273de940885004b1d7d0b5507f6862817a6fb766dda8421f5fa4e79
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9

Security for candleprep 0.2.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.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page