Hi,
I exported
a trained autoencoder model as POJO and now want to use it to predict new
cases. However, it seems there is no implementation for a prediction method
Exception in thread "main" java.lang.RuntimeException: Unimplemented 55 at
hex.genmodel.easy.EasyPredictModelWrapper.predictAutoEncoder(EasyPredictModelWrapper.java:103)at
main.main(main.java:71)
I'm really curious about that because which value has the POJO if I'm not able to make any predictions with it?
Best regards,
Roberto
--
You received this message because you are subscribed to the Google Groups "H2O Open Source Scalable Machine Learning - h2ostream" group.
To unsubscribe from this group and stop receiving emails from it, send an email to h2ostream+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Hi Tom,
your right, the POJO contains a score method, but I was hoping that there will be also an Easy-API wrapper that can be used with it. Would result in a more comfortable and unified API.
I'm not a Java programmer, but I would expect that the resulting "AutoEncoderModelPrediction" object afterwards give me access on (1) the reconstructed values (like with the predict function from the R and Python API), (2) the per-feature reconstruction error and (3) the average reconstruction error ( (2) and (3) in a similar way like the anomaly method from the R/Python-API).
So I edited my test code on the "AutoEncoderModelPrediction" class like this:
public class AutoEncoderModelPrediction extends AbstractPrediction {
public double[] predictions;
public double[] feature;
public double[] reconstrunctionError;
public double averageReconstructionError;
}
and on EasyPredictModelWrapper (just update the predictAutoEncoder method) like this:
public AutoEncoderModelPrediction predictAutoEncoder(RowData data) throws PredictException {
double[] preds = preamble(ModelCategory.AutoEncoder, data);
// save predictions
AutoEncoderModelPrediction p = new AutoEncoderModelPrediction();
p.predictions = preds;
// save raw data
double[] rawData = new double[m.nfeatures()];
setToNaN(rawData);
fillRawData(data, rawData);
p.feature = rawData;
//calculate and reconstruction error
double[] reconstrunctionError = new double [rawData.length];
for (int i = 0; i < reconstrunctionError.length; i++) {
reconstrunctionError[i] = Math.pow(rawData[i] - preds[i],2);
}
p.reconstrunctionError = reconstrunctionError;
//calculate mean squared error
double sum = 0;
for (int i = 0; i < reconstrunctionError.length; i++) {
sum = sum + reconstrunctionError[i];
}
p.averageReconstructionError = sum/reconstrunctionError.length;
return p;
}
Now I can use something like this inside my little test program (the main java from your POJO documentation) to get the result for a specific feature vector:
AutoEncoderModelPrediction p = model.predictAutoEncoder(row);
System.out.println("Got predictions ...");
System.out.println(Arrays.toString(p.predictions));
System.out.println("\nRaw data ...");
System.out.println(Arrays.toString(p.feature));
System.out.println("\nReconstruction error ...");
System.out.println(Arrays.toString(p.reconstrunctionError));
System.out.println("\nAverage reconstruction error ...");
System.out.println(p.averageReconstructionError);
Will
similar functionality find their way into your product?
Best
Roberto