AlsPredictBatchOp extends BatchOperator<AlsPredictBatchOp> implements AlsPredictParams<AlsPredictBatchOp> { @Override public AlsPredictBatchOp linkFrom(BatchOperator<?>... inputs) { checkOpSize(2, inputs); BatchOperator model = inputs[0]; BatchOperator data = inputs[1]; this.setOutputTable(rate(model, data)); return this; } AlsPredictBatchOp();  AlsPredictBatchOp(Params params); @Override AlsPredictBatchOp linkFrom(BatchOperator<?>... inputs); Table rate(BatchOperator model, BatchOperator data);  }
@Test public void testRating() throws Exception { BatchOperator data = BatchOperator.fromTable( MLEnvironmentFactory.getDefault().createBatchTable(rows1, new String[]{"user", "item", "rating"})); ALS als = new ALS() .setUserCol("user") .setItemCol("item") .setRateCol("rating") .setLambda(0.01) .setRank(10) .setNumIter(10) .setPredictionCol("recommendations"); ALSModel model = als.fit(data); BatchOperator modelData = BatchOperator.fromTable(model.getModelData()); BatchOperator pred = new AlsPredictBatchOp() .setUserCol("user").setItemCol("item").setPredictionCol("predicted_rating").linkFrom(modelData, data); checkRatingError(pred); }