All Downloads are FREE. Search and download functionalities are using the official Maven repository.

hex.genmodel.easy.OneHotEncoderDomainMapConstructor Maven / Gradle / Ivy

There is a newer version: 3.46.0.5
Show newest version
package hex.genmodel.easy;

import hex.genmodel.GenModel;

import java.util.HashMap;
import java.util.Map;

public class OneHotEncoderDomainMapConstructor extends DomainMapConstructor {

  public OneHotEncoderDomainMapConstructor(GenModel m, Map columnNameToIndex) {
    super(m, columnNameToIndex);
  }

  @Override
  public Map create() {
    Map domainMap = new HashMap<>();

    String[] columnNames = _m.getOrigNames();
    String[][] domainValues = _m.getOrigDomainValues();

    for (int i = 0; i < _m.getOrigNumCols(); i++) {
      String[] colDomainValues = domainValues[i];
      int targetOffsetIndex = _columnNameToIndex.get(columnNames[i]);
      if (colDomainValues != null) {
        domainMap.put(targetOffsetIndex, new OneHotEncoder(columnNames[i], targetOffsetIndex, colDomainValues));
      }
    }
    return domainMap;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy