<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Microsoft Machine Learning Server</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/mlserver/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/mlserver/feed.xml</link>
    <description>Microsoft Machine Learning Server Blog</description>
    <lastBuildDate>Mon, 04 Mar 2019 20:46:21 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>We are moving!</title>
      <link>https://docs.microsoft.com/archive/blogs/mlserver/we-are-moving</link>
      <pubDate>Mon, 04 Mar 2019 12:46:21 GMT</pubDate>
      <dc:creator><![CDATA[jeroen_ter_heerdt]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/mlserver/?p=6975</guid>
      <description><![CDATA[This blog is in the process of being migrated to one of the new consolidated SQL Server and Azure...]]></description>
      <content:encoded><![CDATA[<span>This blog is in the process of being migrated to </span><span>one of </span><span>the new consolidated </span><a href="https://techcommunity.microsoft.com/t5/SQL-Server/ct-p/SQL-Server"><span>SQL Server</span></a><span> and </span><a href="https://techcommunity.microsoft.com/t5/Azure-SQL-Database/bg-p/Azure-SQL-Database"><span>Azure SQL Database</span></a><span> blog</span><span>s</span><span> on the </span><a href="https://techcommunity.microsoft.com/"><span>Microsoft </span><span>TechCommunity</span></a><span> website.</span><span>  Once the migration is complete, we will post the new URL along with instructions for how to navigate the new blog and update your RSS feeds.  Until then, feel free to keep reading here, but keep in mind that any comments that are added may not make it over to the new blog.  You will be able to re-post them there once we are live.  Stay tuned and see you on the new site soon!</span><span> </span>]]></content:encoded>
    </item>
    <item>
      <title>Build Intelligent Web App with Machine Learning Service</title>
      <link>https://docs.microsoft.com/archive/blogs/mlserver/build-intelligent-web-app-with-machine-learning-service</link>
      <pubDate>Tue, 21 Aug 2018 14:59:16 GMT</pubDate>
      <dc:creator><![CDATA[Bill_Liang]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/mlserver/?p=6925</guid>
      <description><![CDATA[In an earlier article: How to operationalize TensorFlow models in Microsoft Machine Learning Server,...]]></description>
      <content:encoded><![CDATA[In an earlier article: <a target="_blank" href="https://blogs.msdn.microsoft.com/mlserver/2018/08/16/how-to-operationalize-tensorflow-models-in-microsoft-machine-learning-server/" rel="noopener">How to operationalize TensorFlow models in Microsoft Machine Learning Server</a>, we showed how you can deploy a TensorFlow image classification model pre-trained using ImageNet as service in Machine Learning Server, and download a Swagger specification of the service as a JSON file, which can be passed on to app developers who will use it to generate a client for consuming the service.

In this article, we will walk through the process of consuming an ML service from a single-page app (SPA) built using the popular progressive web apps (PWA) framework <a target="_blank" href="https://vuejs.org" rel="noopener">Vue.js</a>. At a very high level, it involves:
<ul>
 	<li>Generating API client from the Swagger JSON file of the service</li>
 	<li>Linking in the client as npm module package</li>
 	<li>Adding Vue component with javascript code that leverages the generated client to make service consumption API calls</li>
</ul>
Before we start, we assume you have gone through the previous article: <a target="_blank" href="https://blogs.msdn.microsoft.com/mlserver/2018/08/16/how-to-operationalize-tensorflow-models-in-microsoft-machine-learning-server/" rel="noopener">How to operationalize TensorFlow models in Microsoft Machine Learning Server</a>, and published the image classification ML model as a service and download the swagger.json file, and you have also installed a version of <a target="_blank" href="https://nodejs.org" rel="noopener">Node.js</a> that is current.
<h2>Creating a VueJS App</h2>
We can use the <a target="_blank" href="https://vuejs-templates.github.io/webpack" rel="noopener">Vue.js webpack template</a> to scaffold our project. The webpack template is part of the vue-cli, which can be installed through:

<script src="https://gist.github.com/0xbliang/d985a5553da9456f7580dd4f323a5708.js"></script>

Once that's installed, we can run the following commands to create our project and run it. For this example, let's use "ml-app-vuejs" as the name of our app.

<script src="https://gist.github.com/0xbliang/4ae266bc59aa34cf062895a26d5659db.js"></script>

At this point, you should be able to point your browser to https://localhost:8080 and see a responsive Vue.js web app. You can change the browser to a responsive mode through the dev tools and see how the app renders on mobile.
<h2>Setting up the Swagger Generated Javascript Client</h2>
Next, we will generate a javascript client and set it up for use in our javascript code. To do that, go to <a target="_blank" href="https://editor.swagger.io" rel="noopener">https://editor.swagger.io</a>, upload the previously downloaded "swagger.json" file and choose to generate a javascript client. Save and extract the zip file containing the generated client. Let's rename the folder to "image-classification-client", making sure there's a "package.json" file directly under it among other files and folders. Then create a "lib" folder under our project root, and drop the entire "image-classification-client" folder under "ml-app-vuejs/lib". Run the following commands under the project root folder to link in the package and install its dependency "superagent":

<script src="https://gist.github.com/0xbliang/f08d21e9c15a474f43abce347fdf6df8.js"></script>

After that, inspect the "node_modules" folder, and you should see a link named "image_classification" there. In addition to linking in the package, we also need to disable AMD loader through "webpack.base.conf.js" to avoid potential module loading error:

<script src="https://gist.github.com/0xbliang/17deaf5ca0ddab377cafbfe74ca603a3.js"></script>

See the "<a target="_blank" href="https://github.com/Microsoft/microsoft-r/blob/master/ml-app-vuejs/lib/image-classification-client/README.md#webpack-configuration" rel="noopener">Webpack Configuration</a>" section in README.md of the generated client for more details.

In this example, all API requests are sent to the same domain where the web app is hosted and then proxied (see "proxyTable" in "config/index.js") to Machine Learning service. In production, API requests can be re-routed to the API servers using reverse proxy, or you can also <a target="_blank" href="https://docs.microsoft.com/en-us/machine-learning-server/operationalize/configure-cors" rel="noopener">enable CORS to allow cross-domain API requests</a> from the web app in the browser directly.

To proxy the API calls the Machine Learning service, we need to update "config/index.js" to have the following:

<script src="https://gist.github.com/0xbliang/c43ecfb390e35127becad9ef520fd095.js"></script>
<h2>Implementing the Login Screen</h2>
In order to consume the ML service to perform image classification, we need an access token. So, we will implement a login screen, where the the app will acquire an JWT access token using the credentials provided by the user on the login screen.

Let's add a new file "ImageClassification.vue" under "src/components" with some login HTML elements inside the "template", and javascript code inside "script":

<script src="https://gist.github.com/0xbliang/eb875cbef3e30a2a3c974ccd820b164d.js"></script>

Go to "src/router/index.js" to wire up the component we just created to the main "App.vue". It should look like this:

<script src="https://gist.github.com/0xbliang/3ea533237778140d5f0a8cc6d6b59a0b.js"></script>

To actually call the login API and obtain an JWT access token, we need to update the "login" function above to:

<script src="https://gist.github.com/0xbliang/3e027b9fa05aedd924ea56f8f1443b44.js"></script>

For details on the usage and code example of the "image_classification" module, consult the <a target="_blank" href="https://github.com/Microsoft/microsoft-r/blob/master/ml-app-vuejs/lib/image-classification-client/README.md" rel="noopener">README</a> of the generated client.

At this point, you should be able to login and see a login request in the dev tools coming back with an access token.
<h2>Implementing the Image Classification Screen</h2>
For image classification, we will let the user provide an image, and the app will draw it out on a canvas, then base64 encode the image to a string, because we will be sending it in JSON format to the API. If you recall from the <a target="_blank" href="https://blogs.msdn.microsoft.com/mlserver/2018/08/16/how-to-operationalize-tensorflow-models-in-microsoft-machine-learning-server" rel="noopener">previous article</a>, the service deployed already understands the encoding and it will decode it properly to pass onto the TensorFlow model.

Here's the HTML elements to be added to the "template" and right after the "login-container" div:

<script src="https://gist.github.com/0xbliang/24d10b8db495bf1e110ca8ede053275c.js"></script>

and the corresponding javascript code:

<script src="https://gist.github.com/0xbliang/5fce7e697c4baa9a1fc0217daa4e4afb.js"></script>

Again, usage and sample code for "<a target="_blank" href="https://github.com/Microsoft/microsoft-r/blob/master/ml-app-vuejs/lib/image-classification-client/docs/ImageClassificationApi.md#runInferenceOnImage" rel="noopener">ImageClassificationApi</a>" can found in the documentation inside the generated client package.
<h2>The Final Product</h2>
Here's what the final product looks like, slightly styled using Bootstrap.

<img src="https://msdnshared.blob.core.windows.net/media/2018/08/ml-app-screenshots-1024x569.png" alt="" width="1024" height="569" class="alignnone wp-image-6945 size-large" />

The source code of the full project can be found at:
<a target="_blank" href="https://github.com/Microsoft/microsoft-r/tree/master/ml-app-vuejs" rel="noopener">https://github.com/Microsoft/microsoft-r/tree/master/ml-app-vuejs</a>]]></content:encoded>
    </item>
    <item>
      <title>How to operationalize TensorFlow models in Microsoft Machine Learning Server</title>
      <link>https://docs.microsoft.com/archive/blogs/mlserver/how-to-operationalize-tensorflow-models-in-microsoft-machine-learning-server</link>
      <pubDate>Thu, 16 Aug 2018 16:05:56 GMT</pubDate>
      <dc:creator><![CDATA[Vivian_K]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/mlserver/?p=6895</guid>
      <description><![CDATA[We have seen how to operationalize Keras models as web services in R and Python in a previous blog....]]></description>
      <content:encoded><![CDATA[<span>We have seen how to operationalize Keras models as web services in R and Python in a previous <a href="https://blogs.msdn.microsoft.com/mlserver/2018/05/25/how-to-operationalize-keras-models-in-microsoft-machine-learning-server/">blog</a>. Now we will see how to deploy a TensorFlow image classification model to Microsoft Machine Learning Server. </span>

<span>Click <a target="_blank" href="https://msdn.microsoft.com/en-us/microsoft-r/operationalize/about" rel="noopener">here</a> to know more about Microsoft Machine Learning Server Operationalization. <span class="TextRun SCXW87213530" xml:lang="EN-US" lang="EN-US"><span class="NormalTextRun SCXW87213530">You can configure Machine Learning Server to operationalize analytics on a single machine (</span></span><a href="https://docs.microsoft.com/en-us/machine-learning-server/operationalize/configure-machine-learning-server-one-box#how-to-configure"><span class="TextRun Underlined SCXW87213530" xml:lang="EN-US" lang="EN-US"><span class="NormalTextRun SCXW87213530">One-box</span></span></a><span class="TextRun SCXW87213530" xml:lang="EN-US" lang="EN-US"><span class="NormalTextRun SCXW87213530">) or multiple <a href="https://docs.microsoft.com/en-us/machine-learning-server/operationalize/configure-start-for-administrators#configure-server-for-operationalization">web and compute nodes</a> that are configured on multiple machines along with other enterprise features.</span></span></span>
<h3>Create a web service for a TensorFlow image classification model in Python</h3>
Before you can use the web service management functions in the azureml-model-management-sdk Python package, you must:
<ul>
 	<li> Have access to a Python-enabled instance of Machine Learning Server that was <a href="https://docs.microsoft.com/en-us/machine-learning-server/r-reference/mrsdeploy/mrsdeploy-package#configure">properly configured</a><span> </span>to host web services.</li>
 	<li>Authenticate with Machine Learning Server in Python as described in "Connecting to Machine Learning Server."</li>
 	<li>Have <a href="https://www.tensorflow.org/install/">Tensorflow</a><span> </span>installed on compute nodes.</li>
 	<li>Have a trained TensorFlow image classification model.</li>
</ul>
In the following example, we are going to demonstrate how to operationalize a TensorFlow image classification model and generate web service API. We are using the trained <a href="https://www.image-net.org/">ImageNet</a> model downloaded from <a href="https://github.com/tensorflow/models">TensorFlow Models Repo</a>.
<ol>
 	<li>We first put the trained model on each compute node</li>
 	<li>The below python script loads the model, builds the graph, and decodes image for classification
<script src="https://gist.github.com/viviankou/0a8bb8cb74f71fd674b1361710e02b7b.js"></script></li>
 	<li>The below python script deploys the image classification model as a service and generates service swagger
<script src="https://gist.github.com/viviankou/d1843451c432187231b9fcb8454a839c.js"></script></li>
 	<li><span>We can use the swagger json file from previous step to generate clients in many languages. </span>With the generated web service API, developers can easily consume the image classification model in their applications. In another <a href="https://blogs.msdn.microsoft.com/mlserver/2018/08/21/build-intelligent-web-app-with-machine-learning-service/">blog</a>, we will talk about how to consume the image classification web service in a JavaScript web application.</li>
</ol>
<h3>REFERENCES</h3>
https://www.tensorflow.org/tutorials/images/image_recognition

https://www.image-net.org/

https://github.com/tensorflow/models/blob/master/tutorials/image/imagenet/classify_image.py]]></content:encoded>
    </item>
    <item>
      <title>Dockerizing R and Python Web Services</title>
      <link>https://docs.microsoft.com/archive/blogs/mlserver/dockerizing-r-and-python-web-services</link>
      <pubDate>Thu, 26 Jul 2018 15:34:52 GMT</pubDate>
      <dc:creator><![CDATA[Ramkumar Chandrasekaran, Microsoft]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/mlserver/?p=6825</guid>
      <description><![CDATA[Containerization is an approach to software development in which an application or service, its...]]></description>
      <content:encoded><![CDATA[<span>Containerization is an approach to software development in which an application or service, its dependencies, and its configuration (abstracted as deployment manifest files) are packaged together as a container image. The containerized application can be tested as a unit and deployed as a container image instance to the host operating system (OS). <a href="https://www.docker.com/">Docker</a> is an <a href="https://github.com/docker/docker">open-source project</a> for automating the deployment of applications as portable, self-sufficient containers that can run on the cloud or on-premises. More information <a target="_blank" href="https://docs.microsoft.com/en-us/dotnet/standard/microservices-architecture/container-docker-introduction/" rel="noopener">here.</a></span>
<img src="https://msdnshared.blob.core.windows.net/media/2018/07/image214.png" alt="" width="984" height="476" class="size-full wp-image-6835 aligncenter" />
<span><a target="_blank" href="https://docs.microsoft.com/en-us/machine-learning-server/what-is-machine-learning-server" rel="noopener">Microsoft Machine Learning Server</a> is your flexible enterprise platform for analyzing data at scale, building intelligent apps, and discovering valuable insights across your business with full support for Python and R. <a target="_blank" href="https://docs.microsoft.com/en-us/machine-learning-server/what-is-operationalization" rel="noopener">Operationalization</a> refers to the process of deploying R and Python models and code to Machine Learning Server in the form of <a href="https://docs.microsoft.com/en-us/machine-learning-server/operationalize/concept-what-are-web-services">web services</a> and the subsequent consumption of these services within client applications to affect business results. </span>

In this article, We will look into how to build a docker image containing <a target="_blank" href="https://blogs.technet.microsoft.com/machinelearning/2018/02/27/introducing-the-microsoft-machine-learning-server-9-3-release/" rel="noopener">Machine Learning Server 9.3</a> using Dockerfiles and how-to-perform the following operations using the docker image :
<ol>
 	<li><strong>Run R Shell</strong></li>
 	<li><strong>Run Python Shell</strong></li>
 	<li><strong>Run Jupyter Notebook</strong></li>
 	<li><strong>Run Onebox Configuration</strong></li>
 	<li><strong>Run R Web Service</strong></li>
 	<li><strong>Run Python Web Service</strong></li>
</ol>
&nbsp;
<h4><strong>Prerequisites :</strong></h4>
Any Linux VM with docker community edition installed. For this article, I have spinned a <a target="_blank" href="https://portal.azure.com/#create/Canonical.UbuntuServer1604LTS-ARM" rel="noopener">Ubuntu 16.04 VM</a> and <a target="_blank" href="https://docs.docker.com/install/linux/docker-ce/ubuntu/#install-docker-ce" rel="noopener">installed docker CE.</a>
<h4><strong>Step 0 :</strong></h4>
First let us create an image called "mlserver" with <a target="_blank" href="https://blogs.technet.microsoft.com/machinelearning/2018/02/27/introducing-the-microsoft-machine-learning-server-9-3-release/" rel="noopener">Machine Learning Server 9.3</a> installed using the following Dockerfile :

<script src="https://gist.github.com/ramnov/a927a97438819df547a7bbd13b404386.js"></script>

Use <a target="_blank" href="https://docs.docker.com/engine/reference/commandline/build/" rel="noopener">docker build</a> command to build image "mlserver" using the above dockerfile :
<pre>docker build -f mlserver-dockerfile -t mlserver .</pre>
Check if image "mlserver" is built successfully using the following command :
<pre>docker images</pre>
&nbsp;
<h3><strong>Run R Shell</strong></h3>
<pre>docker run -it mlserver R</pre>
<img src="https://msdnshared.blob.core.windows.net/media/2018/07/d1.png" alt="" width="708" height="608" class="alignnone size-full wp-image-6845" />
<h3><strong>Run Python Shell :</strong></h3>
<pre>docker run -it mlserver mlserver-python</pre>
<img src="https://msdnshared.blob.core.windows.net/media/2018/07/d2.png" alt="" width="692" height="133" class="alignnone size-full wp-image-6855" />
<h3><strong>Run Jupyter Notebook :</strong></h3>
<pre>docker run -p 8888:8888 -it mlserver /opt/microsoft/mlserver/9.3.0/runtime/python/bin/jupyter notebook --no-browser --port=8888 --ip=0.0.0.0 --allow-root</pre>
<span>Running the above command gives a link that you can open in your browser to use Jupyter Notebooks. </span>
<img src="https://msdnshared.blob.core.windows.net/media/2018/07/d3.png" alt="" width="1691" height="333" class="alignnone size-full wp-image-6865" />
<h3><strong>Run One-box Configuration :</strong></h3>
<span>You can configure Microsoft Learning Server after installation to act as a deployment server and to host analytic web services for <a target="_blank" href="https://docs.microsoft.com/en-us/machine-learning-server/operationalize/configure-machine-learning-server-one-box" rel="noopener">operationalization</a>. </span>

<script src="https://gist.github.com/ramnov/de62737a1146e50ad0125f018eafae6a.js"></script>

Build image "mlserver-onebox" using the above dockerfile :
<pre>docker build -f mlserver-onebox-dockerfile -t mlserver-onebox .</pre>
Check if image "mlserver-onebox" is built successfully using the following command :
<pre>docker images</pre>
Start a onebox container using the following command :
<pre>docker run --name mlserver-onebox-container -dit mlserver-onebox</pre>
Check the status of container using :
<pre>docker logs mlserver-onebox-container</pre>
Once you have confirmed that the diagnostic tests have passed successfully from the above command, you can start using it as one-box. (docker logs output should contain the following string : "All Diagnostic Tests have passed.")

Obtain the IP address of the container using the following command :
<pre>docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' mlserver-onebox-container
'172.17.0.3'</pre>
and use it like a one-box :
<pre>az login --mls --mls-endpoint "https://172.17.0.3:12800" --username "admin" --password "Microsoft@2018"
az ml admin diagnostic run</pre>
&nbsp;
<h3><strong>Run R Web Service :</strong></h3>
We can also develop an image with a webservice pre-configured so that it is ready for consumption as soon as we spin a container. Here is an example to build an image with <a target="_blank" href="https://docs.microsoft.com/en-us/machine-learning-server/operationalize/how-to-deploy-web-service-publish-manage-in-r#1-r-code-and-model-are-objects" rel="noopener">Manual Transmission R Web Service</a> pre-configured inside the image.

<script src="https://gist.github.com/ramnov/0532070291d2a7af1934898b0e85d32b.js"></script>

Build image "rmanualtransmission" using the above dockerfile :
<pre>docker build -f r-manualtransmission-dockerfile -t rmanualtransmission .</pre>
Check if image "rmanualtransmission" is built successfully using the following command :
<pre>docker images</pre>
Start container using the following command :
<pre>docker run --name rmanualtransmission-container -dit rmanualtransmission</pre>
Check the status of container using :
<pre>docker logs rmanualtransmission-container</pre>
Once you have confirmed that the diagnostic tests have passed successfully and web service has been published, you can start consuming the web service.

Obtain the IP address of the container using the following command :
<pre>docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' rmanualtransmission-container
'172.17.0.3'</pre>
you can consume (or) obtain the swagger.json of ManualTranmission R Web Service using curl commands :
<pre>apt-get -y install jq

curl -s --header "Content-Type: application/json" --request POST --data '{"username":"admin","password":"Microsoft@2018"}' https://172.17.0.3:12800/login | jq -r '.access_token'
&lt;access token&gt;

curl -s --header "Content-Type: application/json" --header "Authorization: Bearer &lt;access token&gt;" --request POST --data '{"hp":120,"wt":2.8}' https://172.17.0.3:12800/api/ManualTransmissionService/1.0.0
{"success":true,"errorMessage":"","outputParameters":{"answer":0.64181252840938208},"outputFiles":{},"consoleOutput":"","changedFiles":[]}

curl -s --header "Authorization: Bearer &lt;access token&gt;" --request GET https://172.17.0.3:12800/api/ManualTransmissionService/1.0.0/swagger.json -o swagger.json</pre>
The swagger.json file can then be used to <a target="_blank" href="https://docs.microsoft.com/en-us/machine-learning-server/operationalize/how-to-build-api-clients-from-swagger-for-app-integration#option-2-build-using-an-online-swagger-editor" rel="noopener">build a client library in any language</a>.
<h3><strong>Run Python Web Service :</strong></h3>
Here is an example to build an image with <a target="_blank" href="https://github.com/Microsoft/ML-Server-Python-Samples/blob/master/operationalize/Quickstart_Publish_Python_Web_Service.ipynb" rel="noopener">Manual Transmission Python Web Service</a> pre-configured inside the image.

<script src="https://gist.github.com/ramnov/a43998f73d9254fafec45e0eb8d10c36.js"></script>

Build image "pymanualtransmission" using the above dockerfile :
<pre>docker build -f py-manualtransmission-dockerfile -t pymanualtransmission .</pre>
Check if image "pymanualtransmission" is built successfully using the following command :
<pre>docker images</pre>
Start container using the following command :
<pre>docker run --name pymanualtransmission-container -dit pymanualtransmission</pre>
Check the status of container using :
<pre>docker logs pymanualtransmission-container</pre>
Once you have confirmed that the diagnostic tests have passed successfully and web service has been published, you can start consuming the web service.

Obtain the IP address of the container using the following command :
<pre>docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' pymanualtransmission-container
'172.17.0.3'</pre>
you can obtain the swagger.json of ManualTranmission Python Web Service using curl commands :
<pre>apt-get -y install jq

curl -s --header "Content-Type: application/json" --request POST --data '{"username":"admin","password":"Microsoft@2018"}' https://172.17.0.3:12800/login | jq -r '.access_token'
&lt;access token&gt;

curl -s --header "Content-Type: application/json" --header "Authorization: Bearer &lt;access token&gt;" --request POST --data '{"hp":120,"wt":2.8}' https://172.17.0.3:12800/api/ManualTransmissionService/1.0.0 
{"success":true,"errorMessage":"","outputParameters":{"answer":0.64181252840938208},"outputFiles":{},"consoleOutput":"","changedFiles":[]}

curl -s --header "Authorization: Bearer &lt;access token&gt;" --request GET https://172.17.0.3:12800/api/ManualTransmissionService/1.0.0/swagger.json -o swagger.json</pre>
The swagger.json file can then be used to <a target="_blank" href="https://docs.microsoft.com/en-us/machine-learning-server/operationalize/how-to-build-api-clients-from-swagger-for-app-integration#option-2-build-using-an-online-swagger-editor" rel="noopener">build a client library in any language</a>.

<strong>NOTE</strong> : You can also modify webnode appsettings.json using Dockerfile magic and enable <a target="_blank" href="https://docs.microsoft.com/en-us/machine-learning-server/operationalize/configure-authentication" rel="noopener">LDAP/AAD Authentication</a>.
<h3><strong>Run on Kubernetes :</strong></h3>
The developed local docker images can be pushed to <a target="_blank" href="https://docs.microsoft.com/en-us/azure/container-registry/container-registry-get-started-docker-cli" rel="noopener">Azure Container Registry</a> (ACR).

<a target="_blank" href="https://docs.microsoft.com/en-us/azure/aks/tutorial-kubernetes-deploy-cluster" rel="noopener">Create Azure Kubernetes Service (AKS)</a> cluster using images in ACR which <a target="_blank" href="https://docs.microsoft.com/en-us/azure/aks/tutorial-kubernetes-scale#autoscale-pods" rel="noopener">can be scaled up and down automatically using Autoscale pods.</a>

In order to run 9.3 linux onebox image in a Kubernetes Cluster, we will have to initialize JWTSigningCertificate with a certificate value and add "kubepods" group to webnode/computenode autoStartScripts. These extra steps can be added to the dockerfile as follows :

<script src="https://gist.github.com/ramnov/ffdb9306612f0716b6c480987352e12f.js"></script>
<h3>REFERENCES :</h3>
<a target="_blank" href="https://github.com/johnpaulada/microsoftmlserver-docker" rel="noopener">https://github.com/johnpaulada/microsoftmlserver-docker</a>

<a target="_blank" href="https://github.com/rcarmo/docker-ml-server" rel="noopener">https://github.com/rcarmo/docker-ml-server</a>

<a target="_blank" href="https://success.docker.com/article/use-a-script-to-initialize-stateful-container-data" rel="noopener">https://success.docker.com/article/use-a-script-to-initialize-stateful-container-data</a>

<a target="_blank" href="https://docs.docker.com/v17.09/engine/userguide/eng-image/dockerfile_best-practices" rel="noopener">https://docs.docker.com/v17.09/engine/userguide/eng-image/dockerfile_best-practices</a>

<a target="_blank" href="https://www.tothenew.com/blog/dockerizing-nginx-and-ssh-using-supervisord" rel="noopener">https://www.tothenew.com/blog/dockerizing-nginx-and-ssh-using-supervisord</a>

<a target="_blank" href="https://microsoft.github.io/deployr-api-docs" rel="noopener">https://microsoft.github.io/deployr-api-docs</a>

<a target="_blank" href="https://docs.microsoft.com/en-us/dotnet/standard/microservices-architecture/container-docker-introduction" rel="noopener">https://docs.microsoft.com/en-us/dotnet/standard/microservices-architecture/container-docker-introduction</a>]]></content:encoded>
    </item>
    <item>
      <title>Run R and Python Remotely in SQL Server from Jupyter Notebooks or any IDE</title>
      <link>https://docs.microsoft.com/archive/blogs/mlserver/run-r-and-python-remotely-in-sql-server-from-jupyter-notebooks-or-any-ide</link>
      <pubDate>Tue, 10 Jul 2018 08:57:16 GMT</pubDate>
      <dc:creator><![CDATA[Kyle Weller]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/mlserver/?p=6755</guid>
      <description><![CDATA[Did you know that you can execute R and Python code remotely in SQL Server from any IDE? This...]]></description>
      <content:encoded><![CDATA[<img src="https://msdnshared.blob.core.windows.net/media/2018/06/RemoteCompute.png" alt="" width="771" height="434" class="wp-image-6765 alignnone" />

Did you know that you can execute R and Python code remotely in SQL Server from any IDE? This eliminates the need to move data around. Instead of transferring large and sensitive data over the network or losing accuracy with sample csv files, you can have your R/Python code execute within your database. You can work in Jupyter Notebooks, RStudio, PyCharm, VSCode, Visual Studio, wherever you want, and then send function execution to SQL Server bringing intelligence to where your data lives.

This tutorial will show you an example of how you can send your python code from Juptyter notebooks to execute within SQL Server. The same principles apply to R and any other IDE as well. If you prefer to learn through videos, this tutorial is also published on YouTube here:

<iframe width="560" height="315" src="https://www.youtube.com/embed/D5erljpJDjE" frameborder="0" allowfullscreen></iframe>
<h3>Environment Setup</h3>
In order for R or Python to execute within SQL, you need the Machine Learning Services feature installed and configured. See this how-to guide:<span> </span><a href="https://blogs.msdn.microsoft.com/mlserver/2018/05/18/getting-started-with-machine-learning-services-in-sql-server/">https://blogs.msdn.microsoft.com/mlserver/2018/05/18/getting-started-with-machine-learning-services-in-sql-server/</a>

In order to send Python execution to SQL, you need to use Microsoft's RevoscalePy package.
<ol>
 	<li>To get revoscalepy, download and install Microsoft's Python Client. <a href="https://docs.microsoft.com/en-us/machine-learning-server/install/python-libraries-interpreter">Documentation Page</a> or <a href="https://aka.ms/mls93-py">Direct Download Link</a> (for Windows).<span> </span></li>
 	<li>After downloading, open powershell as an administrator and navigate to the download folder.</li>
 	<li>Start the installation with this command (feel free to customize the install folder):</li>
 	<li><span style="font-family: Calibri;font-size: 11.0pt;font-weight: normal;font-style: normal">.\Install-PyForMLS.ps1 -InstallFolder "C:\Program Files\MicrosoftPythonClient"</span></li>
 	<li>Be patient while the installation can take a little while. Once installed navigate to the new path you installed in.</li>
 	<li>Let's make an empty folder and open Jupyter Notebooks:</li>
 	<li><span style="font-family: Calibri;font-size: 11.0pt;font-weight: normal;font-style: normal">mkdir JupyterNotebooks; cd JupyterNotebooks; ..\Scripts\jupyter-notebook</span></li>
 	<li>Create a new notebook with Python 3 interpreter:</li>
 	<li><img src="https://msdnshared.blob.core.windows.net/media/2018/06/JupyterNew.png" alt="" width="207" height="176" class="alignnone wp-image-6775" /></li>
 	<li>To test if everything is setup, import revoscalepy in the first cell and execute.</li>
 	<li><img src="https://msdnshared.blob.core.windows.net/media/2018/06/importrevopy.png" alt="" width="281" height="62" class="alignnone size-full wp-image-6785" /></li>
 	<li>If there are no error messages you are ready to move forward.</li>
</ol>
<a href="https://aka.ms/RemoteExecJupyter"></a>
<h3>Database Setup</h3>
For the rest of the tutorial you can also clone this Jupyter Notebook if you don't want to copy paste all of the code: <a href="https://aka.ms/RemoteExecJupyter">https://aka.ms/RemoteExecJupyter</a>

<span>This database setup is a one time step to ensure you have the same data for this tutorial. You won't need to perform any of these steps to use your own data.</span>
<h4>1. Create a database</h4>
Modify the connection string for your server and use pyodbc to create a new database.
<blockquote>
<pre><span class="kn">import</span> <span class="nn">pyodbc</span>

<span class="c1"># creating a new db to load Iris sample in</span>
<span class="n">new_db_name</span> <span class="o">=</span> <span class="s2">"MLRemoteExec"</span>
<span class="n">connection_string</span> <span class="o">=</span> <span class="s2">"Driver=SQL Server;Server=localhost\MSSQLSERVER2017;Database=</span><span class="si">{0}</span><span class="s2">;Trusted_Connection=Yes;"</span> 
                        <span class="c1"># you can also swap Trusted_Connection for UID={your username};PWD={your password}</span>
<span class="n">cnxn</span> <span class="o">=</span> <span class="n">pyodbc</span><span class="o">.</span><span class="n">connect</span><span class="p">(</span><span class="n">connection_string</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="s2">"master"</span><span class="p">),</span> <span class="n">autocommit</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="n">cnxn</span><span class="o">.</span><span class="n">cursor</span><span class="p">()</span><span class="o">.</span><span class="n">execute</span><span class="p">(</span><span class="s2">"IF EXISTS(SELECT * FROM sys.databases WHERE [name] = '</span><span class="si">{0}</span><span class="s2">') DROP DATABASE </span><span class="si">{0}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">new_db_name</span><span class="p">))</span>
<span class="n">cnxn</span><span class="o">.</span><span class="n">cursor</span><span class="p">()</span><span class="o">.</span><span class="n">execute</span><span class="p">(</span><span class="s2">"CREATE DATABASE "</span> <span class="o">+</span> <span class="n">new_db_name</span><span class="p">)</span>
<span class="n">cnxn</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>

<span class="nb">print</span><span class="p">(</span><span class="s2">"Database created"</span><span class="p">)</span></pre>
</blockquote>
<h4>2. Import Iris sample from SkLearn</h4>
<blockquote>
<pre><span class="kn">from</span> <span class="nn">sklearn</span> <span class="k">import</span> <span class="n">datasets</span>
<span class="kn">import</span> <span class="nn">pandas</span> <span class="k">as</span> <span class="nn">pd</span>

<span class="c1"># SkLearn has the Iris sample dataset built in to the package</span>
<span class="n">iris</span> <span class="o">=</span> <span class="n">datasets</span><span class="o">.</span><span class="n">load_iris</span><span class="p">()</span>
<span class="n">df</span> <span class="o">=</span> <span class="n">pd</span><span class="o">.</span><span class="n">DataFrame</span><span class="p">(</span><span class="n">iris</span><span class="o">.</span><span class="n">data</span><span class="p">,</span> <span class="n">columns</span><span class="o">=</span><span class="n">iris</span><span class="o">.</span><span class="n">feature_names</span><span class="p">)</span></pre>
</blockquote>
<h4>3. Use RecoscalePy APIs to create a table and load the Iris data</h4>
<a href="https://aka.ms/RemoteExecJupyter"></a><span>(You can also do this with pyodbc, sqlalchemy or other packages)</span>
<blockquote>
<pre><span class="kn">from</span> <span class="nn">revoscalepy</span> <span class="k">import</span> <span class="n">RxSqlServerData</span><span class="p">,</span> <span class="n">rx_data_step</span>

<span class="c1"># Example of using RX APIs to load data into SQL table. You can also do this with pyodbc</span>
<span class="n">table_ref</span> <span class="o">=</span> <span class="n">RxSqlServerData</span><span class="p">(</span><span class="n">connection_string</span><span class="o">=</span><span class="n">connection_string</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">new_db_name</span><span class="p">),</span> <span class="n">table</span><span class="o">=</span><span class="s2">"Iris"</span><span class="p">)</span>
<span class="n">rx_data_step</span><span class="p">(</span><span class="n">input_data</span> <span class="o">=</span> <span class="n">df</span><span class="p">,</span> <span class="n">output_file</span> <span class="o">=</span> <span class="n">table_ref</span><span class="p">,</span> <span class="n">overwrite</span> <span class="o">=</span> <span class="kc">True</span><span class="p">)</span>

<span class="nb">print</span><span class="p">(</span><span class="s2">"New Table Created: Iris"</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">"Sklearn Iris sample loaded into Iris table"</span><span class="p">)</span></pre>
</blockquote>
<h3>Define Function to Send to SQL Server</h3>
<span>Write any python code you want to execute in SQL. In this example we are creating a scatter matrix on the iris dataset and only returning the bytestream of the .png back to Jupyter Notebooks to render on our client.</span>
<blockquote>
<pre><span class="k">def</span> <span class="nf">send_this_func_to_sql</span><span class="p">():</span>
    <span class="kn">from</span> <span class="nn">revoscalepy</span> <span class="k">import</span> <span class="n">RxSqlServerData</span><span class="p">,</span> <span class="n">rx_import</span>
    <span class="kn">from</span> <span class="nn">pandas.tools.plotting</span> <span class="k">import</span> <span class="n">scatter_matrix</span>
    <span class="kn">import</span> <span class="nn">matplotlib.pyplot</span> <span class="k">as</span> <span class="nn">plt</span>
    <span class="kn">import</span> <span class="nn">io</span>
    
    <span class="c1"># remember the scope of the variables in this func are within our SQL Server Python Runtime</span>
    <span class="n">connection_string</span> <span class="o">=</span> <span class="s2">"Driver=SQL Server;Server=localhost\MSSQLSERVER2017;Database=MLRemoteExec;Trusted_Connection=Yes;"</span>
    
    <span class="c1"># specify a query and load into pandas dataframe df</span>
    <span class="n">sql_query</span> <span class="o">=</span> <span class="n">RxSqlServerData</span><span class="p">(</span><span class="n">connection_string</span><span class="o">=</span><span class="n">connection_string</span><span class="p">,</span> <span class="n">sql_query</span> <span class="o">=</span> <span class="s2">"select * from Iris"</span><span class="p">)</span>
    <span class="n">df</span> <span class="o">=</span> <span class="n">rx_import</span><span class="p">(</span><span class="n">sql_query</span><span class="p">)</span>
    
    <span class="n">scatter_matrix</span><span class="p">(</span><span class="n">df</span><span class="p">)</span>
    
    <span class="c1"># return bytestream of image created by scatter_matrix</span>
    <span class="n">buf</span> <span class="o">=</span> <span class="n">io</span><span class="o">.</span><span class="n">BytesIO</span><span class="p">()</span>
    <span class="n">plt</span><span class="o">.</span><span class="n">savefig</span><span class="p">(</span><span class="n">buf</span><span class="p">,</span> <span class="nb">format</span><span class="o">=</span><span class="s2">"png"</span><span class="p">)</span>
    <span class="n">buf</span><span class="o">.</span><span class="n">seek</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span>
    
    <span class="k">return</span> <span class="n">buf</span><span class="o">.</span><span class="n">getvalue</span><span class="p">()</span></pre>
</blockquote>
<h3>Send execution to SQL</h3>
<span>Now that we are set up, check out how easy this really is. Import revoscalepy, Create a sql compute context, and then send the execution of any function seamlessly to SQL Server with RxExec. No raw data had to be transferred from SQL to the Jupyter Notebook. All computation happened within the database and only the image file was returned to be displayed.</span>
<blockquote>
<pre><span class="kn">from</span> <span class="nn">IPython</span> <span class="k">import</span> <span class="n">display</span>
<span class="kn">import</span> <span class="nn">matplotlib.pyplot</span> <span class="k">as</span> <span class="nn">plt</span> 
<span class="kn">from</span> <span class="nn">revoscalepy</span> <span class="k">import</span> <span class="n">RxInSqlServer</span><span class="p">,</span> <span class="n">rx_exec</span>

<span class="c1"># create a remote compute context with connection to SQL Server</span>
<span class="n">sql_compute_context</span> <span class="o">=</span> <span class="n">RxInSqlServer</span><span class="p">(</span><span class="n">connection_string</span><span class="o">=</span><span class="n">connection_string</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">new_db_name</span><span class="p">))</span>

<span class="c1"># use rx_exec to send the function execution to SQL Server</span>
<span class="n">image</span> <span class="o">=</span> <span class="n">rx_exec</span><span class="p">(</span><span class="n">send_this_func_to_sql</span><span class="p">,</span> <span class="n">compute_context</span><span class="o">=</span><span class="n">sql_compute_context</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span>

<span class="c1"># only an image was returned to my jupyter client. All data remained secure and was manipulated in my db.</span>
<span class="n">display</span><span class="o">.</span><span class="n">Image</span><span class="p">(</span><span class="n">data</span><span class="o">=</span><span class="n">image</span><span class="p">)</span></pre>
</blockquote>
<img src="https://msdnshared.blob.core.windows.net/media/2018/06/scattermatrix.png" alt="" width="563" height="446" class="alignnone size-full wp-image-6795" />

<span>While this example is trivial with the Iris dataset, imagine the capabilities that you have now unlocked. You can use any of the latest open source R/Python packages to build Deep Learning and AI applications on large amounts of data in SQL Server. We also offer <a target="_blank" href="https://cloudblogs.microsoft.com/sqlserver/2016/10/11/1000000-predictions-per-second/" rel="noopener">leading edge</a>, high-performance algorithms in Microsoft's <a target="_blank" href="https://docs.microsoft.com/en-us/machine-learning-server/r-reference/revoscaler/revoscaler" rel="noopener">RevoScaleR </a>and <a target="_blank" href="https://docs.microsoft.com/en-us/sql/advanced-analytics/python/what-is-revoscalepy?view=sql-server-2017" rel="noopener">RevoScalePy </a>APIs. Using these with the latest innovations in the open source world allows you to bring unparalleled selection, performance, and scale to your applications.</span>
<h3>Learn More</h3>
Check out <a href="https://aka.ms/SQLMLDocs">SQL Machine Learning Services Documentation</a> to learn how you can also easily deploy your R/Python code with SQL stored procedures making them accessible in your ETL processes or to any application. Train and store machine learning models in your database bringing intelligence to where your data lives.

Basic R and Python Execution in SQL Server: <a href="https://blogs.msdn.microsoft.com/mlserver/2018/05/24/basics-of-r-and-python-execution-in-sql-server/">https://blogs.msdn.microsoft.com/mlserver/2018/05/24/basics-of-r-and-python-execution-in-sql-server/</a>
Set up Machine Learning Services in SQL Server: <a href="https://blogs.msdn.microsoft.com/mlserver/2018/05/18/getting-started-with-machine-learning-services-in-sql-server/">https://blogs.msdn.microsoft.com/mlserver/2018/05/18/getting-started-with-machine-learning-services-in-sql-server/</a>
End-to-end tutorial solutions on Github: <a href="https://microsoft.github.io/sql-ml-tutorials/">https://microsoft.github.io/sql-ml-tutorials/</a>
Other YouTube Tutorials:
<ul>
 	<li><span>How to Install SQL Server Machine Learning Services: </span><a href="https://www.youtube.com/redirect?v=kwudtriqLcA&amp;redir_token=Jn7Yp3BkUdO2cePtZURpC4suvb98MTUyODMyNDM2M0AxNTI4MjM3OTYz&amp;event=video_description&amp;q=https%3A%2F%2Faka.ms%2FInstallMLServices" class="yt-simple-endpoint style-scope yt-formatted-string">https://aka.ms/InstallMLServices</a><span> </span></li>
 	<li><span>How to Enable SQL Server Machine Learning Services: </span><a href="https://www.youtube.com/redirect?v=kwudtriqLcA&amp;redir_token=Jn7Yp3BkUdO2cePtZURpC4suvb98MTUyODMyNDM2M0AxNTI4MjM3OTYz&amp;event=video_description&amp;q=https%3A%2F%2Faka.ms%2FEnableMLServices" class="yt-simple-endpoint style-scope yt-formatted-string">https://aka.ms/EnableMLServices</a><span> </span></li>
 	<li><span>Basics of R and Python Execution in SQL: </span><a href="https://www.youtube.com/redirect?v=kwudtriqLcA&amp;redir_token=Jn7Yp3BkUdO2cePtZURpC4suvb98MTUyODMyNDM2M0AxNTI4MjM3OTYz&amp;event=video_description&amp;q=https%3A%2F%2Faka.ms%2FExecuteMLServices" class="yt-simple-endpoint style-scope yt-formatted-string">https://aka.ms/ExecuteMLServices</a></li>
</ul>
&nbsp;]]></content:encoded>
    </item>
    <item>
      <title>How we are fixing our installer for Microsoft R Open on Linux</title>
      <link>https://docs.microsoft.com/archive/blogs/mlserver/how-we-are-fixing-our-installer-for-microsoft-r-open-on-linux</link>
      <pubDate>Wed, 13 Jun 2018 00:45:31 GMT</pubDate>
      <dc:creator><![CDATA[NageshPabbisetty]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/mlserver/?p=6805</guid>
      <description><![CDATA[This post is authored by Nagesh Pabbisetty, Partner Director of Program Management at...]]></description>
      <content:encoded><![CDATA[<span style="color: #454545;font-family: Segoe UI;font-size: 10pt;background-color: white"><em>This post is authored by Nagesh Pabbisetty, <span style="background: white;margin: 0px;padding: 0in;border: 1pt windowtext;color: #454545;font-family: 'Segoe UI',sans-serif;font-size: 10pt"><i>Partner Director of Program Management at Microsoft</i></span>.
</em></span>

On Monday, we were alerted to an issue in the Microsoft R Open install script on Linux-based systems, including Debian. We appreciate that <a href="https://www.preining.info/blog/2018/06/microsofts-failed-attempt-on-debian-packaging/">Norbert Preining</a> highlighted the problem. This blog describes what went wrong, what we learned and what we are doing to make sure something like this doesn't happen again.

We learned that the issue caused installation and de-installation scripts to modify the system shell and did not follow the standard practices for software installation.  We have described more about the issue and how we fixed<span style="color: #b00000;font-family: Arial"> </span><span style="color: black"><a href="https://social.msdn.microsoft.com/Forums/en-US/6b51afe3-72b4-47a4-ab72-180cf3f2fba2/debianubuntu-packaging-is-badly-hosed-and-dangerous?forum=ropen">it </a></span>in the Microsoft R Open forum.  And last night, we <a href="https://mran.microsoft.com/download">released</a> a hotfix update for Microsoft R Open 3.5.0. With this fix, Microsoft R Open will no longer attempt to modify the system shell on install or uninstall, and now uses the standard dpkg-divert process.

While we work hard to be a good steward in all the open source communities we participate in, this one did not stand up to the community's or our high expectations. In response to this incident, we have deeply examined our review processes for install scripts. Given that Microsoft R Open is released on a wide variety of platforms, we know that it is essential we have experts from each of these communities review our methods and scripts to make sure that we adhere to the norms of that community. We have now made these changes and assigned internal code reviewers for our supported open source platforms. We have put processes in place to help us fix things like this as soon as they are discovered (this issue was identified in 2016 but wasn't fixed) and named individuals have been identified to monitor and address any issues as soon as possible. We are lucky at Microsoft to have many experienced Linux contributors at our company, and we will do better at getting their input going forward.

For those not familiar with <a href="https://mran.microsoft.com/rro">Microsoft R Open</a>, it is Microsoft's distribution of R, a language and system for data analysis. Microsoft R Open includes <a href="https://www.r-project.org/">open source R</a> from the R Foundation and comes bundled with additional open source R packages developed by Microsoft and others. It also includes the Intel Math Kernel Library (distributed under license from Intel), which <a href="https://mran.microsoft.com/documents/rro/multithread">improves the performance</a> of R on many systems. Microsoft R Open is also used by several Microsoft products, including SQL Server, Azure HDInsight, and Azure SQL Database.

We recognize that without the contributions of the open source community generally, and the R project specifically, these products would not have the statistical modeling, advanced analytics and data visualization capabilities our customers rely on. We are committed to being responsible members of both Debian and R open source communities. Microsoft ships over 100 Debian packages for flagship products like SQLServer, .NET Core and VS Code. We are a Platinum supporter of the <a href="https://www.r-consortium.org/">R Consortium</a>, by providing Azure credits for the <a href="https://github.com/r-hub">R-hub project</a>, and as a sponsor of many open source community events.

We always welcome your feedback on Microsoft R – or any of our open source projects. You can post your comments and suggestions for improvement in the official <a href="https://social.msdn.microsoft.com/Forums/en-US/home?forum=ropen">Microsoft R Open forum</a>, or via the <a href="https://github.com/Microsoft/microsoft-r-open">Microsoft R Open Github repository</a>. Most importantly, as a company committed to developer freedom, openness and innovation, we thank the community for flagging any potential issues in any open source ecosystem.]]></content:encoded>
    </item>
    <item>
      <title>Build Your Own Image Similarity Model</title>
      <link>https://docs.microsoft.com/archive/blogs/mlserver/build-your-own-image-similarity-model</link>
      <pubDate>Thu, 31 May 2018 18:35:16 GMT</pubDate>
      <dc:creator><![CDATA[Sheri Gilley]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/mlserver/?p=6715</guid>
      <description><![CDATA[The Image Similarity with SQL Server solution on the Azure AI Gallery demonstrates how to apply...]]></description>
      <content:encoded><![CDATA[The <a href="https://aka.ms/image-similarity">Image Similarity with SQL Server</a> solution on the <a href="https://gallery.azure.ai/solutions">Azure AI Gallery</a> demonstrates how to apply transfer learning, incorporating a pretrained deep neural network (DNN) model (trained on ImageNet) to the problem of finding images that are similar to a target image. In this solution, we use an image based product recommendation scenario as an example, e.g., recommending clothing similar to the one a user is considering.
<img src="https://msdnshared.blob.core.windows.net/media/2018/05/neckties-cravats-ties-fashion-63580-300x200.jpg" alt="" width="300" height="200" class="alignnone size-medium wp-image-6745" />

Our example features shirts (around 300 images) which contains 3 type of designs: dotted, striped, and leopard print. Those with similar patterns are considered more similar than those with different patterns.

Here are the steps we adopt to solve this problem:
<ol>
<li>Use the <a href="https://docs.microsoft.com/en-us/machine-learning-server/python-reference/microsoftml/featurize-image">pretrained model (ResNet-18)</a> as a featurizer to transform the images into features </li>
<li>Train a multi-class classifier on the features of training images. A <a href="https://docs.microsoft.com/en-us/machine-learning-server/python-reference/microsoftml/rx-neural-network">3-layer neural network from MicrosoftML</a> package is used here.</li>
<li>The Trained model is used to predict the class probabilities of each image.</li>
<li>Calculate the distance (e.g., L1, L2, Cosine) between the predicted class probabilities of image pairs. </li>
<li>Rank order image pairs based on the distance: the smaller the distance, the more similar of the image pairs.</li>
</ol>
This solution is developed to work on  <a href="https://docs.microsoft.com/en-us/sql/advanced-analytics/what-is-sql-server-machine-learning?view=sql-server-2017">SQL Server ML Services</a>  available on <a href="https://www.microsoft.com/en-US/sql-server/sql-server-2017">SQL 2017</a>. All the steps are written in Python and wrapped in SQL Server Stored procedures. It uses SQL Server FileTable to manage the storage of unstructured data, which is the type of setup a manufacturer of shirts might have for their inventory.

Are you ready to give it a try?  On the deployed VM (or at the end of the on-prem installation), you'll find the following script running in a terminal window waiting for your reply:
<code><pre>
This script will download all images listed in "c:\Solutions\ImageSimilarity\fashion_texture_urls.tsv"
onto your machine, upload them to SQL and execute the end-to-end workflow to train an image similarity model.
This portion of the script will take about 6 minutes to complete.

Please respond YES to continue
</pre></code>
When you type YES, it will download the sample images, upload them to SQL Server and execute the end-to-end workflow of training and evaluating the image similarity model. You can simply replace the contents of the file with your own image URLs prior to responding to the prompt to get your own personalized model. 

The hard part of the model building has become easy - now all you need is to go find the images you want to use to build your own image similarity model.

 We’d love your feedback and looking forward to hearing what similar images you have been able to match!
]]></content:encoded>
    </item>
    <item>
      <title>How to operationalize Keras models in Microsoft Machine Learning Server</title>
      <link>https://docs.microsoft.com/archive/blogs/mlserver/how-to-operationalize-keras-models-in-microsoft-machine-learning-server</link>
      <pubDate>Fri, 25 May 2018 11:45:01 GMT</pubDate>
      <dc:creator><![CDATA[Vivian_K]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/mlserver/?p=6625</guid>
      <description><![CDATA[Microsoft Machine Learning Server’s operationalization feature enables data scientists to...]]></description>
      <content:encoded><![CDATA[Microsoft Machine Learning Server’s operationalization feature enables data scientists to operationalize their R and Python analytics. In this blog, we will see how to operationalize Keras models as web services in R and Python.

Click<span> </span><a target="_blank" href="https://msdn.microsoft.com/en-us/microsoft-r/operationalize/about" rel="noopener">here</a><span> </span>to know more about Microsoft Machine Learning Server Operationalization. <span class="TextRun SCXW87213530" xml:lang="EN-US" lang="EN-US"><span class="NormalTextRun SCXW87213530">You can configure Machine Learning Server to operationalize analytics on a single machine (</span></span><a href="https://docs.microsoft.com/en-us/machine-learning-server/operationalize/configure-machine-learning-server-one-box#how-to-configure"><span class="TextRun Underlined SCXW87213530" xml:lang="EN-US" lang="EN-US"><span class="NormalTextRun SCXW87213530">One-box</span></span></a><span class="TextRun SCXW87213530" xml:lang="EN-US" lang="EN-US"><span class="NormalTextRun SCXW87213530">).</span></span><span class="EOP SCXW87213530"> </span>
<h3>Create a web service for Keras models in Python</h3>
Before you can use the web service management functions in the azureml-model-management-sdk Python package, you must:
<ul>
 	<li> Have access to a Python-enabled instance of Machine Learning Server that was <a href="https://docs.microsoft.com/en-us/machine-learning-server/r-reference/mrsdeploy/mrsdeploy-package#configure">properly configured</a> to host web services.</li>
 	<li>Authenticate with Machine Learning Server in Python as described in "Connecting to Machine Learning Server."</li>
 	<li>Have <a href="https://keras.io/#installation">Keras</a>, <a href="https://www.tensorflow.org/install/">Tensorflow</a>, and <a href="https://pypi.org/project/keras-pickle-wrapper/">keras-pickle-wrapper</a> installed.</li>
 	<li>Have a trained Keras model.</li>
</ul>
Here is a sample python code to create a simple WebService, publish it, and generate swagger. The below sample uses the Keras model <span> to recognize handwritten digits from the </span><a href="https://en.wikipedia.org/wiki/MNIST_database">MNIST</a><span> dataset. </span>

<script src="https://gist.github.com/viviankou/9fcb7bdb926c9ff2b43ad7d7c6a74967.js"></script>
<p id="how-to-create-and-manage-session-pools-for-fast-web-service-connections-in-python" class="x-hidden-focus">For fast web service connections in Python, you can create sessions and load dependencies in advance by using <a href="https://docs.microsoft.com/en-us/machine-learning-server/operationalize/python/how-to-create-manage-session-pools#create-or-modify-a-dedicated-session-pool">dedicated session pool</a>.</p>

<h3>Create a web service for Keras models in R</h3>
<ul>
 	<li><span>Have access to a Machine Learning Server instance that was </span><a href="https://docs.microsoft.com/en-us/machine-learning-server/r-reference/mrsdeploy/mrsdeploy-package#configure">properly configured</a><span> to host web services.</span></li>
 	<li><span>Authenticate with Machine Learning Server using the remoteLogin() or remoteLoginAAD() functions in the mrsdeploy package.</span></li>
 	<li>Install Keras and Tensorflow backend described <a href="https://tensorflow.rstudio.com/keras/reference/install_keras.html">here</a>.</li>
 	<li>Have a trained Keras model.</li>
</ul>
Here is a sample R code to create a simple WebService, publish it, and generate swagger. The below sample uses the Keras model <span> to recognize handwritten digits from the </span><a href="https://en.wikipedia.org/wiki/MNIST_database">MNIST</a><span> dataset.</span>

<script src="https://gist.github.com/viviankou/d55ed5fb028abf164d15d7fa278bde98.js"></script>
For fast web service connections in R, you can create sessions and load dependencies in advance by using <a href="https://docs.microsoft.com/en-us/machine-learning-server/operationalize/how-to-create-manage-session-pools">dedicated session pool</a>.
<h3><strong>REFERENCES</strong></h3>
<a href="https://keras.io/">https://keras.io/</a>

<a href="https://keras.rstudio.com/">https://keras.rstudio.com/</a>

<a href="https://www.tensorflow.org/">https://www.tensorflow.org/</a>

<a href="https://yann.lecun.com/exdb/mnist/">https://yann.lecun.com/exdb/mnist/</a>

<a href="https://pypi.org/project/keras-pickle-wrapper/">https://pypi.org/project/keras-pickle-wrapper/</a>

<a href="https://tensorflow.rstudio.com/keras/reference/install_keras.html">https://tensorflow.rstudio.com/keras/reference/install_keras.html</a>

<a href="https://docs.microsoft.com/en-us/machine-learning-server/">https://docs.microsoft.com/en-us/machine-learning-server/</a>]]></content:encoded>
    </item>
    <item>
      <title>Basics of R and Python Execution in SQL Server</title>
      <link>https://docs.microsoft.com/archive/blogs/mlserver/basics-of-r-and-python-execution-in-sql-server</link>
      <pubDate>Thu, 24 May 2018 14:35:21 GMT</pubDate>
      <dc:creator><![CDATA[Kyle Weller]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/mlserver/?p=6605</guid>
      <description><![CDATA[In a previous post, we talked about how to set up Machine Learning Services in SQL Server. Now I...]]></description>
      <content:encoded><![CDATA[In a <a target="_blank" href="https://blogs.msdn.microsoft.com/mlserver/2018/05/18/getting-started-with-machine-learning-services-in-sql-server/" rel="noopener">previous post</a>, we talked about how to set up <a href="https://aka.ms/sqlmloverview" rel="noopener" target="_blank">Machine Learning Services in SQL Server</a>. Now I will cover the basics of how to Execute R and Python in T-SQL statements. The video below will help you understand the basic syntax, parameter names, and data types used. I also summarized the key steps if you want to read along. Check out the <a href="https://aka.ms/sqlmldocs">SQL Machine Learning Services documentation</a> to learn more.
<h3>How to Execute R/Python Code in SQL Server</h3>
<iframe width="560" height="315" allowfullscreen="allowfullscreen" frameborder="0" src="https://www.youtube.com/embed/ACejZ9optCQ?rel=0"></iframe>
<h4>Basics</h4>
Ensure Machine Learning Services is <a href="https://blogs.msdn.microsoft.com/mlserver/2018/05/18/getting-started-with-machine-learning-services-in-sql-server/">already installed and enabled</a>. After setup I will now show you the basics of executing R and Python code within a T-SQL statement. While I use Python in these samples, you can do everything with R as well.
<ol>
 	<li>Open up SQL Server Management Studio and make a connection to your server.</li>
 	<li><span>Open a new query.</span></li>
 	<li>Paste <span>this basic example:</span></li>
 	<li>
<div style="background: #EEE;margin-left: 15px;float: left"><code style="font-size: 12px;background: none"><span style="color: blue">EXEC</span> sp_execute_external_script <span style="color: #8b0000">@language</span> = <span style="color: red">N'Python'</span>,
<span style="color: #8b0000">@script</span> = <span style="color: red">N'print(3+4)'</span></code></div></li>
<div style="clear: both"></div>
 	<li>Sp_execute_external_script is a special system stored procedure that enables R and Python execution in SQL Server.</li>
 	<li>There is a "language" parameter that allows us to choose between Python and R.</li>
 	<li>There is a "script" parameter where we can paste R or Python code.</li>
</ol>
<h4>Parameter introduction</h4>
Now that we discussed a basic example, let's start adding more pieces.
<div style="background: #EEE;margin-left: 15px;margin-bottom: 15px;float: left"><code style="font-size: 12px;background: none"><span style="color: blue">EXEC</span> sp_execute_external_script  <span style="color: #8b0000">@language</span> =<span style="color: red">N'Python'</span>,
<span style="color: #8b0000">@script</span> = <span style="color: red">N'
OutputDataSet = InputDataSet;
'</span>,
<span style="color: #8b0000">@input_data_1</span> =<span style="color: red">N'SELECT 1 AS Col1'</span>;</code></div>
<div style="clear: both"></div>
<ol>
 	<li>Machine Learning Services provides more natural communications between SQL and R or Python with an input data parameter that accept any SQL query. The input parameter name is called "input_data_1".</li>
 	<li><span>You can see in the python code that there are default variables defined to pass data between Python and SQL. </span><span>The default variable names are "OutputDataSet" and "InputDataSet"</span></li>
 	<li>You can change these default names like this example:</li>
 	<li>
<div style="background: #EEE;margin-left: 15px;float: left"><code style="font-size: 12px;background: none"><span style="color: blue">EXEC</span> sp_execute_external_script  <span style="color: #8b0000">@language</span> =<span style="color: red">N'Python'</span>,
<span style="color: #8b0000">@script</span> = <span style="color: red">N'
MyOutput = MyInput;
'</span>,
<span style="color: #8b0000">@input_data_1_name</span> = <span style="color: red">N'MyInput'</span>,
<span style="color: #8b0000">@input_data_1</span> =<span style="color: red">N'SELECT 1 AS foo'</span>,
<span style="color: #8b0000">@output_data_1_name</span> =<span style="color: red">N'MyOutput'</span>;</code></div></li>
<div style="clear: both"></div>
 	<li>As you executed these examples, you might have noticed that they each return a result with "(No column name)"? You can specify a name for the columns that are returned by adding "WITH RESULT SETS" to the end of the statement:</li>
 	<li>
<div style="background: #EEE;margin-left: 15px"><code style="font-size: 12px;background: none"><span style="color: blue">EXEC</span> sp_execute_external_script  <span style="color: #8b0000">@language</span> =<span style="color: red">N'Python'</span>,
<span style="color: #8b0000">@script</span>=<span style="color: red">N'
MyOutput = MyInput;
'</span>,
<span style="color: #8b0000">@input_data_1_name</span> = <span style="color: red">N'MyInput'</span>,
<span style="color: #8b0000">@input_data_1</span> =<span style="color: red">N'
SELECT 1 AS foo,
2 AS bar
'</span>,
<span style="color: #8b0000">@output_data_1_name</span> =<span style="color: red">N'MyOutput'</span>
<span style="color: blue">WITH</span> RESULT SETS ((MyColName <span style="color: blue">int</span>, MyColName2 <span style="color: blue">int</span>));</code></div></li>
<div style="clear: both"></div>
 	<li>WITH RESULT SETS is a comma separated list of column names and their datatypes.</li>
</ol>
<h4>Input/Output DataTypes</h4>
Alright, let's discuss a little more about the input/output data types used between SQL and Python.
<ol>
 	<li value="1"><span>Your input SQL SELECT statement passes a "Dataframe" to python relying on the Python <a href="https://pypi.org/project/pandas/">Pandas package</a>.</span></li>
 	<li><span>Your output from Python back to SQL also needs to be in a Pandas Dataframe object. If you need to convert scalar values into a dataframe here is an example:</span></li>
 	<li>
<div style="background: #EEE;margin-left: 15px;float: left"><code style="font-size: 12px;background: none"><span style="color: blue">EXEC</span> sp_execute_external_script  <span style="color: #8b0000">@language</span> =<span style="color: red">N'Python'</span>,
<span style="color: #8b0000">@script</span>=<span style="color: red">N'
import pandas as pd
c = 1/2
d = 1*2
s = pd.Series([c,d])
df = pd.DataFrame(s)
OutputDataSet = df
'</span></code></div></li>
<div style="clear: both"></div>
 	<li><span>Variables c and d are both scalar values, which you can add to a pandas Series if you like, and then convert them to a pandas dataframe.</span></li>
 	<li><span>This one shows a little bit more complicated example, go read up on the <a href="https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.html">python pandas package documentation</a> for more details and examples.</span></li>
 	<li>
<div style="background: #EEE;margin-left: 15px;float: left"><code style="font-size: 12px;background: none"><span style="color: blue">EXEC</span> sp_execute_external_script  <span style="color: #8b0000">@language</span> =<span style="color: red">N'Python'</span>,
<span style="color: #8b0000">@script</span>=<span style="color: red">N'
import pandas as pd
s = {"col1": [1, 2], "col2": [3, 4]}
df = pd.DataFrame(s)
OutputDataSet = df
'</span></code></div></li>
</ol>
<div style="clear: both"></div>

You now know the basics to execute Python in T-SQL! Did you know you can also write your R and Python code in your favorite IDE like RStudio and Jupyter Notebooks and then remotely send the execution of that code to SQL Server? Check out these documentation links and stay tuned for more blog posts: 
<a target="_blank" href="https://aka.ms/R-RemoteSQLExecution" rel="noopener">https://aka.ms/R-RemoteSQLExecution</a> 
<a target="_blank" href="https://aka.ms/PythonRemoteSQLExecution" rel="noopener">https://aka.ms/PythonRemoteSQLExecution </a>

Leave a comment below to ask questions or even tell us about the ways you have used Machine Learning Services in your database.]]></content:encoded>
    </item>
    <item>
      <title>Build Your Own Text Classification Model</title>
      <link>https://docs.microsoft.com/archive/blogs/mlserver/build-your-own-text-classification-model</link>
      <pubDate>Thu, 24 May 2018 09:25:55 GMT</pubDate>
      <dc:creator><![CDATA[Sheri Gilley]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/mlserver/?p=6585</guid>
      <description><![CDATA[In a support center, text needs to be quickly routed to the correct person.  Chatbots need to turn...]]></description>
      <content:encoded><![CDATA[In a support center, text needs to be quickly routed to the correct person.  Chatbots need to turn text into different scenarios to be addressed.  Sentiment analysis determines whether text is positive, negative, or neutral.  In all three of these examples, machine learning models can help.

The <a href="https://aka.ms/text-classification">Text Classification solution on the Azure AI Gallery </a> solves these multi-class text classification problems using SQL Server ML Services.  Both R and Python solutions are included. <a href="https://scikit-learn.org/stable/datasets/twenty_newsgroups.html">The 20 newsgroups dataset</a> is used (with some modification) to demonstrate the model building process, which can easily be generalized to other problems such as support ticket classification, chatbot, or sentiment analysis data. 

The data schema for training the model is simple: items with one or more pieces of text (for example, a title and longer description) and the label representing the desired classification. This solution uses the Multiclass Logistic Regression model in the <a href="https://docs.microsoft.com/en-us/machine-learning-server/r/concept-what-is-the-microsoftml-package">MicrosoftML package</a> to train the model. The trained model is evaluated and then deployed to SQL Stored procedures. It is straightforward to swap in your own data with the same schema and rerun the code in the solution to build your own customized model.  

Once you've built your model, open the provided Power BI file to examine the results of your model on your test data and your new unclassified items. Use the Power BI Refresh button in the toolbar to replace the example with your own data and model. (If you use a different database name or table names, first go to the PowerBI Data Source Settings and/or the Edit Queries section to supply the correct names, then use Refresh.)

<img width="300" height="178" class="alignnone size-medium wp-image-6595" alt="" src="https://msdnshared.blob.core.windows.net/media/2018/05/Capture1-300x178.png" />

Remember, you can quickly deploy this solution either <a href="https://blogs.msdn.microsoft.com/mlserver/2018/04/27/on-prem-or-on-the-cloud/">On-Prem or On the Cloud</a>.]]></content:encoded>
    </item>
  </channel>
</rss>