Learning

Liver disease laboratory-record classification with machine learning

Audit a five-class HCV laboratory-record model beyond headline accuracy

This reproducible Neural Designer example maps age, sex and ten laboratory measurements to the five source labels in the 615-record UCI HCV data set. The fixed model classifies 115 of 123 internally held-out records correctly, but 112 test records carry the majority blood-donor/none label. Macro sensitivity is 35.0%, and only 3 of 11 records from the four non-none categories are classified correctly. The artifact is suitable for education and model audit, not diagnosis or fibrosis staging.

615public patient records
123internally held-out test records
35.0%macro sensitivity across five labels
3 / 11non-none test labels classified correctly

1. Clinical question and intended use

The defensible purpose of this artifact is retrospective machine-learning education, software verification and audit of a highly imbalanced multiclass benchmark. It reproduces the labels in a historical public table; it does not establish the presence, cause or stage of liver disease in a new patient.

The intended users are clinical data scientists, laboratory-medicine researchers, biostatisticians and model-governance teams. The supported action is to inspect preprocessing, class imbalance, optimization and class-level test behaviour before designing a stronger study.

Expose imbalance

Compare overall accuracy with macro sensitivity and the 91.1% majority-class baseline.

Trace the artifact

Reproduce the stored split, mean imputation, direct softmax model and exact exported scores.

Define the evidence gap

Separate internal record-level performance from calibration, clinical validity and external transportability.

Laboratory medicineClinical data scienceBiostatisticsMedical ML researchModel governance
Intended-use boundary. Do not use this model to screen, diagnose, stage, reassure or recommend treatment. Outputs require research interpretation and cannot replace validated laboratory pathways, imaging, histopathology or specialist assessment.

2. Cohort, measurements and endpoint

The analysis uses the UCI HCV data set (DOI 10.24432/C5D612), accessed 13 August 2026 and distributed under CC BY 4.0. UCI describes each instance as a patient and the table as laboratory values from blood donors and hepatitis C patients. The processed CSV used here contains 615 records, 12 inputs and one five-class endpoint.

Source categoryProcessed labelRecordsShare
3 = Cirrhosiscirrhosis304.9%
2 = Fibrosisfibrosis213.4%
1 = Hepatitishepatitis243.9%
0 = Blood donornone53386.7%
0s = Suspect blood donorsuspect_disease71.1%
Distribution of the five source labels across 615 UCI HCV records
The chart shows sample composition, not population prevalence. In particular, none maps to the source blood-donor category and must not be interpreted as a clinically verified absence of all liver disease.

The UCI record identifies age in years and sex as f/m. The remaining inputs are albumin, alkaline phosphatase, alanine aminotransferase, aspartate aminotransferase, bilirubin, cholinesterase, cholesterol, creatinine (named creatinina in the processed file), gamma-glutamyl transferase and total protein. The downloadable UCI metadata does not specify measurement units for these laboratory fields, so this page does not invent units or clinical reference ranges.

SubsetRowsCirrhosisFibrosisHepatitisNoneSuspect
Training3691616163174
Selection12310171041
Testing1234411122

The stored project uses a random 60/20/20 row split. The audit found no duplicate complete rows or duplicate input vectors. It found 31 missing values in 26 records: albumin 1, alkaline phosphatase 18, alanine aminotransferase 1, cholesterol 10 and protein 1. The project uses mean replacement.

Preprocessing leakage. The means embedded in the exported scaling layer match summaries calculated from all 615 records rather than the 369 training records. The missing-value path is also configured at data-set level without a stored training-only fit. The testing partition therefore did not remain isolated from preprocessing and must not be described as untouched.
Neural Designer association values between laboratory inputs and the categorical liver-disease label
These coding- and method-dependent univariate associations are not feature importance, causal effects, biological mechanisms or evidence that a measurement is clinically decisive.
Endpoint provenance. UCI defines the five source categories but does not fully document the ascertainment path for every one of the 615 labels. The associated 2018 paper describes a separate 73-patient hepatitis C analysis with serological and histopathological diagnosis, simultaneous biopsy and blood sampling, and three severity groups. Because its cohort size and class structure do not exactly match this 615-record table, that reference standard is not assumed to apply unchanged to every record here.

