Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can you provide a parameter to control the Separator of output result #10

Closed
Ying456123 opened this issue Sep 3, 2018 · 3 comments
Closed

Comments

@Ying456123
Copy link

Ying456123 commented Sep 3, 2018

Hi @vruusmann, through the code, I see the prediction name and probability name of output result is hard coded. Is it possible to provide a parameter to control the Separator of output result? For example, change probability(1) to probability-1

Below is the existing naming rules, and separator is brackets:

static
public OutputField createProbabilityField(DataType dataType, String value){
	return createProbabilityField(FieldName.create("probability(" + value + ")"), dataType, value);
}

Thanks a lot.

@vruusmann
Copy link
Member

.. prediction name and probability name of output result is hard coded.

That's intentional - helps to enforce a convention that all "function fields" are named as <name>(<arg1>, <arg2>, .., <argn>).

By this convention, probability is a "function field" whose name is probability which that takes exactly one argument (category label).

For example, change probability(1) to probability-1

"Conventions over configuration".

If you're unhappy with the default naming system, then you can always rename fields using the Visitor API of the JPMML-Model library (eg. class org.jpmml.model.visitors.FieldRenamer).

@Ying456123
Copy link
Author

Ying456123 commented Sep 4, 2018

@vruusmann
Thanks a lot. Just want to know how can I get the probability name fields when I creating the name mapping? I have load the pmml model by using the function:

PMML load(InputStream is)

And then get call getModels() to fetch the model, and call model.getOutput(), and get null result. But form the pmml file, I can see there are two output fields. Do you have any advice? Thanks a lot.

<Output>
	<OutputField name="probability_0" optype="continuous" dataType="float" feature="probability" value="0"/>
	<OutputField name="probability_1" optype="continuous" dataType="float" feature="probability" value="1"/>
</Output>

test_classifier_pmml_46.tar.gz

@vruusmann
Copy link
Member

vruusmann commented Sep 4, 2018

And then get call getModels() to fetch the model, and call model.getOutput(), and get null result.

This sequence of calls queries the top-level model element. In your file, the top-level model element is the MiningModel element, which in fact does not specify an Output child element - so the null result value is to be expected.

Anyway, one is not supposed to query PMML elements directly. You should be using the Evaluator#getOutputFields() method, which would give you a two-element list (defined by the last segment on lines 936 -- 939 of your PMML file).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants