File size: 501 Bytes
01e42e6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
from typing import Dict, List
import joblib
import numpy as np
def load_model():
model = joblib.load("model.pkl")
return model
def predict(inputs: Dict):
"""
Prediction function for the API
"""
model = load_model()
features = np.array(inputs['inputs']).reshape(1, -1)
prediction = model.predict(features)
probability = model.predict_proba(features).max()
return {
"prediction": int(prediction[0]),
"confidence": float(probability)
}
|