3. Model

Eleven numeric inputs use mean-and-standard-deviation scaling; binary sex uses minimum-maximum scaling. The scaled values connect directly to five softmax outputs, with no hidden layer. The model therefore behaves as a multinomial logistic classifier and contains 65 trainable coefficients: 60 input weights and five biases.

Output contract. The five values sum to one, but calibration has not been evaluated. They are uncalibrated model scores for the source labels, not patient-level probabilities. Classification uses the largest score (argmax).
Direct classifier with twelve scaled inputs and five softmax source-label scores
Fixed initial and final architecture: a 12-input scaling layer followed by one five-unit softmax layer. No hidden layer or architecture-selection experiment was run.

4. Training strategy

The stored project minimizes multiclass cross-entropy with L2 regularization weight 0.01 and the quasi-Newton optimizer. It stops on minimum loss decrease after 40 stored epochs (0–39); no class weighting or resampling is recorded.

Training cross-entropy falls from 1.6449 to 0.1969. Selection cross-entropy falls from 1.0226 to approximately 0.356 at epoch 4, then rises and ends at 0.4166. That divergence is evidence of overfitting risk; the final export must not be described as a selection-optimal checkpoint.

Training and selection cross-entropy histories over forty quasi-Newton epochs
The selection curve reaches its minimum early while training error continues to improve. The stored stopping rule is minimum loss decrease, not a documented restoration of the best selection epoch.

5. Model selection and baseline

No neuron selection, feature selection or architecture selection was performed. The direct 12-to-5 classifier is both the initial and final model. The selection subset monitors optimization but was not used to compare documented candidate architectures.

Testing referenceAccuracyMacro sensitivityCorrect non-none labels
Always predict none91.1% (112/123)20.0%0/11
Fixed softmax model93.5% (115/123)35.0%3/11

The model improves accuracy by only 2.4 percentage points over the transparent majority baseline. Macro sensitivity improves by 15 points but remains low, which is more informative than the headline accuracy for this imbalanced five-class task.

6. Clinical validation

The final exported model was recomputed against the 123 records marked as testing in the project, reproducing the supplied confusion table exactly. These records were held out from coefficient fitting, but not from preprocessing statistics. Test prevalence is highly skewed: 112 none records (91.1%) versus only 11 records across the four other categories.

Calibration, multiclass ROC AUC and PR AUC were not evaluated or supplied. With only one hepatitis record, two suspect records and four each for fibrosis and cirrhosis, class-specific estimates have very wide uncertainty and cannot establish diagnostic performance.

Decision rule and confusion matrix

No binary or class-specific decision threshold was selected. The reported operating point assigns the label with the largest of the five softmax scores (argmax); no threshold was optimized on the test subset.

Actual / predictedCirrhosisFibrosisHepatitisNoneSuspectTotal
Cirrhosis210104
Fibrosis010304
Hepatitis000101
None / blood donor0001120112
Suspect blood donor100102
Total3201180123
One-vs-rest labelTest prevalenceTP / FN / FP / TNSensitivity (95% Wilson CI)SpecificityObserved precision / PPV
Cirrhosis4/123 (3.3%)2 / 2 / 1 / 11850.0% (15.0–85.0)99.2%66.7%
Fibrosis4/123 (3.3%)1 / 3 / 1 / 11825.0% (4.6–69.9)99.2%50.0%
Hepatitis1/123 (0.8%)0 / 1 / 0 / 1220% (0–79.3)100%Not estimable
None / blood donor112/123 (91.1%)112 / 0 / 6 / 5100% (96.7–100)45.5%94.9%
Suspect blood donor2/123 (1.6%)0 / 2 / 0 / 1210% (0–65.8)100%Not estimable
Overall test summaryValue
Accuracy93.5% (115/123)
Macro sensitivity / balanced multiclass recall35.0%
Macro F10.376
Exact classification among four non-none categories27.3% (3/11)
Interpretation. The model recognizes the majority blood-donor/none label but does not detect either hepatitis or suspect-disease test record and has low sensitivity for fibrosis and cirrhosis. Predictive values reflect this artificial test composition and must not be transferred to a clinical population.

