Giter VIP home page Giter VIP logo

Comments (3)

vruusmann avatar vruusmann commented on August 18, 2024

Your PMML looks fine in this regard.

The important thing to understand is that Evaluator#getActiveFields() defines the "public API" of your NN model, whereas NeuralInput elements define the first layer of the "private API" of your NN model.

For example, take the "TxnChannelCodeATM" field. The first element of Evaluator#getActiveFields() is an org.jpmml.evaluator.InputField object, that has name=TxnChannelCodeATM, opType=categorical and dataType=string; there are further Evaluator API methods that let you query its valid value space, which would be returned as a set of ATM, POS and OnL. If you execute your NN model then you would specify the corresponding input value like this:

Evaluator evaluator = ..
Map<FieldName, Object> arguments = ...
InputField tccaInput = (evaluator.getInputFields()).get(0); // In real life, use field name-based lookup, not positional lookup
arguments.put(tccaInput.getName(), tccaInput.prepare("POS"));
Map<FieldName, ?> result = evaluator.evaluate(arguments);

The NeuralNetwork element takes the input value from "public API" layer and can do whatever it likes with it in "private API" layer. Typically, categorical input values are one-hot-encoded, which means that the "TxnChannelCodeATM" would be expanded into three binary indicator fields TxnChannelCodeATM==ATM, TxnChannelCodeATM==POS and TxnChannelCodeATM==OnL (these are your first three NeuralInput elements). However, an NN model might choose to ignore some categories, combine several categories into one, compute interactions between the categories of different input fields etc.

Some other notes. You don't need to set various "numberOf" attributes such as DataDictionary@numberOfFields, NeuralInputs@numberOfInputs, NeuralLayer@numberOfNeurons, NeuralOutputs@numberOfOutputs etc. Also, you define 131 NeuralInput elements, but only use 10 of them (referenced via Con@from attributes, on lines 2026 -- 2048). Perhaps your NN model is missing some middle layers?

from jpmml-evaluator.

aminaaslam avatar aminaaslam commented on August 18, 2024

Thanks @vruusmann. When i debug this code
InputField tccaInput = ((evaluator.getInputFields()).get(0));
I do see values of the categorical field like ATM,POS in values array but i am not able access them. Is that method not exposed??

from jpmml-evaluator.

vruusmann avatar vruusmann commented on August 18, 2024

What exactly do you mean by "not able to access them"? Did you use the code example that is provided in the "Querying the data schema of models" section of README.md file?

Anyway, the lesson here is that you're only supposed to care about model input fields at a "public API" level. If the Evaluator#getInputFields() returns a 100-element list, then this is the information that you're supposed to work with. Internally, a NN model may keep those 100 input values as-is, or expand them to 132 transformed input fields (eg. by binarizing the values of categorical input fields) - it's a low-level algorithmic detail.

from jpmml-evaluator.

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.