question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How do we unpack a DimensionTuple?

See original GitHub issue

Ask the question I’m trying to unpack the prediction results after calling model.predict(data), I get a ArrayList of Prediction items.

Each Prediction item in my case is of type Regressor.DimensionTuple, there is a getOutput() method and a getValues() on it but neither give me the prediction value (numeric). It seems there isn’t an easy method/API to get this out.

When I call this xgbModel.predict(data).get(0).getOutput(), I get this (DIM-0,5.982707500457764) When I call this xgbModel.predict(data).get(0).getOutput().getValues(), I get this [D@6b788c95, the getDimensionNamesString() works but not the one to get the value corresponding to it.

What am I not doing? This I believe is an important function. I have been looking at the docs at https://tribuo.org/learn/4.0/javadoc/org/tribuo/regression/Regressor.DimensionTuple.html

Is your question about a specific Tribuo class? Class Regressor.DimensionTuple,

Additional context Using the prediciton results to do further analysis.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
neomatrix369commented, May 11, 2021

Nice work @Craigacp loving these new PRs and changes

1reaction
Craigacpcommented, Jan 28, 2021

We could add a public DimensionTuple get(int idx) method to Regressor which would return the single dimension requested, and then you could call getValue() on that if you wanted, but it’s about the same.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to unpack a tuple for looping without being dimension ...
This relies on a couple of tricks. First, itertools.product() is a function which generates tuples from iterables. for i in range(a): ...
Read more >
Unpack a tuple and list in Python - nkmk note
In Python, you can assign elements of a tuple or list to multiple variables. It is called sequence unpacking.
Read more >
Initialize Numpy Arrays with Tuple Unpacking ... - Github-Gist
This post shows multiple (equivalent) methods to initialize a new numpy array that takes the same shape as A1 - with either random...
Read more >
Tuple unpacking - Python Morsels
Tuple unpacking describes the shape of the tuple you're unpacking. So the number of variables you're unpacking into must be the same as...
Read more >
How to Find the Shape of a Python Tuple or List
This procedure gets more complicated for a tuple of tuples or a list of lists. You can think of these as 2-dimensional tuples...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found