Learning

Classify high-grade cervical lesions with machine learning

Classify the source-derived CIN II-or-worse endpoint

This reproducible Neural Designer example reformulates 197 cervical-pathology records as a binary classification problem instead of assigning arbitrary numbers to lesion grades. On 39 internally held-out records, the selected model reaches ROC AUC 0.756 and 76.0% sensitivity at score 0.50. Limited provenance, possible endpoint leakage and the absence of external validation keep it firmly within retrospective research.

197source records
39internally held-out records
0.756testing ROC AUC (95% CI 0.629–0.883)
76.0%testing sensitivity at score 0.50

1. Clinical question and intended use

The model learns the binary endpoint cin2_or_worse from age, cytology, HPV group, biopsy result, p16/Ki-67 and smoking status. The defensible purpose is to demonstrate categorical preprocessing, class-weighted training, model selection and internal validation on a small historical table.

This is not a longitudinal prognosis model: the source does not document an index date, prediction horizon or later outcome. The revised endpoint describes the record’s final source label and is therefore presented as retrospective classification.

Preserve categories

Use categorical expansion instead of imposing a questionable numeric distance between cytology, HPV and biopsy labels.

Audit an operating point

Report counts, sensitivity and specificity at a fixed score threshold rather than a goodness-of-fit chart for an ordinal regression.

Expose evidence limits

Compare the network with transparent baselines and separate reproducibility from clinical validity.

Clinical data scienceCervical pathology researchMedical ML educationBiostatisticsModel governance
Intended-use boundary. This is a retrospective educational classifier of a source-derived label. It must not determine population screening, triage, diagnosis, follow-up intervals, treatment or discharge from care.

2. Cohort, measurements and endpoint

The updated cervixcancer.csv contains 197 records. The previous numeric grades have been replaced by explicit categories, and the former continuous target has been derived as cin2_or_worse: 0 for negative/CIN I and 1 for CIN II, CIN II–III, CIN III or carcinoma.

Source provenance. The previous article attributes the table to the Cervical Pathology Unit of the Palencia health area in Spain and says it covers three years, but it provides no exact dates, recruitment protocol, reference-standard timing, follow-up horizon, ethics statement or primary data publication. Those missing details prevent a clinical prognosis claim.
CSV fieldRoleValues and interpretation
patient_idIdentifierStable row identifier; excluded from modelling.
ageInputAge in years, 20–68.
cytologyInputNormal, ASC-US, ASC-H, LSIL, HSIL, AGC or unknown.
hpv_risk_groupInputNegative, other low risk, other high risk, HPV 16/18 or unknown.
biopsy_resultInputNegative/nondiagnostic, CIN I, CIN II, CIN II–III, CIN III, carcinoma or unknown. The source numeric table had already merged negative and nondiagnostic values, so they cannot be separated retrospectively.
p16_ki67InputNegative, positive or unknown.
smoking_statusInputNo, yes or unknown.
cin2_or_worseTargetBinary source-derived endpoint: 85 negative/CIN I and 112 CIN II-or-worse records.

Missing source values remain explicit unknown categories rather than being silently imputed. Before recoding, missingness affected 5 cytology, 2 HPV, 3 biopsy, 78 p16/Ki-67 and 103 smoking entries. In particular, high missingness may reflect the local testing workflow rather than biology.

SubsetRowsEndpoint 0Endpoint 1Purpose
Training1194970Estimate model parameters
Selection392217Select hidden-layer size
Testing391425Internal final analysis
Total19785112Random 60/20/20 row split
Distribution of the binary CIN2-or-worse endpoint
The 56.9% positive share is the class balance of this source table, not population prevalence.
Coding-dependent input-target Pearson correlations
Biopsy has the largest displayed coefficient. Pearson values for encoded categories are descriptive, coding-dependent associations—not feature importance, causal effects or independent clinical evidence.
Split-integrity audit. The 197 rows collapse to 190 unique input vectors; seven are exact extra duplicates and two testing vectors also appear in training. This row-level leakage can make internal performance optimistic. Future work should group identical records and, preferably, split by time, patient or clinical site.

3. Model

Age remains numeric. Neural Designer one-hot expands the five categorical variables, producing 26 model features. The initial architecture connects those 26 scaled features directly to one sigmoid output, so it is a compact linear baseline in the expanded feature space.

Output contract. A larger sigmoid value ranks a record toward the source-derived cin2_or_worse=1 label. It has not been calibrated as an individual clinical probability.
Initial 26-to-1 cervical CIN2-plus classifier
Initial 26–1 architecture before neuron selection. Six displayed source inputs expand to 26 numeric model features.

4. Training strategy

The initial model minimizes weighted squared error with quasi-Newton optimization, L2 regularization 0.01 and class weights 1.1588 for endpoint 0 and 0.8795 for endpoint 1. Weighting prevents the larger class from dominating the loss.

Across 35 stored iterations, training error decreases from 1.0178 to 0.3580 and selection error from 1.1765 to 0.8203. Optimization stops on minimum loss decrease.

