use of org.apache.spark.ml.classification.LinearSVCModel in project jpmml-sparkml by jpmml.
the class LinearSVCModelConverter method encodeModel.
@Override
public MiningModel encodeModel(Schema schema) {
LinearSVCModel model = getTransformer();
Transformation transformation = new AbstractTransformation() {
@Override
public FieldName getName(FieldName name) {
return FieldNameUtil.create("threshold", name);
}
@Override
public Expression createExpression(FieldRef fieldRef) {
return PMMLUtil.createApply(PMMLFunctions.THRESHOLD).addExpressions(fieldRef, PMMLUtil.createConstant(model.getThreshold()));
}
};
Schema segmentSchema = schema.toAnonymousRegressorSchema(DataType.DOUBLE);
Model linearModel = LinearModelUtil.createRegression(this, model.coefficients(), model.intercept(), segmentSchema).setOutput(ModelUtil.createPredictedOutput(FieldName.create("margin"), OpType.CONTINUOUS, DataType.DOUBLE, transformation));
return MiningModelUtil.createBinaryLogisticClassification(linearModel, 1d, 0d, RegressionModel.NormalizationMethod.NONE, false, schema);
}
Aggregations