com.flipkart.fdp.ml.adapter.HashingTFModelInfoAdapter Maven / Gradle / Ivy
package com.flipkart.fdp.ml.adapter;
import com.flipkart.fdp.ml.modelinfo.HashingTFModelInfo;
import org.apache.spark.ml.feature.HashingTF;
import org.apache.spark.sql.DataFrame;
import java.util.LinkedHashSet;
import java.util.Set;
/**
* Transforms Spark's {@link HashingTF} in MlLib to {@link com.flipkart.fdp.ml.modelinfo.HashingTFModelInfo} object
* that can be exported through {@link com.flipkart.fdp.ml.export.ModelExporter}
*/
public class HashingTFModelInfoAdapter extends AbstractModelInfoAdapter {
@Override
public HashingTFModelInfo getModelInfo(final HashingTF from, DataFrame df) {
final HashingTFModelInfo modelInfo = new HashingTFModelInfo();
modelInfo.setNumFeatures(from.getNumFeatures());
Set inputKeys = new LinkedHashSet();
inputKeys.add(from.getInputCol());
modelInfo.setInputKeys(inputKeys);
Set outputKeys = new LinkedHashSet();
outputKeys.add(from.getOutputCol());
modelInfo.setOutputKeys(outputKeys);
return modelInfo;
}
@Override
public Class getSource() {
return HashingTF.class;
}
@Override
public Class getTarget() {
return HashingTFModelInfo.class;
}
}