Multi-Feature One-Hot-Encoder with varying amount of feature instances
I think you can transform this into a text preprocessing problem and then use CountVectorizer. You basically build &quot;documents&quot; by putting together all the words in your raw data and then use CountVectorizer on those documents.
from sklearn.feature_extraction.text import CountVectorizer

X = [[&quot;banana&quot;,&quot;apple&quot;,&quot;cucumber&quot;], [&quot;orange&quot;,&quot;banana&quot;, &quot;cucumber&quot;]]
# Create documents
X_ = [' '.join(x) for x in X]
enc = CountVectorizer()
print(enc.fit_transform(X_).toarray())

Returns
[[1 1 1 0]
 [0 1 1 1]]

which has 4 different values as you expected.