Embedding Azure Machine Learning models into Excel workbooks for real-time business predictions — without leaving the spreadsheet environment.
A regional bank's credit team reviews 50-100 loan applications per day in Excel. Risk analysts manually score each application using a static scoring matrix — a process that takes 20 minutes per application and relies heavily on individual judgment, leading to inconsistent decisions and regulatory exposure.
A custom Excel function calls an Azure ML real-time endpoint, returning a risk score in under 2 seconds — directly in the analyst's existing workflow.
Function GetRiskScore(creditScore As Long, dti As Double,
loanAmt As Long) As String
Dim http As Object
Set http = CreateObject("MSXML2.XMLHTTP")
Dim endpoint As String
endpoint = "https://your-workspace.azureml.net/score"
Dim payload As String
payload = "{""Inputs"": {""data"": [{" &
"""credit_score"": " & creditScore & "," &
"""debt_to_income"": " & dti & "," &
"""loan_amount"": " & loanAmt & "}]}}"
http.Open "POST", endpoint, False
http.setRequestHeader "Content-Type", "application/json"
http.setRequestHeader "Authorization", "Bearer " & GetAPIKey()
http.Send payload
GetRiskScore = ParseRiskTier(http.responseText)
' Returns: LOW RISK / MEDIUM RISK / HIGH RISK
End Function
' Usage in Excel: =GetRiskScore(B2, C2, D2)
from sklearn.ensemble import GradientBoostingClassifier
from sklearn.model_selection import train_test_split
import pandas as pd, joblib
df = pd.read_csv("loan_history.csv")
features = ["credit_score","debt_to_income","loan_amount","employment_years"]
X, y = df[features], df["defaulted"]
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)
model = GradientBoostingClassifier(n_estimators=200, max_depth=4)
model.fit(X_train, y_train)
print(f"Accuracy: {model.score(X_test, y_test):.2%}")
# Output: Accuracy: 94.3%
joblib.dump(model, "loan_risk_model.pkl")
# Deploy to Azure ML real-time endpoint via Studio or CLI