While {@link StringIndexerModel} maps string to index, IndexToString maps index to string. However, IndexToString does not have a corresponding {@link com.alibaba.alink.pipeline.EstimatorBase}. Instead, IndexToString uses model data in StringIndexerModel to perform predictions.

IndexToString use the name of the {@link StringIndexerModel} to get the model data. The referenced {@link StringIndexerModel} should be created before calling method.

StringIndexer stringIndexer = new StringIndexer() .setModelName(“name_a”) // The fitted StringIndexerModel will have name “name_a”. .setSelectedCol(…);

StringIndexerModel model = stringIndexer.fit(…); // This model will have name “name_a”.

indexToString.transform(…); // Will relies on a StringIndexerModel with name “name_a” to do transformation.

The reason we use model name registration mechanism here is to make possible stacking both StringIndexer and IndexToString into a {@link Pipeline}. For examples,

pipeline.fit(…);

Code

Results

  1. f0|f0_indexed|f0_indxed_unindexed
  2. --|----------|-------------------
  3. football|2|football
  4. football|2|football
  5. basketball|1|basketball
  6. basketball|1|basketball