title: OneHotEncoding an array of text with ML.NET
body: <p>I have a class <code>InputData</code> as below</p>
  
  <pre><code>public class InputData
  {
      public string[] TextFields { get; set; }
      public float[] NumericFields { get; set; }
  }
  </code></pre>
  
  <p>When building the pipeline, I can easily convert <code>NumericFields</code> to numeric features with 1 line of code</p>
  
  <pre><code>var numFeatures = MlContext.Transforms.Concatenate("NumFeatures", nameof(InputData.NumericFields));
  </code></pre>
  
  <p>However I couldn't figure out a way to one-hot-encoding <code>TextFields</code></p>
  
  <p>According to the example at <a href="https://docs.microsoft.com/en-us/dotnet/api/microsoft.ml.categoricalcatalog.onehotencoding" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/dotnet/api/microsoft.ml.categoricalcatalog.onehotencoding</a>, each text field needs to have its own property and then can be added as</p>
  
  <pre><code>MlContext.Transforms.Categorical.OneHotEncoding("TextField1", "TextField2" ....);
  </code></pre>
  
  <p>Is there a more elegant way to quickly OneHotEncoding an array of text fields?</p>
  
  <p>Thanks</p>