The Altair Community is migrating to a new platform to provide a better experience for you. In preparation for the migration, the Altair Community is on read-only mode from October 28 - November 6, 2024. Technical support via cases will continue to work as is. For any urgent requests from Students/Faculty members, please submit the form linked here
exampleSet.getExampleFromId returns null
I want to retrieve an example object by the "exampleSet.getExampleFromId" method, but got an NullPointerException error, anybody can tell me how to use this method?
Sample source likes this (Simplified Version)
-------------------------------------------------------------------------------------
Set<Double> exampleIds = new HashSet<Double>(exampleSet.size());
for (Example example: exampleSet) {
exampleIds.add(example.getId());
}
for (Double exampleId: exampleIds) {
Example example = exampleSet.getExampleFromId(exampleId);
example.getWeight();
}
-------------------------------------------------------------------------------------
Sample source likes this (Simplified Version)
-------------------------------------------------------------------------------------
Set<Double> exampleIds = new HashSet<Double>(exampleSet.size());
for (Example example: exampleSet) {
exampleIds.add(example.getId());
}
for (Double exampleId: exampleIds) {
Example example = exampleSet.getExampleFromId(exampleId);
example.getWeight();
}
-------------------------------------------------------------------------------------
Tagged:
0
Answers
hard to tell without an error message. Does your example set actually have an id attribute?
Best,
Simon
Best,
Simon
Problem resolved by adding ExampleSet.remapIds().
Thank you very much.
Yours ZHENG