Finding levels/subsets that will predict labels with high probabilty Assume some 1000 data-points of the following pattern
X1 X2 Y
2  B  1
1  C  0
6  A  0
3  B  1
3  C  0

where $X_1 \in \{1, 2, 3, 4, 5, 6\}$, $X_2 \in \{A, B, C\}$ and the labels $Y \in \{0,1\}$
Now, for example, I observe that whenever X1 is 2, 3, or 4 and X2 is B at the same time, Y is almost always 1. So $Pr(Y=1|X_1 =\{2,3,4\}, X_2=B)$ is going to be higher.
How can I find such observations (mathematically) in R? The objective is to find such key values that will help create buckets to classify new data-points into. If not a coding solution, I would also appreciate any suggestions in best approach to take.
Here's some code to generate a sample data frame ...
set.seed(123)
X1 <- sample (1:6, 1000, rep = TRUE)
X2 <- sample(c('A', 'B', 'C'), 1000, rep = TRUE)
Y <- sample(c(0, 1), 1000, rep = TRUE)
df <- data.frame(X1, X2, Y)

 A: Another approach would be to derive this information from looking at a tree based model trained on your data. 
The tree would be grown trying to obtain more homogeneous groups of samples for which it can correctly predict Y, while the tree complexity is limited using e.g. pruning (to not overfit or simply remember all samples). The obtained, final tree essentially divides your feature space into multiple (possibly rectangular) subspaces - therefore this is one form of grouping samples with regard to Y. Samples within one group = subspace will have a relatively high/low probability of Y==0 resp. Y==1, which should account for the probability you mentioned.
I would try using such an approach (e.g. first with a simple CART, and if it works with more complex models, possibly model trees or J48/C5.0 etc.), and try to regulate the tree complexity using pruning and similar techniques. Thereby, you should be able come up with a tree that is still small enough for your needs (small number of terminal nodes), but also has at least some terminal nodes with sufficient probabilities for Y==0 or Y==1 - which would essentially be the groups you are searching for.
