Class MLIntegrationExamples

java.lang.Object
neqsim.process.safety.risk.ml.MLIntegrationExamples

public class MLIntegrationExamples extends Object
Examples and templates for integrating external ML frameworks with the risk system.

This class provides patterns and examples for integrating machine learning models from external frameworks like TensorFlow, PyTorch, ONNX, and scikit-learn with the NeqSim risk framework.

Supported Integration Patterns

  • ONNX Runtime - Platform-independent ML model execution
  • TensorFlow Java API - Direct TensorFlow model loading
  • Deep Java Library (DJL) - Unified API for multiple backends
  • REST API - External model serving endpoints

Usage Example

// Create adapter for external model
MLModelAdapter adapter =
    MLIntegrationExamples.createOnnxAdapter("/models/failure_predictor.onnx");

// Register with risk interface
RiskMLInterface mlInterface = new RiskMLInterface();
mlInterface.registerModel("failure_predictor", RiskMLInterface.ModelType.FAILURE_PREDICTION,
    adapter::predict);
Since:
3.3.0
Version:
1.0
Author:
NeqSim Development Team
  • Field Details

    • logger

      private static final org.apache.logging.log4j.Logger logger
  • Constructor Details

    • MLIntegrationExamples

      public MLIntegrationExamples()
  • Method Details

    • createOnnxFailurePredictor

      public static MLIntegrationExamples.OnnxAdapter createOnnxFailurePredictor(String modelPath)
      Creates an ONNX adapter for failure prediction.
      Parameters:
      modelPath - path to ONNX model
      Returns:
      configured adapter
    • createRestAnomalyDetector

      public static MLIntegrationExamples.RestApiAdapter createRestAnomalyDetector(String endpoint)
      Creates a REST API adapter for anomaly detection.
      Parameters:
      endpoint - model serving endpoint
      Returns:
      configured adapter
    • createTestFailurePredictor

      public static MLIntegrationExamples.ThresholdModel createTestFailurePredictor()
      Creates a simple threshold-based failure predictor for testing.
      Returns:
      threshold model
    • createTestAnomalyDetector

      public static MLIntegrationExamples.ThresholdModel createTestAnomalyDetector()
      Creates a simple threshold-based anomaly detector for testing.
      Returns:
      threshold model
    • main

      public static void main(String[] args)
      Demonstrates integration with RiskMLInterface.
      Parameters:
      args - command line arguments