Full Utility AI Platform Deployment

The Business Problem: Moving from Analytics Pilots to Enterprise Scale

Utilities often find themselves stuck in a cycle of pilots. A predictive maintenance proof of concept runs on a small data set. An outage prediction model is tested in isolation during one storm season. These efforts demonstrate potential but rarely graduate into production systems that run continuously, scale across the enterprise, and deliver measurable results.

Barriers to scaling include disparate infrastructure, limited deployment pipelines, and governance concerns. Critical questions arise: How do we ensure that models are auditable and compliant? How do we integrate them into operational workflows without disrupting critical systems? How do we manage multiple models and ensure they stay accurate as conditions evolve?

Without a structured approach to platform deployment, utilities risk accumulating isolated use cases without building the robust infrastructure needed to support long-term AI adoption.

The Analytics Solution: An Enterprise AI Platform

Deploying an enterprise-grade AI platform transforms analytics from isolated scripts into an integrated operational capability. Such platforms combine scalable compute, unified data storage, model lifecycle management, and real-time serving capabilities under a single architecture.

Key components include:

By consolidating these capabilities, utilities can deploy models that run reliably at scale, retrain automatically, and deliver predictions directly where they are needed—from outage planning dashboards to SCADA-linked monitoring tools.

Business Impact

A fully deployed AI platform supports real-time decision-making across the utility. Predictive maintenance scores continuously update from streaming SCADA data. Outage risk models run automatically as new weather alerts arrive. Load forecasts feed into operational systems without manual exports.

This reduces latency between insight and action, increases the operational relevance of analytics, and establishes AI as a trusted part of utility workflows. Over time, it also reduces cost and complexity by replacing fragmented point solutions with a unified, scalable platform.

Transition to the Demo

In this chapter’s demo, we will simulate deploying a predictive maintenance model onto an enterprise AI platform. We will:

This example illustrates how a well-architected AI platform moves machine learning from the realm of isolated pilots into the core of utility operations, delivering sustained value at enterprise scale.

pyfile shortcode: missing param 'file'. Example: {{< pyfile file="script.py" >}}


Code

"""
Chapter 20: Full Utility AI Platform Deployment
Deploy ML models as APIs using FastAPI, Docker, and Kubernetes with monitoring.
"""

import pandas as pd
import numpy as np
from sklearn.ensemble import RandomForestClassifier
from fastapi import FastAPI
from pydantic import BaseModel
import joblib
import uvicorn
import os

# --- Model Training ---
def train_model():
    np.random.seed(42)
    temp = np.random.normal(60, 5, 500)
    vibration = np.random.normal(0.2, 0.05, 500)
    oil_quality = np.random.normal(70, 10, 500)
    age = np.random.randint(1, 30, 500)
    failure_prob = 1 / (1 + np.exp(-(0.05*(temp-65) + 8*(vibration-0.25))))
    failure = np.random.binomial(1, failure_prob)

    X = pd.DataFrame({"Temperature": temp, "Vibration": vibration, "OilQuality": oil_quality, "Age": age})
    y = failure

    model = RandomForestClassifier(n_estimators=100, random_state=42).fit(X, y)
    joblib.dump(model, "transformer_model.pkl")
    print("Model trained and saved.")
    return model

# --- API Setup ---
app = FastAPI()
class TransformerInput(BaseModel):
    Temperature: float
    Vibration: float
    OilQuality: float
    Age: int

if os.path.exists("transformer_model.pkl"):
    model = joblib.load("transformer_model.pkl")
else:
    model = train_model()

@app.post("/predict")
def predict(data: TransformerInput):
    X = np.array([[data.Temperature, data.Vibration, data.OilQuality, data.Age]])
    pred = model.predict(X)[0]
    return {"failure_risk": int(pred)}

# --- Monitoring Integration ---
@app.get("/health")
def health_check():
    """
    Health endpoint for Kubernetes and monitoring probes.
    """
    return {"status": "ok"}

if __name__ == "__main__":
    uvicorn.run(app, host="0.0.0.0", port=8000)