Code Monkey home page Code Monkey logo

Comments (2)

vruusmann avatar vruusmann commented on August 11, 2024

Apache Spark ML decision tree models do not support such "execution flow" customizations. Therefore, it is impossible to generate the requested PMML markup automatically.

Possible workaround:

  1. Generate a "raw" PMML class model object by invoking ConverterUtil#toPMML(StructType, PipelineModel).
  2. Apply a (list of-) post-processing Visitor(s) to it.
  3. Save the "post-processed" PMML class model object to a file.

In your case, the Visitor needs to be modifying TreeModel elements (of the top-level MiningModel element). Here's a starting point:

PMML pmml = ConverterUtil.toPMML(...);

Visitor treeModelUpdater = new new AbstractVisitor(){

	@Override
	public VisitorAction visit(TreeModel treeModel){
		treeModel.setMissingValueStrategy(MissingValueStrategy.NULL_PREDICTION);
		treeModel.setMissingValuePenalty(0d);
		treeModel.setNoTrueChildStrategy(NoTrueChildStrategy.RETURN_NULL_PREDICTION);
	
		return VisitorAction.CONTINUE;
	}
};
treeModelUpdater.applyTo(pmml);

from jpmml-sparkml.

vruusmann avatar vruusmann commented on August 11, 2024

Related to #14

It should be possible to toggle PMML converters between two modes:

  1. "Missing value"-friendly (a missing input leads to a missing prediction).
  2. "Missing value"-hostile (a missing input raises an error, or leads to a non-missing default prediction).

from jpmml-sparkml.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.