import os
import pickle
import json
import numpy
import joblib
from sklearn.linear_model import Ridge
from azureml.core.model import Model

def init():
    global model
    # note here "sklearn_regression_model.pkl" is the name of the model registered under
    # this is a different behavior than before when the code is run locally, even though the code is the same.
    model_path = os.path.join(os.getenv('AZUREML_MODEL_DIR'), 'sklearn_regression_model.pkl')
    # deserialize the model file back into a sklearn model
    model = joblib.load(model_path)

# note you can pass in multiple rows for scoring
def run(raw_data):
    try:
        data = json.loads(raw_data)['data']
        data = numpy.array(data)
        result = model.predict(data)
        # you can return any data type as long as it is JSON-serializable
        return result.tolist()
    except Exception as e:
        error = str(e)
        return error

@@ -7,22 +7,8 @@
  os%0A
-import pickle%0A
 impo
@@ -45,84 +45,8 @@
 blib
-%0Afrom sklearn.linear_model import Ridge%0Afrom azureml.core.model import Model
 %0A%0Ade
@@ -165,119 +165,8 @@
 der%0A
-    # this is a different behavior than before when the code is run locally, even though the code is the same.%0A
     

remove unused imports