Search in sources :

Example 1 with ItemSetFeature

use of org.jpmml.sparkml.ItemSetFeature in project jpmml-sparkml by jpmml.

the class FPGrowthModelConverter method getFeatures.

@Override
public List<Feature> getFeatures(SparkMLEncoder encoder) {
    FPGrowthModel model = getTransformer();
    String itemsCol = model.getItemsCol();
    // Convert from plural to singular
    if (itemsCol.endsWith("s")) {
        itemsCol = itemsCol.substring(0, itemsCol.length() - 1);
    }
    DataField transactionDataField = encoder.createDataField(FieldName.create("transaction"), OpType.CATEGORICAL, DataType.STRING);
    DataField itemDataField = encoder.createDataField(FieldName.create(itemsCol), OpType.CATEGORICAL, DataType.STRING);
    Feature feature = new ItemSetFeature(encoder, itemDataField);
    return Collections.singletonList(feature);
}
Also used : ItemSetFeature(org.jpmml.sparkml.ItemSetFeature) DataField(org.dmg.pmml.DataField) FPGrowthModel(org.apache.spark.ml.fpm.FPGrowthModel) Feature(org.jpmml.converter.Feature) ItemSetFeature(org.jpmml.sparkml.ItemSetFeature)

Aggregations

FPGrowthModel (org.apache.spark.ml.fpm.FPGrowthModel)1 DataField (org.dmg.pmml.DataField)1 Feature (org.jpmml.converter.Feature)1 ItemSetFeature (org.jpmml.sparkml.ItemSetFeature)1