Search in sources :

Example 1 with ModelEvaluatorFactory

use of org.jpmml.evaluator.ModelEvaluatorFactory in project openscoring by openscoring.

the class ModelRegistry method load.

@SuppressWarnings(value = { "resource" })
public Model load(InputStream is) throws Exception {
    CountingInputStream countingIs = new CountingInputStream(is);
    HashingInputStream hashingIs = new HashingInputStream(Hashing.md5(), countingIs);
    PMML pmml = unmarshal(hashingIs, this.validate);
    this.visitorBattery.applyTo(pmml);
    ModelEvaluatorFactory modelEvaluatorFactory = this.modelEvaluatorFactory;
    Evaluator evaluator = modelEvaluatorFactory.newModelEvaluator(pmml);
    evaluator.verify();
    Model model = new Model(evaluator);
    model.putProperty(Model.PROPERTY_FILE_SIZE, countingIs.getCount());
    model.putProperty(Model.PROPERTY_FILE_MD5SUM, (hashingIs.hash()).toString());
    return model;
}
Also used : CountingInputStream(com.google.common.io.CountingInputStream) PMML(org.dmg.pmml.PMML) HasPMML(org.jpmml.evaluator.HasPMML) ModelEvaluatorFactory(org.jpmml.evaluator.ModelEvaluatorFactory) Evaluator(org.jpmml.evaluator.Evaluator) HashingInputStream(com.google.common.hash.HashingInputStream)

Aggregations

HashingInputStream (com.google.common.hash.HashingInputStream)1 CountingInputStream (com.google.common.io.CountingInputStream)1 PMML (org.dmg.pmml.PMML)1 Evaluator (org.jpmml.evaluator.Evaluator)1 HasPMML (org.jpmml.evaluator.HasPMML)1 ModelEvaluatorFactory (org.jpmml.evaluator.ModelEvaluatorFactory)1