generated from sub-mod/s2i-flask-notebook
-
Notifications
You must be signed in to change notification settings - Fork 8
/
MyModel.py
42 lines (37 loc) · 1.29 KB
/
MyModel.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import json
from flask import Flask, jsonify, request
from prediction import predict, predict1, predict2, predict3
from functools import wraps
from time import time
class MyModel(object):
"""
Model template. You can load your model parameters in __init__ from a location accessible at runtime
"""
def __init__(self):
"""
Add any initialization parameters. These will be passed at runtime from the graph definition parameters defined in your seldondeployment kubernetes resource manifest.
"""
print("Initializing")
def predict(self,X):
"""
Return a prediction.
Parameters
----------
X : array-like
feature_names : array of feature names (optional)
"""
print("Predict called - will run idenity function")
X = predict(X)
return X
def send_feedback(self,features,feature_names,reward,truth,routing):
"""
Handle feedback
Parameters
----------
features : array - the features sent in the original predict request
feature_names : array of feature names. May be None if not available.
reward : float - the reward
truth : array with correct value (optional)
"""
print("Send feedback called")
return []