Closed neomatrix369 closed 3 years ago
xgbModel.predict(data).get(0).getOutput().getValues()
returns the array of regressed outputs from that prediction. As in your case it's a single dimensional regression then there is only one element and so xgbModel.predict(data).get(0).getOutput().getValues()[0]
is the regressed value.
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.
We could add a
public DimensionTuple get(int idx)
method toRegressor
which would return the single dimension requested, and then you could callgetValue()
on that if you wanted, but it's about the same.
Yes that would be good to have, and a bit more intuitive as well.
Would also be good to show this in the notebooks, so it becomes obvious how to get the values out, its a bit of nested calls before we can get to the value(s). Maybe I'll do a pull request.
xgbModel.predict(data).get(0).getOutput().getValues()
returns the array of regressed outputs from that prediction. As in your case it's a single dimensional regression then there is only one element and soxgbModel.predict(data).get(0).getOutput().getValues()[0]
is the regressed value.
Thanks for this
We could add a
public DimensionTuple get(int idx)
method toRegressor
which would return the single dimension requested, and then you could callgetValue()
on that if you wanted, but it's about the same.Yes that would be good to have, and a bit more intuitive as well.
Would also be good to show this in the notebooks, so it becomes obvious how to get the values out, its a bit of nested calls before we can get to the value(s). Maybe I'll do a pull request.
Well it's only the getValues()
and then indexing the regressed value that's different from accessing any other predicted output. But I'll expand the javadoc a little and add the extra accessor.
The regression tutorial should have a note about how the multidimensional nature affects the regression objects, I thought that was in there but it's probably elsewhere in the docs.
Nice work @Craigacp loving these new PRs and changes
Ask the question I'm trying to unpack the prediction results after calling
model.predict(data)
, I get aArrayList
ofPrediction
items.Each
Prediction
item in my case is of typeRegressor.DimensionTuple
, there is agetOutput()
method and agetValues()
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 thisxgbModel.predict(data).get(0).getOutput().getValues()
, I get this[D@6b788c95
, thegetDimensionNamesString()
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.