| 21 | raise |
| 22 | |
| 23 | def prepare_input_data(self, connection_status): |
| 24 | # Example: Normalize and reshape input data based on expected model input |
| 25 | try: |
| 26 | # Assuming connection_status is a dictionary with relevant features |
| 27 | features = [ |
| 28 | connection_status.get('latency', 0), |
| 29 | connection_status.get('bandwidth', 0), |
| 30 | connection_status.get('signal_strength', 0), |
| 31 | # Add more features as needed |
| 32 | ] |
| 33 | # Normalize features (example normalization) |
| 34 | features = np.array(features) / np.array([1000, 1000, 100]) # Example normalization factors |
| 35 | return features.reshape(1, -1) # Reshape for model input |
| 36 | except Exception as e: |
| 37 | logging.error(f"Error preparing input data: {e}") |
| 38 | raise |
| 39 | |
| 40 | async def predict_latency(self, connection_status): |
| 41 | try: |