Skip to content
Learning

Lung cancer survey classification with machine learning

Classify historical lung-cancer survey records with a transparent baseline model

This reproducible Neural Designer example maps 15 demographic, behavioural and symptom fields to the binary label in a 309-row public survey table. On 61 internally held-out records, the fixed direct classifier reaches ROC AUC 0.989 and detects 50 of 54 positive labels at threshold 0.50. The collection lacks the provenance and reference-standard documentation required for clinical screening or diagnosis.

309public survey records
61internally held-out testing records
0.989testing ROC AUC (95% CI 0.971–1.000)
92.6%testing sensitivity at score 0.50

1. Clinical question and intended use

The model reproduces the binary label attached to records in the supplied survey table. Its defensible use is machine-learning education, software verification and retrospective benchmarking. It does not estimate eligibility for lung-cancer screening and cannot establish whether a person has cancer.

Real screening programmes use defined eligibility criteria and validated methods. For example, current US guidance identifies low-dose computed tomography (LDCT) as the recommended screening test for eligible high-risk adults; this questionnaire model is not an alternative.

Inspect imbalance

Understand why 87.4% positive labels make accuracy alone a misleading performance summary.

Audit a compact model

Review a direct 15-input sigmoid classifier with sixteen trainable parameters and exact exported coefficients.

Expose validation risk

See how duplicated rows and undocumented label provenance limit otherwise strong internal metrics.

Clinical data scienceEpidemiology educationMedical ML researchBiostatisticsModel governance
Intended-use boundary. This is an educational survey-record classifier. It must not determine screening eligibility, reassure symptomatic people, diagnose lung cancer or replace LDCT, imaging review, pathology or specialist care.

2. Cohort, measurements and endpoint

The local lung_cancer.csv contains 309 rows, 15 inputs and one binary target. It is a cleaned copy of the widely redistributed Kaggle “Survey Lung Cancer” table. No values are missing, age spans 21–87 years, and all other predictors are binary categories.

Source limitation. The downloadable file and repository page do not provide a primary collection protocol, recruitment setting, dates, participant identifiers, diagnostic reference standard, assay/imaging confirmation or label-adjudication procedure. Rows are therefore described as survey records, not independently verified patients.
SubsetRowsyesnoPurpose
Training18716027Estimate coefficients
Selection61565Monitor optimization
Testing61547Internal final analysis
Total30927039Random 60/20/20 row split

Distribution of positive and negative lung-cancer labels across 309 survey records

The positive label represents 87.4% of the table. This is a dataset class proportion, not disease prevalence in a screening population.
GroupCSV fieldsEncoding
Demographicsgender, ageFemale/male; age in years
Behaviour and contextsmoking, alcohol_consuming, peer_pressureNo/yes
Symptoms and historyyellow_fingers, anxiety, chronic_disease, fatigue, allergy, wheezing, coughing, shortness_of_breath, swallowing_difficulty, chest_painNo/yes
Targetlung_cancerno=0, yes=1

Pearson correlations between encoded survey fields and the lung-cancer label

allergy, alcohol_consuming and swallowing_difficulty have the largest displayed coefficients. These are coding-dependent associations, not causal effects, clinical importance or verified risk factors.
Split-integrity audit. The 309 rows collapse to 276 unique complete records. Six testing rows exactly duplicate a training row, and seven testing rows share the same 15-input vector with training. This leakage can make internal test performance optimistic; a duplicate-grouped split is required before stronger claims.

3. Model

Fourteen binary inputs use minimum–maximum scaling and age uses mean-and-standard-deviation scaling. They connect directly to one sigmoid output, with no hidden layer. The fixed model contains fifteen weights and one bias, so it is a logistic classifier expressed in Neural Designer’s network framework.

Output contract. Larger values rank a record toward the source label lung_cancer=yes. The sigmoid output has not been independently calibrated, so it is a model score—not an individual probability of cancer.
Direct lung-cancer survey classifier with fifteen inputs and one sigmoid output
Fixed initial and final 15–1 architecture. No hidden layer or neuron-selection experiment was used.

4. Training strategy

The model minimizes weighted squared error with the quasi-Newton method and L2 regularization weight 0.01. To counter the 270-to-39 class imbalance, the stored project assigns weight 3.9615 to negative records and 0.5722 to positive records.

