Upload 3 files
Browse files- conda_env_v_1_0_0.yml +27 -0
- model.pkl +3 -0
- scoring_file_v_2_0_0.py +58 -0
conda_env_v_1_0_0.yml
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Conda environment specification. The dependencies defined in this file will
|
| 2 |
+
# be automatically provisioned for runs with userManagedDependencies=False.
|
| 3 |
+
|
| 4 |
+
# Details about the Conda environment file format:
|
| 5 |
+
# https://conda.io/docs/user-guide/tasks/manage-environments.html#create-env-file-manually
|
| 6 |
+
|
| 7 |
+
name: project_environment
|
| 8 |
+
dependencies:
|
| 9 |
+
# The python interpreter version.
|
| 10 |
+
# Currently Azure ML only supports 3.8 and later.
|
| 11 |
+
- python=3.9.19
|
| 12 |
+
|
| 13 |
+
- pip:
|
| 14 |
+
- azureml-train-automl-runtime==1.57.0
|
| 15 |
+
- inference-schema
|
| 16 |
+
- xgboost<=1.5.2
|
| 17 |
+
- azureml-interpret==1.57.0
|
| 18 |
+
- azureml-defaults==1.57.0
|
| 19 |
+
- numpy==1.23.5
|
| 20 |
+
- pandas==1.3.5
|
| 21 |
+
- scikit-learn==1.5.1
|
| 22 |
+
- prophet==1.1.4
|
| 23 |
+
- holidays==0.54
|
| 24 |
+
- psutil==5.9.3
|
| 25 |
+
channels:
|
| 26 |
+
- anaconda
|
| 27 |
+
- conda-forge
|
model.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7e9a93cc6f8d9cdbfa6304f0579c8b323a51c9be06c69620bd3ea1bca5b8faa1
|
| 3 |
+
size 268686
|
scoring_file_v_2_0_0.py
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# ---------------------------------------------------------
|
| 2 |
+
# Copyright (c) Microsoft Corporation. All rights reserved.
|
| 3 |
+
# ---------------------------------------------------------
|
| 4 |
+
import json
|
| 5 |
+
import logging
|
| 6 |
+
import os
|
| 7 |
+
import pickle
|
| 8 |
+
import numpy as np
|
| 9 |
+
import pandas as pd
|
| 10 |
+
import joblib
|
| 11 |
+
|
| 12 |
+
import azureml.automl.core
|
| 13 |
+
from azureml.automl.core.shared import logging_utilities, log_server
|
| 14 |
+
from azureml.telemetry import INSTRUMENTATION_KEY
|
| 15 |
+
|
| 16 |
+
from inference_schema.schema_decorators import input_schema, output_schema
|
| 17 |
+
from inference_schema.parameter_types.numpy_parameter_type import NumpyParameterType
|
| 18 |
+
from inference_schema.parameter_types.pandas_parameter_type import PandasParameterType
|
| 19 |
+
from inference_schema.parameter_types.standard_py_parameter_type import StandardPythonParameterType
|
| 20 |
+
|
| 21 |
+
data_sample = PandasParameterType(pd.DataFrame({"day": pd.Series([0], dtype="int8"), "mnth": pd.Series([0], dtype="int8"), "year": pd.Series([0], dtype="int16"), "season": pd.Series([0], dtype="int8"), "holiday": pd.Series([False], dtype="bool"), "weekday": pd.Series([0], dtype="int8"), "workingday": pd.Series([False], dtype="bool"), "weathersit": pd.Series([0], dtype="int8"), "temp": pd.Series([0.0], dtype="float32"), "atemp": pd.Series([0.0], dtype="float32"), "hum": pd.Series([0.0], dtype="float32"), "windspeed": pd.Series([0.0], dtype="float32")}))
|
| 22 |
+
input_sample = StandardPythonParameterType({'data': data_sample})
|
| 23 |
+
|
| 24 |
+
result_sample = NumpyParameterType(np.array([0]))
|
| 25 |
+
output_sample = StandardPythonParameterType({'Results':result_sample})
|
| 26 |
+
sample_global_parameters = StandardPythonParameterType(1.0)
|
| 27 |
+
|
| 28 |
+
try:
|
| 29 |
+
log_server.enable_telemetry(INSTRUMENTATION_KEY)
|
| 30 |
+
log_server.set_verbosity('INFO')
|
| 31 |
+
logger = logging.getLogger('azureml.automl.core.scoring_script_v2')
|
| 32 |
+
except:
|
| 33 |
+
pass
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
def init():
|
| 37 |
+
global model
|
| 38 |
+
# This name is model.id of model that we want to deploy deserialize the model file back
|
| 39 |
+
# into a sklearn model
|
| 40 |
+
model_path = os.path.join(os.getenv('AZUREML_MODEL_DIR'), 'model.pkl')
|
| 41 |
+
path = os.path.normpath(model_path)
|
| 42 |
+
path_split = path.split(os.sep)
|
| 43 |
+
log_server.update_custom_dimensions({'model_name': path_split[-3], 'model_version': path_split[-2]})
|
| 44 |
+
try:
|
| 45 |
+
logger.info("Loading model from path.")
|
| 46 |
+
model = joblib.load(model_path)
|
| 47 |
+
logger.info("Loading successful.")
|
| 48 |
+
except Exception as e:
|
| 49 |
+
logging_utilities.log_traceback(e, logger)
|
| 50 |
+
raise
|
| 51 |
+
|
| 52 |
+
@input_schema('Inputs', input_sample)
|
| 53 |
+
@input_schema('GlobalParameters', sample_global_parameters, convert_to_provided_type=False)
|
| 54 |
+
@output_schema(output_sample)
|
| 55 |
+
def run(Inputs, GlobalParameters=1.0):
|
| 56 |
+
data = Inputs['data']
|
| 57 |
+
result = model.predict(data)
|
| 58 |
+
return {'Results':result.tolist()}
|