Handling a feature with multiple categorical values for the same instance value I have data in the following form:

table 1
id, feature1, predict 
1, xyz,yes
2, abc, yes

table2
id, feature2
1, class1
1, class2
1, class3
2, class2

I could perform a one many join and train on the resultant set- which is one way to go about it. But If I rather wanted to maintain the length of the resultant set equal length of table 1, what is the technique?
One possible approach is to perform an encoding, where each level of the feature2 corresponds to a new feature (column).
This way you may describe the 1:N relation between the feature 1 and 2

Here a small example in R

&gt; table1  &lt;- data.frame(id = c(1,2),  feature1 = c("xyz","abc"), predict = c(T,T))
&gt; table2  &lt;- data.frame(id = c(1,1,1,2), feature2 = c("class1", "class2", "class3", "class2"))
&gt; 
&gt; ## encoding
&gt; table(table2)
   feature2
id  class1 class2 class3
  1      1      1      1
  2      0      1      0


The new object contains the (now unique) id and setting of the feature2.
You need only to merge (join) the result to the table1 (basically same task a DB join - which variance: inner, outer or full depends on your requirements).