# Dataset strategy and training decision

**Status:** Active strategy — Drebin-215 fallback  
**Decision date:** 2026-11-09  
**Repository:** `navyask911/safemobile-Antivirus-Trained-ML-Data-of-Android-malware`

## Executive decision

The Android model's input contract remains the original, ordered **215-feature Drebin schema**. Neither McNdroid nor MH-1M currently provides a complete, unambiguous representation of that schema from its published processed feature matrix. The mapping attempts therefore remain fail-closed and neither dataset is used to train or promote the Android model.

The scheduled `.github/workflows/continuous-learning.yml` workflow now uses the pinned, real Drebin-215 feature CSV as its fallback source. It refuses synthetic data, checks the frozen schema and reference holdout, trains and validates a candidate, and applies the existing **97.45% fixed-holdout TFLite accuracy gate**. This workflow uploads a validation artifact only; it does **not** publish a model release or replace the currently deployed model.

The event-driven `.github/workflows/train-and-export.yml` remains the path for gated updates from pre-extracted 215-feature rows supplied by the Main App.

## Why modern processed matrices are not active training sources

### McNdroid — 100 features unavailable in the selected matrix

The inspected 2013 McNdroid source has:

- 501,525 entries in its original `vocab.json`.
- 2,390 selected columns in `selector_meta.json`.
- A 2013 training matrix of 77,240 × 2,390 and test matrix of 19,310 × 2,390.

The selector metadata provides the original vocabulary indices represented by those 2,390 matrix columns. After applying explicit category-aware aliases and translating those original indices to actual selected matrix positions, **115 of the 215 canonical features** could be resolved. **100 features remain unavailable in the selected matrix**: 29 names exist in the original vocabulary but were removed by feature selection, and 71 have no corresponding token in the inspected original vocabulary.

The mapper stops rather than reusing a different column, padding the feature vector, or synthesizing values. The verified diagnostic run is [workflow 42607398000](https://github.com/navyask911/safemobile-Antivirus-Trained-ML-Data-of-Android-malware/actions/runs/42607398000).

### MH-1M — 74 features unresolved

The processed MH-1M matrix exposes 23,247 named columns: 22,394 API-call indicators, 407 intent indicators, 232 opcode indicators and 214 permission indicators.

The verified coverage inspection found:

- **141** Drebin features uniquely resolved.
- **70** canonical features with no exact source feature match.
- **4** canonical features whose class tokens are ambiguous because one source API-owner token could populate multiple distinct Drebin names.
- **74 unresolved features in total**.

The mapper supports only documented category-specific normalizations and exact API owner/method matching. It does not treat an importance-ranked top-215 list as a substitute for the app's canonical schema. Extraction refuses to run while any feature is missing or ambiguous. See [workflow 42617044685](https://github.com/navyask911/safemobile-Antivirus-Trained-ML-Data-of-Android-malware/actions/runs/42617044685).

### Consequence

Neither matrix can currently produce the exact 215 inputs the Android app expects. Reordering, truncating, filling absent features with zeros, guessing semantic aliases or selecting the top 215 by importance would change the meaning of the model inputs. These approaches are prohibited.

McNdroid and MH-1M may remain isolated research/diagnostic datasets. They are not active production model-training inputs.

## Active path A — Continue with the Drebin-215 fallback

This is the current strategy.

1. Obtain the pinned public Drebin-215 feature CSV and verify its SHA-256 against the repository contract.
2. Require provenance kind `drebin215` and `is_synthetic: false`. The scheduled workflow invokes `scripts/download_dataset.py --require-real`; if every pinned source is unavailable or invalid, the job fails rather than substituting synthetic data.
3. Train with the exact canonical 215 feature names and order, using up to 30 epochs and batch size 64. A stratified 15% validation slice is taken only from the training partition; `ReduceLROnPlateau` and `EarlyStopping(patience=5, restore_best_weights=True)` monitor validation loss. The fixed reference holdout remains untouched until final evaluation. The trainer's `--require-real` option independently rejects synthetic input.
4. Convert to TFLite and verify the float32 `[1, 215] -> [1, 1]` Android tensor contract, schema bytes and checksums.
5. Run `scripts/quality_gate.py --baseline`. The existing 1,451-row reference holdout and unrounded 97.45% TFLite accuracy floor remain in force.

The scheduled workflow produces a candidate validation artifact for audit. It does not create a release, allocate a model tag, or move the latest model pointer. The separate event-driven update workflow remains responsible for normal gated release publication when new, provenance-checked feature rows arrive.

**Limit:** the public Drebin feature CSV is a historical feature-vector baseline. A passing result is evidence that the candidate meets the repository's existing fixed-holdout contract; it is not proof of detection performance on modern malware or parity with the current Android APK extractor.

Synthetic data remains usable for explicitly marked CI smoke tests only. It is not eligible for this fallback workflow or a production model release.

## Future path B — Build a custom modern-APK feature extractor

This is a separate future project, not part of the current pipeline.

Build and validate an extractor that processes modern Android APKs—potentially including samples from **CIC-AndMal2017**, subject to its dataset access terms and licensing—and emits the original 215 Drebin features with their exact semantics and order.

The future project must:

- Define and document how each of the 215 canonical features is derived from the APK (manifest permissions, intent filters, DEX/API calls, suspicious APIs, class/method and related static indicators).
- Use deterministic parsing and versioned extractor rules, with reproducible outputs and per-feature provenance.
- Preserve the exact `docs/feature_schema.json` names, indices and SHA-256. A feature may be marked absent only when the extractor's semantics establish absence; parser failures, unsupported constructs and incomplete APKs must be distinguishable from a true zero.
- Validate the extractor against a trusted reference implementation or labelled corpus, including feature-by-feature parity tests and malformed/obfuscated APK tests.
- Establish sample labels, deduplication, train/validation/test separation, temporal/generalization evaluation and dataset licensing before model training.
- Keep unknown, unparseable or unavailable features explicit. Do not silently zero-fill, infer from unrelated features, or train a candidate until all 215 feature semantics are implemented and the coverage gate passes.

Only after this project demonstrates complete and reproducible 215-feature extraction should a modern APK dataset be considered for model training. It must still pass the repository's existing schema, holdout, model verification and promotion controls.

## Contract invariants

The following are not changed by this strategy decision:

- Exactly 215 canonical feature names in the existing order and schema SHA-256.
- Float32 TFLite input `[1, 215]` and output `[1, 1]`.
- Binary feature-presence semantics and the existing label contract.
- The fixed 1,451-row reference holdout and 97.45% TFLite accuracy floor used by the baseline gate.
- No synthetic candidate may be promoted as a real-data model.
- The current published model remains installed unless the separate release workflow approves and publishes a verified candidate.

## Operational references

- [Dataset attribution and provenance](DATASET_NOTICE.md)
- [Feature schema](feature_schema.json)
- [MLOps workflow and dispatch contract](MLOPS.md)
- [Scheduled Drebin fallback workflow](../.github/workflows/continuous-learning.yml)
- [Event-driven training and release workflow](../.github/workflows/train-and-export.yml)
