Class MLIntegrationExamples
java.lang.Object
neqsim.process.safety.risk.ml.MLIntegrationExamples
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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBase adapter class with common functionality.static interfaceInterface for ML model adapters.static classAdapter for ONNX Runtime models.static classAdapter for REST API-based model serving.static classAdapter for TensorFlow SavedModel format.static classSimple threshold-based model for testing and fallback. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateOnnxFailurePredictor(String modelPath) Creates an ONNX adapter for failure prediction.createRestAnomalyDetector(String endpoint) Creates a REST API adapter for anomaly detection.Creates a simple threshold-based anomaly detector for testing.Creates a simple threshold-based failure predictor for testing.static voidDemonstrates integration with RiskMLInterface.
-
Field Details
-
logger
private static final org.apache.logging.log4j.Logger logger
-
-
Constructor Details
-
MLIntegrationExamples
public MLIntegrationExamples()
-
-
Method Details
-
createOnnxFailurePredictor
Creates an ONNX adapter for failure prediction.- Parameters:
modelPath- path to ONNX model- Returns:
- configured adapter
-
createRestAnomalyDetector
Creates a REST API adapter for anomaly detection.- Parameters:
endpoint- model serving endpoint- Returns:
- configured adapter
-
createTestFailurePredictor
Creates a simple threshold-based failure predictor for testing.- Returns:
- threshold model
-
createTestAnomalyDetector
Creates a simple threshold-based anomaly detector for testing.- Returns:
- threshold model
-
main
Demonstrates integration with RiskMLInterface.- Parameters:
args- command line arguments
-