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