Module 6: classification and decision trees

{
  "module": 6,
  "dataset": "UCI red wine quality",
  "rows": 1599,
  "chosen_model": "logistic",
  "threshold": 0.3,
  "selection_metric": "validation balanced accuracy",
  "test": {
    "model": "logistic",
    "n": 243,
    "tp": 19,
    "tn": 184,
    "fp": 30,
    "fn": 10,
    "precision": 0.3877551020408163,
    "recall": 0.6551724137931034,
    "specificity": 0.8598130841121495,
    "selection_rate": 0.20164609053497942,
    "fpr": 0.14018691588785046,
    "balanced_accuracy": 0.7574927489526264,
    "f1": 0.48717948717948717
  },
  "split_group_overlap": false,
  "label": "human score >=7"
}

Chemistry-identical rows stay in one split. No physical sample IDs exist; independence cannot be guaranteed.

Quality >=7 is a declared classroom label, not a safety/quality certification. Thresholds are selected on validation only.

Confusion counts, denominators, and rates are explicit. Feature importance and tree rules describe this fit, not causal effects.

Validation Scores

Download validation scores (CSV)

validation scores
modelthresholdntptnfpfnprecisionrecallspecificityselection_ratefprbalanced_accuracyf1
logistic0.32382018816140.55555555555555560.58823529411764710.92156862745098030.151260504201680660.07843137254901960.75490196078431370.5714285714285714
tree_depth_40.32381217826220.31578947368421050.352941176470588260.87254901960784310.159663865546218480.127450980392156850.61274509803921570.3333333333333333
logistic0.523881968260.50.235294117647058820.96078431372549020.067226890756302520.03921568627450980.59803921568627450.32
tree_depth_20.323872022270.77777777777777780.205882352941176460.99019607843137260.0378151260504201660.009803921568627450.59803921568627450.32558139534883723
tree_depth_20.523872022270.77777777777777780.205882352941176460.99019607843137260.0378151260504201660.009803921568627450.59803921568627450.32558139534883723
tree_depth_40.523871977270.50.205882352941176460.96568627450980390.0588235294117647050.034313725490196080.58578431372549020.2916666666666667
tree_depth_80.5238718915270.31818181818181820.205882352941176460.92647058823529420.092436974789915970.073529411764705880.56617647058823530.25
tree_depth_80.32381016836240.217391304347826080.294117647058823540.82352941176470580.193277310924369760.176470588235294130.55882352941176470.25
tree_depth_40.723851977290.41666666666666670.147058823529411770.96568627450980390.050420168067226890.034313725490196080.55637254901960790.21739130434782608
tree_depth_80.7238419113300.235294117647058820.117647058823529410.93627450980392160.071428571428571420.063725490196078430.52696078431372550.1568627450980392
logistic0.723812031330.50.0294117647058823530.99509803921568630.0084033613445378150.0049019607843137250.51225490196078430.05555555555555555
dummy0.32380204034nan0.01.00.00.00.50.0
dummy0.52380204034nan0.01.00.00.00.50.0
dummy0.72380204034nan0.01.00.00.00.50.0
tree_depth_20.72380204034nan0.01.00.00.00.50.0

Test Scores

Download test scores (CSV)

test scores
modelntptnfpfnprecisionrecallspecificityselection_ratefprbalanced_accuracyf1
logistic2431918430100.38775510204081630.65517241379310340.85981308411214950.201646090534979420.140186915887850460.75749274895262640.48717948717948717
dummy_majority2430214029nan0.01.00.00.00.50.0

Test Predictions

Download test predictions (CSV)

