Class MLIntegrationExamples.OnnxAdapter

java.lang.Object
neqsim.process.safety.risk.ml.MLIntegrationExamples.BaseMLAdapter
neqsim.process.safety.risk.ml.MLIntegrationExamples.OnnxAdapter
All Implemented Interfaces:
Serializable, MLIntegrationExamples.MLModelAdapter
Enclosing class:
MLIntegrationExamples

public static class MLIntegrationExamples.OnnxAdapter extends MLIntegrationExamples.BaseMLAdapter
Adapter for ONNX Runtime models.

ONNX (Open Neural Network Exchange) provides a platform-independent format for ML models. This adapter loads ONNX models using the ONNX Runtime Java API.

Dependencies Required

<dependency>
  <groupId>com.microsoft.onnxruntime</groupId>
  <artifactId>onnxruntime</artifactId>
  <version>1.15.1</version>
</dependency>
Since:
3.3.0
Version:
1.0
Author:
NeqSim Development Team
See Also:
  • Field Details

  • Constructor Details

    • OnnxAdapter

      public OnnxAdapter(String modelPath, List<String> inputFeatures)
      Creates an ONNX adapter.
      Parameters:
      modelPath - path to ONNX model file
      inputFeatures - list of input feature names in order
  • Method Details

    • load

      public void load()
      Loads the ONNX model.

      In production, this would use:

      env = OrtEnvironment.getEnvironment();
      session = env.createSession(modelPath, new OrtSession.SessionOptions());
      
    • predict

      public double predict(Map<String,Double> features)
      Description copied from interface: MLIntegrationExamples.MLModelAdapter
      Predicts output from input features.
      Parameters:
      features - input features as name-value map
      Returns:
      prediction score or probability
    • getModelPath

      public String getModelPath()
      Gets the model path.
      Returns:
      model path