Initial weighted-squared training and selection error histories
Training and selection are separated before architecture selection; testing data remain reserved for the final analysis.

5. Model selection and baseline

A growing-neurons experiment evaluates hidden layers from one to ten neurons with three trials per size. The minimum stored selection error occurs at seven tanh neurons: training error 0.1445 and selection error 0.6884.

Growing-neurons selection from one to ten hidden neurons
Seven neurons are selected from the selection subset; the testing subset is not used to choose this architecture.

Selected architecture

The final 26–7–1 network contains 197 trainable parameters and is the model used for testing and deployment.

Selected 26-to-7-to-1 cervical CIN2-plus classifier
Final 26–7–1 architecture obtained after neuron selection.
Testing reference at score 0.50SensitivitySpecificityAccuracyBalanced accuracy
Always predict endpoint 1100.0%0%64.1%50.0%
Positive when biopsy is CIN II+84.0%64.3%76.9%74.1%
Selected neural network76.0%64.3%71.8%70.1%

The transparent biopsy rule slightly outperforms the selected network on this small test subset. The network therefore demonstrates a reproducible modelling workflow, but it does not establish incremental clinical value.

6. Clinical validation

The selected model is evaluated on 39 held-out records containing 25 positive and 14 negative source labels. Neural Designer reports ROC AUC 0.756 with a 95% confidence interval of 0.629–0.883, indicating moderate internal discrimination with substantial uncertainty.

Testing ROC curve with area under the curve 0.756
The orange point near 0.44 is selected from the same testing ROC curve and is descriptive only. The count table below uses the fixed article reference threshold 0.50.

Operating point at score 0.50

The fixed threshold produces 19 true positives, six false negatives, five false positives and nine true negatives.

Actual / predictedEndpoint 1Endpoint 0Total
CIN II or worse19625
Negative or CIN I5914
Total241539
Testing metricValueCount-based interpretation
Sensitivity76.0%19 of 25 endpoint-1 labels detected
Specificity64.3%9 of 14 endpoint-0 labels rejected
Precision / observed PPV79.2%19 of 24 positive calls match the source label
Observed NPV60.0%9 of 15 negative calls match the source label
Accuracy71.8%28 of 39 records classified correctly
Balanced accuracy70.1%Mean of sensitivity and specificity
F1 score0.776Summary of precision and sensitivity
Interpretation. These are internal, count-based results from only 39 records. Predictive values reflect this test subset’s 64.1% positive-label share and must not be transferred to a screening population. The test-derived ROC threshold cannot be called clinically optimal without external data and explicit consequences for false negatives and false positives.

7. Workflow and reproducibility

A responsible use of the artifact is a reproducibility workflow:

De-identified research record
Schema and category checks
Unknown-value audit
Versioned model score
Researcher comparison
Independent clinical evidence

The calculator reproduces the final exported network for one complete source row. It deliberately returns a neutral score rather than a diagnosis or management recommendation.

Reproduce one exported model score

The default row is a complete source record used only to verify deployment. The calculation runs locally with the selected network’s exact preprocessing and coefficients.

Research demonstration. Values outside the validated domain are rejected. This model is not a diagnosis and must not be used to screen, determine follow-up or guide treatment.

Reproduce the calculation

The Python package contains the selected model, exact input order, categorical encoder and reference call. Neural Designer’s original generated code reused identifiers such as unknown and negative across fields; the downloadable reproducibility copy stores coefficients positionally to prevent category-name collisions while preserving the exact parameters.

from model import NeuralNetwork

score = NeuralNetwork().calculate_from_categories(
    46, "lsil", "hpv_16_or_18", "cin_2_3", "positive", "yes"
)
# 0.7880622145

8. Safety, generalizability and governance

  • No longitudinal endpoint. There is no documented index date, follow-up interval or later outcome, so this is not a prognosis or progression model.
  • Possible endpoint circularity. Biopsy is both an input and closely related to the derived lesion-grade target. Without timing and adjudication metadata, it may encode part of the reference standard rather than an upstream predictor.
  • Small, local sample. Only 197 records from one reported health area are available, with 39 testing rows and no external institution.
  • Missingness may encode care. p16/Ki-67 and smoking are unknown in 39.6% and 52.3% of records. The unknown category can reflect which tests were ordered or recorded.
  • Duplicate leakage. Two testing input vectors occur in training; a grouped or temporal resplit is required.
  • No calibration or subgroup analysis. Scores are not calibrated, and performance by age, HPV group or other clinically relevant strata is not established.
  • No demonstrated added value. On this test subset, a simple biopsy rule slightly exceeds the neural network’s balanced accuracy.
Decision boundary. Use this example for reproducible machine-learning education and retrospective method development only. Do not use it for screening, diagnosis, reassurance, treatment, referral or follow-up decisions. Any clinical investigation requires a prespecified intended use, temporally valid predictors, an independently adjudicated outcome, external validation, calibration, comparison with current care and clinician expert review.

References