X1 and X2 are two independent variables while Y is the dependent variable. The plot shows the data, and the filled color indicates Y value.
sqr_size = 50
rep_time = 10
d = data.table(X1 = rep(rep(1:sqr_size, sqr_size), rep_time), X2 = rep(sort(rep(1:sqr_size, sqr_size)), rep_time))-0.5
d[, `:=`(idx = 1:.N, Y = as.factor(as.numeric(X2<=5 | X2>=max(X2)-4 | (X2<=X1+2 & X2>=X1-3))))]
d_train = d[sample(1:.N, round(0.75*.N))]
setkey(d, idx)
setkey(d_train, idx)
d_test = d[!d_train]
ggplot(data=unique(d), aes(x = X1, y = X2, fill = Y, title())) +
ggtitle("Data Heat Map") + geom_raster() + theme_bw()

ggplot(data = d[, .(p = sum(Y==1)/.N), keyby = "X1"], aes(x = X1, y = p)) +
geom_bar(stat="identity") + ggtitle("Y % at each X1") + ylab("Y %")

ggplot(data = d[, .(p = sum(Y==1)/.N), keyby = "X2"], aes(x = X2, y = p)) +
geom_bar(stat="identity") + ggtitle("Y % at each X2") + ylab("Y %")
