The Cortex class provides methods for predicting future states of twins and aggregates using the Cortex prediction engine. It can return predictions either mapped to human-readable embedding inputs or as raw state vectors.
from avenieca.api.model import NextStateRequestnsr = NextStateRequest( module_id="aggregate001", recall=20, range=20, n=1, status="e")res, status = eca.cortex.predictions(data=nsr)if status == 200: print("Current state:") for twin in res.current_state: print(f" {twin.module_id}: {twin.state}") print("\nPredicted next state:") for twins in res.next_state: for twin in twins.list: print(f" {twin.module_id}: {twin.state}")
from avenieca.api.model import NextStateRequestnsr = NextStateRequest( module_id="aggregate001", recall=20, range=20, n=3, # Predict next 3 states status="e")res, status = eca.cortex.predictions_raw(data=nsr)if status == 200: print("Current state (raw):") for twin in res.current_state: print(f" {twin.module_id}: {twin.state}") print(f"\nPredicted next {len(res.next_state)} states:") for i, twins in enumerate(res.next_state): print(f"\n Step {i+1}:") for twin in twins.list: print(f" {twin.module_id}: {twin.state}")
import osfrom avenieca.api.eca import ECAfrom avenieca.api.model import Config, NextStateRequest# Initialize clientconfig = Config( uri="http://localhost:2580/v1", username=os.getenv("USERNAME"), password=os.getenv("PASSWORD"))eca = ECA(config)# Make prediction requestrequest = NextStateRequest( module_id="air_conditioner", recall=10, # Look back 10 states range=5, # Consider 5 nearest sequences n=2, # Predict next 2 states status="e", # Only use 'existing' status sequences store_response=True, # Save this prediction store_sequence=False # Don't create new sequence)# Get human-readable predictionsres, status = eca.cortex.predictions(data=request)if status == 200: # Display current state print("Current State:") for twin in res.current_state: print(f" Module: {twin.module_id}") print(f" ESS ID: {twin.ess_id}") print(f" State: {twin.state}") # Display predictions print(f"\nPredicted States:") for step_num, twins_set in enumerate(res.next_state, 1): print(f"\n Prediction {step_num}:") for twin in twins_set.list: print(f" {twin.module_id}: {twin.state}")