Across 28 stored iterations (epochs 0–27), training error falls from 0.6908 to 0.2006 and selection error from 0.3544 to 0.1447. Optimization stops on minimum loss decrease.

Weighted-squared training and selection error histories over 28 stored iterations

Selection error reaches its minimum early and then increases slightly. The displayed final export is reported without claiming that the last iteration is an independently chosen optimum.

5. Model selection and baseline

No neuron selection, input selection or architecture selection was performed. The direct 15–1 classifier is both the initial and final model. Given the small, duplicated table, adding hidden neurons would increase capacity without repairing the primary evidence limitations.

ReferenceTesting accuracyTesting specificityInterpretation
Majority-class baseline88.5%0%Predict every row as yes
Fixed weighted classifier91.8%85.7%Separates six of seven negative labels at score 0.50

The baseline comparison shows why accuracy is secondary here: a trivial classifier already reaches 88.5% because negative labels are rare.

6. Clinical validation

The final model is evaluated on 61 testing records containing 54 positive labels (88.5% observed test prevalence) and seven negative labels. Neural Designer reports ROC AUC 0.989 with a 95% confidence interval of 0.971–1.000.

Testing ROC curve with area under the curve 0.989

The marked threshold 0.51 is selected from this same testing ROC curve and is descriptive only. The confusion matrix below uses the prespecified article reference threshold 0.50.

Operating point at score 0.50

At threshold 0.50, the model produces 50 true positives, four false negatives, one false positive and six true negatives.

Actual / predictedPositiveNegativeTotal
Positive label50454
Negative label167
Total511061
Testing metricValueCount-based interpretation
Sensitivity92.6%50 of 54 positive labels detected
Specificity85.7%6 of 7 negative labels rejected
Precision / observed PPV98.0%50 of 51 positive calls match the source label
Observed NPV60.0%6 of 10 negative calls match the source label
Accuracy91.8%56 of 61 rows classified correctly
F1 score0.952Summary of precision and sensitivity
ROC AUC0.98995% CI 0.971–1.000
Interpretation. Internal discrimination is high, but predictive values reflect an artificial 88.5% positive test prevalence and only seven negative examples. Duplicate leakage, the tiny negative denominator and undocumented label ascertainment prevent clinical interpretation.

7. Workflow and reproducibility

A responsible use of this artifact is a reproducibility workflow, not patient screening:

De-identified research record
Schema and range checks
Duplicate and provenance audit
Versioned model score
Researcher review
Independent clinical evidence

The calculator reproduces one complete record with the exact exported coefficients. It does not issue a screening decision or clinical classification.

Reproduce the exported survey score

The default row is the reference case generated in Neural Designer. The calculation runs locally with the exact exported scaling and coefficients.

Research demonstration. Values outside the validated domain are rejected. The output must not guide care and is not a diagnosis, screening recommendation or replacement for low-dose CT and specialist assessment.

Reproduce the calculation

The Python package contains the exact export, input order and reference vector. The Neural Designer package preserves the split, parameters and regenerated analyses.

from model import NeuralNetwork
inputs = [1, 62, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 0, 1]
score = NeuralNetwork().calculate_outputs(inputs)[0]

8. Safety, generalizability and governance

  • Unknown reference standard. The public table does not document how the cancer label was established or when predictors were collected relative to diagnosis.
  • Not a screening cohort. The 87.4% positive proportion is incompatible with population-screening prevalence and makes PPV/NPV non-transferable.
  • Duplicate leakage. Exact records cross training, selection and testing subsets; results must be repeated with duplicate groups kept together.
  • Tiny negative test group. Specificity is based on only seven negative records, so one error changes it by 14.3 percentage points.
  • No external validation. There is no independent site, temporal cohort, prospective evaluation or documented subgroup analysis.
  • Uncalibrated score. No calibration curve, Brier score or recalibration study supports individual probability language.
  • Incomplete screening variables. The table lacks pack-years, years since quitting and CT findings used in real screening pathways.
  • Human expert review. Any consequential assessment requires an approved clinical pathway, qualified professionals and an appropriate confirmatory method.
Decision boundary. Use this model only for education and reproducibility. It must not reassure, diagnose, select patients for screening or replace LDCT, imaging interpretation, pathology or specialist evaluation.

References