test predictions
record_idactualprobabilitypredicted
1700.0146517705376671280
2000.0538614449253352750
3300.0133629164181116360
3500.0119830264430588890
3800.0017205874373834640
5700.014146892794972240
5800.019305548921941340
6900.105674454022294150
8600.59287897444500971
8800.1511359221229830
8900.0049308065648485430
9000.012197527906070490
9100.59287897444500971
9800.0092870464018527510
10000.028121500830041560
10700.0120086708204209730
10800.055832438473877440
11100.017533247075484060
12400.0105230571805748210
12500.0076327672876668030
12900.0228042672918267780
13100.241633784773978570
13200.241633784773978570
13700.0190701384544408880
14500.0078977809312950410
16000.007153974139878430
17300.070697351957317360
17700.0391573108069550940
18400.0066122363464033110
19100.0230888617939515840
19500.0090351501729836280
19810.251593661659614440
19900.016309234069136720
20800.021348446356545880
21800.0243238922320418540
22000.0348651684141149940
23200.037253096416669880
25500.0107957892541567340
27200.16229792507394840
28000.205243747875014620
29300.0428144530299944050
29600.017276174296590220
32100.0132272747399341880
33600.60978126209675961
34000.34938844259241551
34400.130568340058020620
34610.188015188630771880
34700.76903101065051951
35710.416110532312199131
38000.090523966620780770
38200.090523966620780770
38300.090523966620780770
40200.09468761248156620
40400.0098689264899980770
41100.02205313186379850
41310.48102436179854371
42600.052233916929295890
43600.039931437914217120
43700.30456318278048371
44500.0163779089966302230
45310.248614186166494920
45510.64756482025762171
45810.248614186166494920
46200.52203999208006571
46500.094196708318002060
46700.85995491205790551
46900.0230576704166539250
47000.217625313426591030
47200.2534178871884780
48200.150062556987701570
49400.309466166757527971
52400.0278354519738315650
53810.46861519080033891
54800.22078273017166380
55300.024591703585564090
55700.22763590669692810
55900.383154933895553051
56100.0167779487265279670
56400.383154933895553051
59800.0196270287520635720
59900.056769437334760670
62300.36123924883419511
62900.0079858788581154940
63100.067611441967035880
63300.0134497249425846770
63600.004114943718134890
64000.0269615226787577530
64200.0269615226787577530
64400.0269615226787577530
64510.0287966803808924440
64600.0179816759831977830
66400.096245832159291380
68100.0391643554121073460
68400.00304209671334666930
68600.0084485866708122490
69400.013569298852933280
69900.234203219229900730
73000.00357639909759187350
74400.020724500230693610
75000.0106190875622542180
75100.0106190875622542180
75300.0106190875622542180
75400.0080715020507515640
76600.0123043993166474030
77500.005386387388563920
77800.06287437537427360
79000.035821351465264850
79200.0081201091087239260
80300.0158196210769673650
80800.0168628070989754780
83810.419335582629387971
84700.01643407293134950
86100.044502783540642480
87000.146989472856646460
87700.146989472856646460
87900.006525321999933740
88300.006525321999933740
88500.026488063969995110
88600.0224154394453948860
88710.5888632827167841
89400.0076571002558043780
89900.00941515276596440
90310.078535307050388190
90410.078535307050388190
91800.167017662089569220
91900.364633728536123471
92100.167017662089569220
92200.364633728536123471
92510.432761124697396141
93100.0158129257096021260
93200.023159179398606830
93300.0158129257096021260
94810.6379579654344561
94910.6379579654344561
95010.6379579654344561
96000.339773768935134451
96100.018450952448373910
96400.339773768935134451
98200.59455142989093981
98610.37240542983009721
98700.0156212838771191580
101700.70506547971426831
101800.70506547971426831
102000.39917491921264071
102100.39917491921264071
102200.047085622635906070
102800.0518782798723362650
103610.53774968218102911
103700.0040798154755550460
103810.72348603367863881
105310.71678066734327461
105610.342842689399181441
105910.342842689399181441
107200.0221885765181456320
107300.0423642880169860650
107700.204450217702032870
107800.204450217702032870
108810.183713483515843630
108910.183713483515843630
110200.081664048864663230
113500.400304978436366871
114200.27601811277996990
114500.23679206810358530
114600.036351002817156490
114900.43486047070493011
115100.26684443434767640
115800.352848426453129971
117200.52391326664387981
117710.381048190063410841
117800.05070714641516060
118400.0340420014578508840
118800.0340420014578508840
119500.0165453534625241050
119700.041358366393156420
120000.041358366393156420
120300.0124123246031722780
121400.14488314991757920
121800.130536580076753870
123400.196661779039849440
123700.196661779039849440
124200.50604772745657391
124400.098835012716662670
124900.062629999158737060
125000.062629999158737060
125400.05551542543029240
125800.048239583406918240
125900.048239583406918240
126800.019111801198111470
126910.77198169354310971
127400.081589288683843080
129200.367704853677362161
129500.0106277576427694160
129600.0106277576427694160
131300.037196195993014340
133300.010370213238413580
133900.042039145835183610
134000.042039145835183610
134100.042039145835183610
134300.042039145835183610
135000.0364085851696916850
135600.0318462605940060260
136000.0619278790734799560
137000.005511321289804950
137200.005511321289804950
137500.0133211261181173330
138200.0137987412155776320
138300.0137987412155776320
138500.0053953964210568530
139000.268796893421111740
139500.0159643127929152420
139900.081384294100837030
140310.290958212595358030
141800.0241313138275597170
142000.0241313138275597170
142800.055183432170878730
143100.0330589109756836560
143600.006916389926679750
143800.023888471623377410
144700.0165542671295938920
144910.319371861603826751
145300.0111656314112563130
145700.0111656314112563130
146400.0269684118778754330
146500.0269684118778754330
147800.009939826787139060
148700.064027458931158780
148800.087484830648858980
149100.087484830648858980
149200.123555478499058420
150300.11982192533624730
150500.014652212447951440
152900.0277450376803002950
153200.055205860291893150
153800.099773138704901190
154000.096529824349537690
154800.11324519196670610
155800.0041980624711205950
157000.380643411849941271
157700.088658603264810660
158000.312502466872959961
158600.450445869899572641
159400.0325270790148042140
159500.119779029458765410

Tree Rules

Download tree rules (CSV)

tree rules
rule
|--- alcohol <= 11.55
| |--- volatile acidity <= 0.36
| | |--- class: 0
| |--- volatile acidity > 0.36
| | |--- class: 0
|--- alcohol > 11.55
| |--- sulphates <= 0.69
| | |--- class: 0
| |--- sulphates > 0.69
| | |--- class: 1

Validation Calibration

Download validation calibration (CSV)

validation calibration
binloweruppernmean_probabilityobserved_rate
00.00.21920.049375972627177560.057291666666666664
10.20.4250.30542187884599720.44
20.40.6120.50268376025942440.5
30.60.870.63834853352955470.7142857142857143
40.81.020.82321251394521560.5

Tree Importance

Download tree importance (CSV)

tree importance
featureimportance
fixed acidity0.0
volatile acidity0.20080933955496097
citric acid0.0
residual sugar0.0
chlorides0.0
free sulfur dioxide0.0
total sulfur dioxide0.0
density0.0
pH0.0
sulphates0.1873543611620831
alcohol0.611836299282956