File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change 1+ import pickle
2+ import json
3+ import numpy
4+ from sklearn .externals import joblib
5+ from sklearn .linear_model import Ridge
6+ from azureml .core .model import Model
7+
8+ def init ():
9+ global model
10+ # note here "sklearn_regression_model.pkl" is the name of the model registered under
11+ # this is a different behavior than before when the code is run locally, even though the code is the same.
12+ model_path = Model .get_model_path ('sklearn_regression_model.pkl' )
13+ # deserialize the model file back into a sklearn model
14+ model = joblib .load (model_path )
15+
16+ # note you can pass in multiple rows for scoring
17+ def run (raw_data ):
18+ try :
19+ data = json .loads (raw_data )['data' ]
20+ data = numpy .array (data )
21+ result = model .predict (data )
22+ except Exception as e :
23+ result = str (e )
24+ return json .dumps ({"result" : result .tolist ()})
You can’t perform that action at this time.
0 commit comments