7. Workflow and reproducibility

A responsible workflow for this artifact is a controlled research reproduction:

Licensed de-identified record
Schema and provenance check
Missingness and range review
Versioned preprocessing
Five uncalibrated scores
Researcher audit

Use batch inference only with the supplied schema. Reject unknown categories, missing fields not covered by the documented mean-replacement path and measurements whose units or assay context cannot be matched. The exported model should not receive clinical samples because the required laboratory units and deployment domain are not specified.

Verified reference calculation

The supplied export was checked with the reference vector shown below. The values are source-label model scores; the largest score is none.

Reference inputValueReference inputValue
age33sexf
albumin44alkaline_phosphatase74
alanine_aminotransferase50aspartate_aminotransferase52
bilirubin8.5cholinesterase6.5
cholesterol3.34creatinina73
gamma_glutamyl_transferase45protein74
Source labelModel score
Cirrhosis0.096775
Fibrosis0.152749
Hepatitis0.107191
None / blood donor0.585309
Suspect blood donor0.057976

The Python package contains the exact export, ordered input schema, reference vector and expected scores. The Neural Designer package contains the project and exact processed CSV, preserving the split and analysis chronology.

8. Safety, generalizability and governance

  • Internal evidence only: there is no external, temporal or independent-site validation and no prospective workflow evaluation.
  • Preprocessing leakage: scaling summaries match the complete table rather than the training subset, so the test partition is not an untouched estimate.
  • Endpoint uncertainty: full label-ascertainment details for the 615-row UCI table are not documented well enough to claim a uniform clinical reference standard.
  • Class imbalance: the test set contains only 11 non-none records, including one hepatitis and two suspect records; accuracy is therefore dominated by the blood-donor category.
  • Calibration and thresholds: score calibration, decision-curve utility and clinically prespecified thresholds are absent.
  • Measurement transfer: laboratory units, instruments, analytic ranges and pre-analytic handling are not fully specified for deployment. Unmatched samples are out of domain.
  • Subgroups: age- and sex-stratified performance, missingness effects and clinically relevant subgroup robustness were not established.
  • Human oversight: any future research study requires laboratory and specialist review, a confirmatory method, versioned preprocessing, audit logging and an abstention policy.

Evidence required before any clinical research transition

  1. Reconstruct label provenance and measurement units from primary source records.
  2. Predefine a clinically meaningful endpoint and comparator rather than inherit the five source categories uncritically.
  3. Use stratified, patient-level development with sufficient cases in every class and restore the best selection checkpoint.
  4. Evaluate calibration and prespecified operating points on a locked validation cohort.
  5. Perform external site and temporal validation with subgroup, missingness and assay-shift analyses.
  6. Assess prospective workflow impact under specialist oversight before considering regulated use.
Decision boundary. This article demonstrates reproducibility and critical model evaluation. It does not validate a diagnostic pathway, establish clinical benefit or authorize use with patient samples.

References

  1. Lichtinghagen R, Klawonn F, Hoffmann G. HCV data. UCI Machine Learning Repository; 2020. DOI: 10.24432/C5D612.
  2. Hoffmann GF, Bietenbeck A, Lichtinghagen R, Klawonn F. Using machine learning techniques to generate laboratory diagnostic pathways—a case study. Journal of Laboratory and Precision Medicine. 2018;3:58.