Open Peter-Devine opened 4 years ago
Hi,
This library does not support multithreading yet, but instances of Predictor
are thread-safe.
So if you have many FVec
objects, you can share and use a Predictor
across multiple threads like below:
// Predictor predictor = ...;
// List<SimpleEntry<Integer, FVec>> data = ...;
OptionalDouble logloss = data.parallelStream()
.mapToDouble(pair -> {
double predValue = predictor.predictSingle(pair.getValue());
predValue = Math.min(Math.max(predValue, 1e-15), 1 - 1e-15);
int actual = pair.getKey();
return actual * Math.log(predValue) + (1 - actual) * Math.log(1 - predValue);
})
.average();
logloss.ifPresent(d -> System.out.println("Logloss (parallel): " + (-d)));
I know that the XGBoost package itself supports multithreading of the prediction task. Does this predictor implementation also support multithreading? If not, how could I go about adding it?