svm-model / inference.py
niruthiha's picture
Upload inference.py with huggingface_hub
01e42e6 verified
raw
history blame contribute delete
501 Bytes
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)
}