This commit is contained in:
nonstoptimm 2021-09-15 12:12:22 +02:00
Родитель 62b44c64b4
Коммит 229b8972c4
2 изменённых файлов: 21 добавлений и 13 удалений

Просмотреть файл

@ -3,9 +3,9 @@
{
"cell_type": "markdown",
"source": [
"# Verseagility - Score Model\n",
"- A script to batch-score your endpoint after the deployment.\n",
"- Set your endpoint and keys in the function below\n",
"# Verseagility - Batch scoring of deployed model\r\n",
"- A script to batch-score your endpoint after the deployment\r\n",
"- Set your endpoint and keys in the function below\r\n",
"- Read your test data set which has a \"label\" column for the ground truth and a \"text\" column with the document to be scored"
],
"metadata": {}
@ -18,6 +18,7 @@
"import requests\r\n",
"import pandas as pd\r\n",
"import json\r\n",
"import configparser\r\n",
"from sklearn.metrics import classification_report\r\n",
"from sklearn.metrics import accuracy_score\r\n",
"from sklearn.metrics import confusion_matrix"
@ -39,10 +40,12 @@
"cell_type": "code",
"execution_count": null,
"source": [
"# Endpoint settings\r\n",
"endpoint = '[YOUR URL GOES HERE]'\r\n",
"region = '[YOUR REGION GOES HERE]'\r\n",
"key = '[YOUR KEY GOES HERE]'"
"# Get config file\r\n",
"config = configparser.ConfigParser()\r\n",
"config.read('../config.ini')\r\n",
"endpoint = config['API']['endpoint']\r\n",
"region = config['API']['region']\r\n",
"key = config['API']['key']"
],
"outputs": [],
"metadata": {}
@ -53,6 +56,7 @@
"source": [
"# Model scoring function\r\n",
"def score_model(df, endpoint, region, key):\r\n",
" '''Batch score model with multiple documents from a dataframe loaded above'''\r\n",
" # URL for the web service\r\n",
" scoring_uri = f'http://{endpoint}.{region}.azurecontainer.io/score'\r\n",
" # Set the content type\r\n",

Просмотреть файл

@ -3,14 +3,17 @@
{
"cell_type": "markdown",
"source": [
"# Verseagility Endpoint Request"
"# Verseagility - Single endpoint request to deployed model\r\n",
"- A notebook to score your endpoint for testing purpose with a single request\r\n",
"- For batch scoring, see the Batch Scoring notebook in the same folder"
],
"metadata": {}
},
{
"cell_type": "code",
"execution_count": 20,
"execution_count": 3,
"source": [
"# Import packages\r\n",
"import json\r\n",
"import requests\r\n",
"import configparser"
@ -20,7 +23,7 @@
},
{
"cell_type": "code",
"execution_count": 21,
"execution_count": 4,
"source": [
"# Get config file\r\n",
"config = configparser.ConfigParser()\r\n",
@ -34,9 +37,10 @@
},
{
"cell_type": "code",
"execution_count": 24,
"execution_count": 5,
"source": [
"def score_model(text, endpoint=endpoint, region=region, key=key):\r\n",
" '''Score model endpoint with a single request'''\r\n",
" # URL for the web service\r\n",
" scoring_uri = f'http://{endpoint}.{region}.azurecontainer.io/score'\r\n",
" # Set the content type\r\n",
@ -64,7 +68,7 @@
},
{
"cell_type": "code",
"execution_count": 25,
"execution_count": 6,
"source": [
"score_model('windows is such a great product and i love using it, who does agree with me?')"
],
@ -77,7 +81,7 @@
]
},
"metadata": {},
"execution_count": 25
"execution_count": 6
}
],
"metadata": {}