onnx / onnx/models

Extracting the prediction Result from the OnnxTensor

Open
#545 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

question
Dominant language
Jupyter Notebook
Stars
9.8k
Forks
1.6k
PR merge metrics
No merged PRs in 30d

Description

Problem

How do I extract the prediction probability values from the result OnnxTensor after we use session.run() in Java?

Question

I am taking a string as in input from the Command Line.
I already have a ML model saved in the onnx format and I'm only performing inference in Java. It is a Vectorizer + RandomForest pipeline.

I'm converting the string to a String[][] array and storing it as an onnxtensor. Next I'm putting the onnxtensor with the input column name in a HashMap<String, OnnxTensor>()

OrtSession.Result results = session.run(Collections.singletonMap(inputMeta.getName(), inputTensor))

The results is as follows:

OnnxTensor(info=TensorInfo(javaType=INT64,onnxType=ONNX_TENSOR_ELEMENT_DATA_TYPE_INT64,shape=[1]))
OnnxSequence(info=SequenceInfo(length=1,type=MapInfo(size=2,keyType=INT64,valueType=FLOAT)))

How do I extract the prediction probabilities from this object ?

Also I'm not sure if I'm doing the whole thing right, so any suggestions would be really helpful.

Thanks

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Java session.run entry point and the reported OnnxTensor and OnnxSequence result types. Determine how the returned sequence and map values are represented, then verify the extraction approach against the stated prediction-probability goal; done means the result structure and a working Java access path are documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
machine-learning
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.