5.6 Pruned Tree

Pruned Tree right

R figure

Code
h <- 500 
w <- 1000 

grid.step <- 100

plot( c(0,w), c(0,h),  
     xaxs = "i",yaxs = "i",
     xaxt = 'n', yaxt = 'n',
     type = "n",
     xlab = "Negatives", ylab = "Positives")

p0 <- 500
n0 <- 1000
p1 <- 300
n1 <- 350
p
Error: object 'p' not found
Code
y0 <- c(0,  p0)
x0 <- c(0,  n0)
y1 <- c(0,  p1,  p0)
x1 <- c(0,  n1,  n0)
y3 <- c(0,  290,  p1,  450,  p0)
x3 <- c(0,  100,  n1,  380,  n0)
y4 <- c(0,  150,  440,  490,  p0)
x4 <- c(0,   30,  130,  750,  n0)

axis(2,y0,labels=c('0','50'))
axis(1,x0,labels=c('0','100'))

gx <- grid.step
while (gx <= w) {
  abline(v = gx, col="gray", lty="dotted")
  gx <- gx + grid.step
}
gy <- grid.step
while (gy <= h) {
  abline(h = gy, col="gray", lty="dotted")
  gy <- gy + grid.step
}

lines( c(0,100), c(0,290), lty=1, type='o', col=rgb( 16,32,240,maxColorValue=255))
lines( c(100,750), c(290,490), lty=1, type='o', col=rgb(144,32,144,maxColorValue=255))
lines( c(750,1000), c(490,500), lty=1, type='o', col=rgb( 16,32,240,maxColorValue=255))

lines( c(0,30), c(0,150), lty=3, type='o', col=rgb( 16,32,240,maxColorValue=255))
lines( c(30,130), c(150,440), lty=1, type='o', col=rgb(16,32,240,maxColorValue=255))
lines( c(130,750), c(440,490), lty=3, type='o', col=rgb(16,32,240,maxColorValue=255))

Python figure

Code
import matplotlib.pyplot as plt

h = 500
w = 1000
grid_step = 100

fig, ax = plt.subplots()
ax.set_xlim(0, w)
(0.0, 1000.0)
Code
ax.set_ylim(0, h)
(0.0, 500.0)
Code
ax.set_xlabel("Negatives")
ax.set_ylabel("Positives")

p0 = 500
n0 = 1000
p1 = 300
n1 = 350

y0 = [0, p0]
x0 = [0, n0]
y1 = [0, p1, p0]
x1 = [0, n1, n0]
y3 = [0, 290, p1, 450, p0]
x3 = [0, 100, n1, 380, n0]
y4 = [0, 150, 440, 490, p0]
x4 = [0, 30, 130, 750, n0]

ax.set_yticks(y0)
ax.set_yticklabels(['0', '50'])
ax.set_xticks(x0)
ax.set_xticklabels(['0', '100'])

gx = grid_step
while gx <= w:
    ax.axvline(gx, color="gray", linestyle="dotted")
    gx += grid_step

gy = grid_step
while gy <= h:
    ax.axhline(gy, color="gray", linestyle="dotted")
    gy += grid_step

ax.plot([0, 100], [0, 290], linestyle='-', marker='o', color=(16/255,32/255,240/255))
ax.plot([100, 750], [290, 490], linestyle='-', marker='o', color=(144/255,32/255,144/255))
ax.plot([750, 1000], [490, 500], linestyle='-', marker='o', color=(16/255,32/255,240/255))

ax.plot([0, 30], [0, 150], linestyle=':', marker='o', color=(16/255,32/255,240/255))
ax.plot([30, 130], [150, 440], linestyle='-', marker='o', color=(16/255,32/255,240/255))
ax.plot([130, 750], [440, 490], linestyle=':', marker='o', color=(16/255,32/255,240/255))

plt.show()

Pruned Tree left

Code
graph TD;
    N0["[50+, 100−]"]:::red
    N11["[30+, 35−]"]:::purple
    N12["[20+, 65−]"]:::purple
    N21["[29+, 10−]"]:::blue
    N22["[1+, 25−]"]:::blue
    N31["[15+, 3−]"]:::dottedBlue
    N32["[5+, 62−]"]:::dottedBlue

    N0 --> N11
    N0 --> N12
    N11 --> N21
    N11 --> N22
    N12 -.-> N31
    N12 -.-> N32

    classDef red fill:#f04030,stroke:#000,stroke-width:1px;
    classDef purple fill:#804080,stroke:#000,stroke-width:1px;
    classDef blue fill:#1040f0,stroke:#000,stroke-width:1px;
    classDef dottedBlue fill:#1040f0,stroke:#000,stroke-dasharray:3,stroke-width:1px;
graph TD;
    N0["[50+, 100−]"]:::red
    N11["[30+, 35−]"]:::purple
    N12["[20+, 65−]"]:::purple
    N21["[29+, 10−]"]:::blue
    N22["[1+, 25−]"]:::blue
    N31["[15+, 3−]"]:::dottedBlue
    N32["[5+, 62−]"]:::dottedBlue

    N0 --> N11
    N0 --> N12
    N11 --> N21
    N11 --> N22
    N12 -.-> N31
    N12 -.-> N32

    classDef red fill:#f04030,stroke:#000,stroke-width:1px;
    classDef purple fill:#804080,stroke:#000,stroke-width:1px;
    classDef blue fill:#1040f0,stroke:#000,stroke-width:1px;
    classDef dottedBlue fill:#1040f0,stroke:#000,stroke-dasharray:3,stroke-width:1px;