<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Mustafa Kasap Microsoft Tech Blog</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/mustafakasap/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/mustafakasap/feed.xml</link>
    <description />
    <lastBuildDate>Wed, 17 Apr 2019 03:23:41 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Welcome Azure Usage and Billing Portal</title>
      <link>https://docs.microsoft.com/archive/blogs/mustafakasap/welcome-azure-usage-and-billing-portal</link>
      <pubDate>Thu, 14 Jul 2016 16:05:42 GMT</pubDate>
      <dc:creator><![CDATA[Mustafa Kasap]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/mustafakasap/?p=346</guid>
      <description><![CDATA[Today, we are very excited to announce the availability of Azure Usage and Billing Portal (AUBP) as...]]></description>
      <content:encoded><![CDATA[Today, we are very excited to announce the availability of Azure Usage and Billing Portal (AUBP) as an open-source project under <a href="https://github.com/Microsoft/AzureUsageAndBillingPortal">GitHub Microsoft organization</a>. Having wide range of Microsoft Azure Cloud services available, we know that users or organizations want to get detailed insights about the consumed services. Some of the AUBP usage scenarios including but not limited to are: A company with a single azure subscription is tagging the created services by department name so each department’s usage details can be reported according to tags. A school tracks each student’s Azure usage details (i.e. how many hours of Unix VM is used by student X, how much data downloaded by student Y or who uses 512 GB RAM VMs etc.) with a single report. Or a developer can set alerts to be notified in case there is an anomaly in his/her startup’s web app activity etc. Once the subscription owner gives a consent (which may be revoked at any time by him/her) to the AUBP system, portal administrator can get up to date visual or csv report about the current and historic cost/usage details about all registered subscriptions in the system. This features in mind, as a reference application, AUBP project is developed and open-sourced for your collaboration. In this blog post I will try to answer and give a bit more technical details about the project.

AUBP portal has two web based user interface; one is accessible by anyone to let them register/unregister any number of their Azure Subscription to the system, other is an authenticated access portal where up-to-date usage and billing details of the registered subscriptions can be monitored. You can get more general overview about the AUBP system at <a href="https://azure.microsoft.com/en-us/blog/announcing-the-release-of-the-azure-usage-and-billing-portal/">Microsoft Azure Blog site</a>.

If you want to customize or deep dive into AUBP project, <a href="https://azure.microsoft.com/en-us/documentation/articles/billing-usage-rate-card-overview/">Azure Resource Usage and RateCard APIs</a> is the starting point. You can also explore open source <a href="https://azure.microsoft.com/documentation/samples/?term=billing">Code Samples</a> that uses these APIs. These samples show you how to access raw usage/cost details through console or web applications.

Main idea behind the AUBP project is to create an Azure Active Directory (AD) Application (something like a user account) in the AUBP platform and get a consent for this AD app from any subscription owner so thisr AD app can access that subscription with restricted functionality. For more technical details on this process you may refer to “<a href="http://www.dushyantgill.com/blog/2015/05/23/developers-guide-to-auth-with-azure-resource-manager-api/">Developer’s guide to auth with Azure Resource Manager API</a>”

<a href="https://msdnshared.blob.core.windows.net/media/2016/07/Picture1.jpg" rel="attachment wp-att-355"><img class="aligncenter size-full wp-image-355" src="https://msdnshared.blob.core.windows.net/media/2016/07/Picture1.jpg" alt="Architecture" width="359" height="306" /></a>
<p style="text-align: center">Architecture overview of the AUBP</p>
Any user can access to “Registration Web App” that is hosted on your subscription and enter their own credentials to let your AD app to be able to access their billing details. Here AUBP is not accessing or storing etc. your credentials, everything is done transparently on the cloud as you may see through the source code. Giving consent to the AD app (registering the AD app into your AD in your subscription) doesn’t mean that the app can do anything on your subscription. Access details are explained in the authentication stage, and just limited to get usage/billing details, nothing else.

With default configuration, web job runs once per day and collect previous day’s usage/billing details of a subscription. Frequency of this process can be adjusted through WebJob’s configuration file. Data collected through Billing API by the WebJob is stored in an SQL server. By this way, it is possible to create custom PowerBI (one sample already provided in the GitHub Repo) report based on this data.

<a href="https://msdnshared.blob.core.windows.net/media/2016/07/Picture2.jpg" rel="attachment wp-att-356"><img class="aligncenter size-full wp-image-356" src="https://msdnshared.blob.core.windows.net/media/2016/07/Picture2.jpg" alt="Sample Report" width="431" height="524" /></a>
<p style="text-align: center">Default report generated by AUBP</p>
As in the above default report, you can filter out all or few registered subscriptions to be monitored with several criteria. You can see the result of real-time interaction immediately on the report. Because PowerBI reports are interactive, if you click/select any graph, shape etc. on the report, only the selected feature will be highlighted with respect to the others etc. In addition, the intensity of the bars in bar charts matters. i.e. First bar chart from top, “Cost per day with quantity measures”, shows the cost of all services under all or selected subscriptions per day in a date range (if you haven’t applied other filters) magnitude of the bar shows the amount but intensity shows the quantity of the service used. i.e.

If you are monitoring many subscriptions with a wide range of date interval, which means millions of records on the SQL DB, be sure that you are using right tier of services (i.e. higher tier SQL server for many I/O operations possible by PowerBI etc.) Or if it took so much time to collect per subscription daily usage data, then scale up concurrent WebJob count in the config file or on the portal.
<p style="text-align: left">We highly recommend to have general knowledge on <a href="https://azure.microsoft.com/en-us/documentation/articles/billing-usage-rate-card-overview/">Azure Resource Usage and RateCard APIs</a> and <a href="http://www.dushyantgill.com/blog/2015/05/23/developers-guide-to-auth-with-azure-resource-manager-api/">Developer’s guide to auth with Azure Resource Manager API</a> to develop similar projects or customize this one.</p>]]></content:encoded>
    </item>
    <item>
      <title>Py 01 - Visual Studio: Publish Python Script on a Unix Machine &amp; Remote Debug</title>
      <link>https://docs.microsoft.com/archive/blogs/mustafakasap/py-01-visual-studio-publish-python-script-on-a-unix-machine-remote-debug</link>
      <pubDate>Thu, 04 Feb 2016 19:35:01 GMT</pubDate>
      <dc:creator><![CDATA[Mustafa Kasap]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/mustafakasap/2016/02/04/py-01-visual-studio-publish-python-script-on-a-unix-machine-remote-debug/</guid>
      <description><![CDATA[Overview
    In this post we will mention:
Develop Python application in a Microsoft Windows...]]></description>
      <content:encoded><![CDATA[<h2>Overview
</h2><p>    In this post we will mention:
</p><ul style="margin-left: 54pt"><li>Develop Python application in a Microsoft Windows environment with Visual Studio
</li><li>Publish it to a RaspberryPi (RPi) that is running Raspbian OS 
</li><li>Run the app on RaspberryPi and remotely debug it with Visual Studio on Windows
</li></ul><p>In <a href="https://www.visualstudio.com/en-us/features/python-vs.aspx">this link</a> you can find some of the answers to the question "Why to develop Python app in Visual Studio?" We will use fresh Raspbian installation and show step by step preparation of the  Raspberry Pi device.
</p><h2>Requirements
</h2><ul style="margin-left: 54pt"><li>Windows machine with <a href="https://www.visualstudio.com/en-us/products/visual-studio-community-vs.aspx">Visual Studio Community Edition</a> (Free for developers)
</li><li><a href="https://www.visualstudio.com/en-us/features/python-vs.aspx">Python Tools for Visual Studio</a> (<a href="https://github.com/Microsoft/PTVS">Open Source</a>)
</li><li><a href="https://www.raspberrypi.org/">Raspberry Pi 2 Model B</a> with <a href="https://www.raspberrypi.org/downloads/noobs/">Raspbian OS</a> (+Power Supply, Micro SD Card, Ethernet Cable or WIFI dongle)
</li><li>Wired or Wireless Internet connection
</li><li><a href="http://www.putty.org/">Putty SSH Client</a>
		</li></ul><h2>Preparation 
</h2><ul style="margin-left: 54pt"><li>Install Visual Studio then Python tools for Visual Studio (If not already installed), connect the machine to internet
</li><li>Install Putty on your desktop (actually just copy the single EXE file on to your Desktop)
</li><li>Install Raspbian on RaspberryPi (<a href="https://www.raspberrypi.org/help/noobs-setup/">setup guide</a>) 
</li><li>Connect RaspberryPi to Internet (wired or wireless). (<a href="https://www.raspberrypi.org/documentation/configuration/wireless/wireless-cli.md">Howto wireless connection</a>)
</li></ul><p>Be sure that both the development machine (with Visual Studio) and the RaspberryPi connected to the same network. You should be able to ping RaspberryPi from the windows machine.
</p><h2>Get IP Address
</h2><p style="margin-left: 36pt">We need to know the IP address of the RaspberryPI device so we can deploy our Python script and debug it remotely. To get the IP address of the RPi device follow the steps <a href="https://www.raspberrypi.org/documentation/remote-access/ip-address.md">mentioned here</a>. In this post our RPi device's IP address is: 192.168.0.107
</p><h2>Get Putty &amp; Open a Terminal Window
</h2><p style="margin-left: 36pt">We don't want to switch between one monitor or keyboard to another. So we will use the development machine to access the RPi device remotely. To do so open a Putty window and enter your RPi's IP address as shown in the below screenshot. <strong><em>Keep the rest of the settings as they are</em></strong>.
</p><p><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/6082.020516_0337_Py01Visual1.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/6082.020516_5F00_0337_5F00_Py01Visual1.png" alt=""/>
	</p><p>    Click the "Open" button to open a terminal window to the RPi device.
</p><p><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/3301.020516_0337_Py01Visual2.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/3301.020516_5F00_0337_5F00_Py01Visual2.png" alt=""/>
	</p><h2>Prepare RPi for Python Project
</h2><ul style="margin-left: 54pt"><li><div>Login to the RPi device through the terminal window opened in the previous step.
</div><p style="margin-left: 18pt">Default username is: <strong>pi</strong>
			</p><p style="margin-left: 18pt">Default password is: <strong>raspberry</strong>
			</p><p>
 </p><p><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/0247.020516_0337_Py01Visual3.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/0247.020516_5F00_0337_5F00_Py01Visual3.png" alt=""/>
			</p><p>
 </p></li><li><div>Create folder named "<strong>pythonapp</strong>" and change its access mode to "<strong>0777</strong>" so anyone can access/read/write in this folder. Note its path by typing "<strong>pwd</strong>" command. In our case the path is: "/home/pi/pythonapp"
</div><p>
 </p><p><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/7103.020516_0337_Py01Visual4.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/7103.020516_5F00_0337_5F00_Py01Visual4.png" alt=""/>
			</p><p>Commands used in order:
</p><p><strong>    mkdir pythonapp
</strong></p><p><strong>    chmod 0777 pythonapp
</strong></p><p><strong>    cd pythonapp
</strong></p><p><strong>    pwd
</strong></p><p>
 </p></li><li><div>Update all packages to its recent version by typing the following command in the terminal window:
</div><p style="margin-left: 18pt"><strong>sudo apt-get update
</strong></p><p style="margin-left: 18pt">
 </p></li><li><div>Install opensource <a href="https://pypi.python.org/pypi/ptvsd"><strong>ptvsd</strong></a> remote debugging libraries on RPi device by typing the following command in the terminal window:
</div><p style="margin-left: 18pt"><strong>sudo pip install ptvsd
</strong></p><p style="margin-left: 18pt">
 </p></li></ul><h2>Enable Windows file share on RPi device
</h2><ul style="margin-left: 54pt"><li><div>Install Samba software package by typing the following command in the terminal window:
</div><p><strong>sudo apt-get install samba samba-common-bin
</strong></p><p>
 </p></li><li><div>Configure Samba installation by typing the following command in the terminal window:
</div><p><strong>sudo nano /etc/samba/smb.conf
</strong></p><p>
 </p><p>above command will open an editor with samba configuration file. Scroll down and add the following lines to the end of the configuration file.
</p><p>
 </p><p><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/3806.020516_0337_Py01Visual5.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/3806.020516_5F00_0337_5F00_Py01Visual5.png" alt=""/>
			</p><p>
 </p><p>lines added to the end of the configuration file:
</p><p style="margin-left: 18pt"><strong> [pythonapp]
</strong></p><p style="margin-left: 18pt"><strong>  path=/home/pi/pythonapp
</strong></p><p style="margin-left: 18pt"><strong>  browsable=yes
</strong></p><p style="margin-left: 18pt"><strong>  writable=yes
</strong></p><p style="margin-left: 18pt"><strong>  only guest=no
</strong></p><p style="margin-left: 18pt"><strong>  create mask=0777
</strong></p><p style="margin-left: 18pt"><strong>  directory mask=0777
</strong></p><p style="margin-left: 18pt"><strong>  public=yes</strong>
			</p><p>
 </p><p>Switch back to windows, open Windows File Explorer in the development machine. Type <strong>"\\192.168.0.107\pythonapp" </strong>in the address bar. You should be able to explore the empty folder in RPi device from a windows machine.
</p><p>
 </p><p><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/0257.020516_0337_Py01Visual6.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/0257.020516_5F00_0337_5F00_Py01Visual6.png" alt=""/>
			</p><p>
 </p></li></ul><h2>Develop &amp; Publish Python App
</h2><ul style="margin-left: 54pt"><li><div>Open Visual Studio, create a new project.
</div><p><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/7522.020516_0337_Py01Visual7.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/7522.020516_5F00_0337_5F00_Py01Visual7.png" alt=""/>
			</p><p>
 </p></li><li><div>Select the "Python Application" from the templates, and create a blank project.
</div><p><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/0763.020516_0337_Py01Visual8.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/0763.020516_5F00_0337_5F00_Py01Visual8.png" alt=""/>
			</p></li></ul><p>
 </p><ul style="margin-left: 54pt"><li><div>Change project's Python environment by right click on the "Python Environment" node under the project name in the solution explorer window. Click on the "Add/Remove Python Environments…" item in the pop-up menu.
</div><p><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/6457.020516_0337_Py01Visual9.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/6457.020516_5F00_0337_5F00_Py01Visual9.png" alt=""/>
			</p><p>
 </p></li><li><div>Select just the "Python 2.7" in the pop-up window and click OK button.
</div><p><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/6471.020516_0337_Py01Visual10.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/6471.020516_5F00_0337_5F00_Py01Visual10.png" alt=""/>
			</p><p>
 </p></li><li><div>Right click on the "Python 2.7" node under the "Python Environments" in the solution explorer window. Click on the "Install Python Package…" item in the pop-up menu.
</div><p><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/8117.020516_0337_Py01Visual11.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/8117.020516_5F00_0337_5F00_Py01Visual11.png" alt=""/>
			</p><p>
 </p></li><li><div>Type "ptvsd" in the package to install edit box and click OK.
</div><p><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/0677.020516_0337_Py01Visual12.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/0677.020516_5F00_0337_5F00_Py01Visual12.png" alt=""/>
			</p><p>
 </p></li><li><div>Enter the following lines of Python code in to the "pythonapp.py" file through the editor.
</div><p style="margin-left: 54pt"><span style="color:blue; font-family:Consolas; font-size:9pt; background-color:white">import<span style="color:black">
						<span style="color:#6f008a">ptvsd<span style="color:black">
							</span></span></span></span></p><p style="margin-left: 54pt"><span style="color:#6f008a; font-family:Consolas; font-size:9pt; background-color:white">ptvsd<span style="color:black">.enable_attach(secret=<span style="color:#a31515">'my_secret'<span style="color:black">)
</span></span></span></span></p><p style="margin-left: 54pt">
 </p><p style="margin-left: 54pt"><span style="color:black; font-family:Consolas; font-size:9pt; background-color:white">first_num = <span style="color:#2b91af">int<span style="color:black">(raw_input(<span style="color:#a31515">'Enter first number: '<span style="color:black">))
</span></span></span></span></span></p><p style="margin-left: 54pt"><span style="color:black; font-family:Consolas; font-size:9pt; background-color:white">second_num = <span style="color:#2b91af">int<span style="color:black">(raw_input(<span style="color:#a31515">'Enter second number: '<span style="color:black">))
</span></span></span></span></span></p><p style="margin-left: 54pt"><span style="color:black; font-family:Consolas; font-size:9pt; background-color:white">sum = first_num + second_num
</span></p><p style="margin-left: 54pt"><span style="color:blue; font-family:Consolas; font-size:9pt"><span style="background-color:white">print<span style="color:black">(<span style="color:#a31515">'{0} + {1} = {2}: '<span style="color:black">.format(first_num, second_num, sum))</span></span></span></span>
				</span></p><p style="margin-left: 54pt">
 </p><p>
 </p><p><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/6813.020516_0337_Py01Visual13.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/6813.020516_5F00_0337_5F00_Py01Visual13.png" alt=""/>
			</p><p>
 </p></li><li><div>Click the "Start" button on Visual Studio toolbar to run the script locally.
</div><p><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/1526.020516_0337_Py01Visual14.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/1526.020516_5F00_0337_5F00_Py01Visual14.png" alt=""/>
			</p><p>
 </p></li><li><div>Console window will open and waits you to enter two integer value, then shows the sum of these two numbers.
</div><p><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/8463.020516_0337_Py01Visual15.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/8463.020516_5F00_0337_5F00_Py01Visual15.png" alt=""/>
			</p></li><li><div>Now lets make required settings to be able publish the app to RaspberryPi device. Open the project properties window by right clicking on the project name under solution explorer window and then click on the "properties" menu item.
</div><p><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/5824.020516_0337_Py01Visual16.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/5824.020516_5F00_0337_5F00_Py01Visual16.png" alt=""/>
			</p><p>
 </p></li><li><div>In the properties window, switch to the "Publish" tab, enter publish location as "\\192.168.0.107\pythonapp" (or whatever in your case) then press "Publish Now" button.
</div><p>
 </p><p><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/0636.020516_0337_Py01Visual17.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/0636.020516_5F00_0337_5F00_Py01Visual17.png" alt=""/>
			</p><p>
 </p><p>This will copy the latest version of your Python script into the Raspberry Pi device.
</p><p>
 </p></li><li><div>Any time you update the Python script, just right click on the Project name in the solution explorer window and click on the "Publish" button afterwards. This will also copy the latest version of your Python script into the Raspberry Pi device.
</div><p><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/3782.020516_0337_Py01Visual18.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/3782.020516_5F00_0337_5F00_Py01Visual18.png" alt=""/>
			</p></li></ul><h2>Remotely Debug the Python script that is running on Raspberry Pi Device
</h2><ul style="margin-left: 54pt"><li><div>Switch back to the Putty terminal window. If session timed-out, re-enter your credentials and go to the "pythonapp" folder. Type the following command in the SSH terminal window:
</div><p><strong>python pythonapp.py
</strong></p><p>
 </p></li><li><div>Previous command will run the python script. Before entering first number switch back to "Visual Studio" window.
</div><p><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/8176.020516_0337_Py01Visual19.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/8176.020516_5F00_0337_5F00_Py01Visual19.png" alt=""/>
			</p></li><li><div>In Visual Studio, put a breakpoint on the line that starts with "sum = first…"
</div><p><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/7180.020516_0337_Py01Visual20.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/7180.020516_5F00_0337_5F00_Py01Visual20.png" alt=""/>
			</p><p>
 </p></li><li><div>In the "Debug" menu, click on "Attach to Process…" menu item.
</div><p><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/6332.020516_0337_Py01Visual21.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/6332.020516_5F00_0337_5F00_Py01Visual21.png" alt=""/>
			</p><p>
 </p></li><li><div>In the "Attach to Process" window, select "Python remote (ptvsd)" as Transport. Enter "tcp://my_secret@192.168.0.107" as Qualifier and press ENTER. Available Python processes on the RPi device will be listed. Select the one to Debug and press "Attach" button in this window.
</div><p>
 </p><p><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/4606.020516_0337_Py01Visual22.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/4606.020516_5F00_0337_5F00_Py01Visual22.png" alt=""/>
			</p><p>
 </p><p>Here the keyword "my_secret" in the Qualifier must be the same keyword that we entered in the second line of the Python source code.
</p><p>
 </p></li><li><div>Now go back to the SSH terminal to the RPi device and enter the two integer value to calculate their sum. When you enter the second number and press ENTER, Visual studio will flash and the execution cursor will stop on the breakpoint. You can browse local variables, threads, their values etc. on the Locals, Watch, Threads, Call Stack etc. windows. You can execute the script line by line remotely.
</div><p>
 </p><p><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/0160.020516_0337_Py01Visual23.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/0160.020516_5F00_0337_5F00_Py01Visual23.png" alt=""/><strong>
				</strong></p></li></ul><p>
 </p><p>
 </p><p>
 </p><p>
 </p><p>
 </p><p>
 </p><p>
 </p><p>
 </p><p>
 </p>]]></content:encoded>
    </item>
    <item>
      <title>ML 04 – Develop and Consume Azure ML Experiment as a Web Service</title>
      <link>https://docs.microsoft.com/archive/blogs/mustafakasap/ml-04-develop-and-consume-azure-ml-experiment-as-a-web-service</link>
      <pubDate>Wed, 06 Jan 2016 16:09:00 GMT</pubDate>
      <dc:creator><![CDATA[Mustafa Kasap]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/mustafakasap/2016/01/06/ml-04-develop-and-consume-azure-ml-experiment-as-a-web-service/</guid>
      <description><![CDATA[This post will answer:

How to develop simplest Azure Machine Learning (AML) experiment?
How to...]]></description>
      <content:encoded><![CDATA[<p>This post will answer:</p>
<ul style="margin-left: 54pt;">
<li>How to develop simplest Azure Machine Learning (AML) experiment?</li>
<li>How to publish AML Experiment as a scalable Web Service?</li>
<li>How to consume the Web Service from an R/Python script?</li>
</ul>
<h2>How to develop simplest Azure Machine Learning (AML) experiment?</h2>
<p>In our initial post on ML series, using the R studio, we have developed a sample ML solution with linear R model. In this post we will develop the same solution completely in AML with minimum effort.</p>
<p>Referring to our <a href="http://blogs.msdn.com/b/mustafakasap/archive/2015/12/28/more-on-machine-learning-amp-azure-machine-learning-service.aspx">previous post</a>, create a new "blank experiment" and add (drag/drop) the following modules on the empty canvas:</p>
<ul style="margin-left: 54pt;">
<li>"Enter Data Manually": used to enter training data</li>
<li>"Linear Regression": Linear Regression Model</li>
<li>"Train Model": Module to train the Model with provided data</li>
</ul>
<p>Below is the screen shot from the canvas with the above modules connected to each other. To connect the modules with each other, just press the mouse left button on the modules output port, and drag/drop it on to the input port of the other module. You will see a directed arrow will be drawn. Referring to the below screenshot, if you can't find the above modules, just type their names inside the "Search experiment items" search box, it will be filtered out for you.</p>
<p><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/8802.010716_0009_ML04AzureM1.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/8802.010716_5F00_0009_5F00_ML04AzureM1.png" alt="" /></p>
<p>On the right side of the window you will see a child window (like the toolbox) with the caption "Properties". One by one, clicking on (making it selected) each of the three module, you can see corresponding properties of that module in the properties window. Starting from the first module "Enter Data Manually", we will update their properties.</p>
<p>First we will generate a training dataset. Using the same method mentioned in <a href="http://blogs.msdn.com/b/mustafakasap/archive/2015/10/26/01-machine-learning-and-r.aspx">previous post</a>, with an Excel sheet generate data series with random noise. Plotting this data should look like a noisy line with slope = 1 as shown below. This data consists of two columns: X and Y. For each value in X column you will see the corresponding Y value. You should observe that almost all Y values are (+/- 50) same to the X value.</p>
<p>Aim is to develop an ML solution to predict corresponding Y value of any X value which does not exists in our training dataset.</p>
<p><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/6761.010716_0009_ML04AzureM2.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/6761.010716_5F00_0009_5F00_ML04AzureM2.png" alt="" /></p>
<p><strong>&nbsp;How to generate training data video:</strong></p>
<p>[View:http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12/8838.ml04Blog.mp4]&nbsp;</p>
<p>&nbsp;</p>
<div>
<table style="border-collapse: collapse;" border="0"><colgroup><col style="width: 143px;" /><col style="width: 156px;" /><col style="width: 156px;" /></colgroup>
<tbody valign="top">
<tr style="background: #d9d9d9;">
<td style="padding-left: 7px; padding-right: 7px; border: solid 0.5pt;">
<p style="text-align: center;">Module</p>
</td>
<td style="padding-left: 7px; padding-right: 7px; border-top: solid 0.5pt; border-left: none; border-bottom: solid 0.5pt; border-right: solid 0.5pt;" colspan="2">
<p style="text-align: center;">Properties</p>
</td>
</tr>
<tr>
<td style="padding-left: 7px; padding-right: 7px; border-top: none; border-left: solid 0.5pt; border-bottom: solid 0.5pt; border-right: solid 0.5pt;">
<p>Enter Data Manually</p>
</td>
<td style="padding-left: 7px; padding-right: 7px; border-top: none; border-left: none; border-bottom: solid 0.5pt; border-right: solid 0.5pt;">
<p><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/7776.010716_0009_ML04AzureM3.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/7776.010716_5F00_0009_5F00_ML04AzureM3.png" alt="" /></p>
</td>
<td style="padding-left: 7px; padding-right: 7px; border-top: none; border-left: none; border-bottom: solid 0.5pt; border-right: solid 0.5pt;">
<p>In previous step, we generated data for training and Copy it to the clipboard. Now Paste this data into the properties window of the "Enter Data Manually" module. Don't forget to select "HasHeaders" checkbox.</p>
</td>
</tr>
<tr>
<td style="padding-left: 7px; padding-right: 7px; border-top: none; border-left: solid 0.5pt; border-bottom: solid 0.5pt; border-right: solid 0.5pt;">
<p>Linear Regression</p>
</td>
<td style="padding-left: 7px; padding-right: 7px; border-top: none; border-left: none; border-bottom: solid 0.5pt; border-right: solid 0.5pt;">
<p><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/7128.010716_0009_ML04AzureM4.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/7128.010716_5F00_0009_5F00_ML04AzureM4.png" alt="" /></p>
</td>
<td style="padding-left: 7px; padding-right: 7px; border-top: none; border-left: none; border-bottom: solid 0.5pt; border-right: solid 0.5pt;">
<p>Keep the default parameters of the "Linear Regression" module as it is.</p>
</td>
</tr>
<tr>
<td style="padding-left: 7px; padding-right: 7px; border-top: none; border-left: solid 0.5pt; border-bottom: solid 0.5pt; border-right: solid 0.5pt;">
<p>Train Model</p>
</td>
<td style="padding-left: 7px; padding-right: 7px; border-top: none; border-left: none; border-bottom: solid 0.5pt; border-right: solid 0.5pt;">
<p><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/7217.010716_0009_ML04AzureM5.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/7217.010716_5F00_0009_5F00_ML04AzureM5.png" alt="" /></p>
</td>
<td style="padding-left: 7px; padding-right: 7px; border-top: none; border-left: none; border-bottom: solid 0.5pt; border-right: solid 0.5pt;">
<p>Click on the "Launch Column selector" button in the properties window of Train Model. Select or Type Y as the label column name.</p>
</td>
</tr>
</tbody>
</table>
</div>
<p>&nbsp;</p>
<p>After settings the properties of the modules, now it is time to train our model by pressing the run button. On the bottom of the page.</p>
<p><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/8625.010716_0009_ML04AzureM6.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/8625.010716_5F00_0009_5F00_ML04AzureM6.png" alt="" /></p>
<p>It will take around a minute to run the solution and after a successful run you will see green checkmarks on the right side of each module.</p>
<h2>How to publish AML Experiment as a scalable Web Service?</h2>
<p>How will we use this ML solution? Will it take ~1 minute each time to train the model for such small amount of data for training? No, we don't need to train our model every time. Once it is trained, if there is no major change in your training dataset, then you can keep the trained model as it is. To be able to use this trained model, you need to publish it as a web service. To do so, first click on the "Set up web Service" button near the "RUN" button. In the menu windows, select "Create Predictive Experiment". With this command it will create a new experiment by adding "Web Service Input" and "Web Service Output" modules.</p>
<p>&nbsp;</p>
<p>I also made small modification by manually adding two "Project Columns" modules. You can omit them, there will not be a problem in your solution. Reason for putting these two modules is to filter out the Y column in the training dataset. As we already trained our model, we don't need Y column anymore, and we don't want it to be visible in our new web service as an input parameter. Because we want to predict this value, so there is no need to provide it as an input parameter. Same for the output. We filter out the output data by just allowing "Scored values" &ndash; predicted values to be visible in the web service output.</p>
<p><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/2705.010716_0009_ML04AzureM7.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/2705.010716_5F00_0009_5F00_ML04AzureM7.png" alt="" /></p>
<p>Now you have to "Run" this experiment once again to be able to publish it as a web service. After a successful run, you will see "Deploy Web Service" button near the "RUN" button, press it. After few seconds your web service will be ready.</p>
<p><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/5481.010716_0009_ML04AzureM8.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/5481.010716_5F00_0009_5F00_ML04AzureM8.png" alt="" /></p>
<p>Press the "TEST" button which will pop out an input parameters dialog box. Type any "X" value that you want to predict its corresponding "Y" value. i.e. 3578, which is not in our training set.</p>
<p><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/4705.010716_0009_ML04AzureM9.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/4705.010716_5F00_0009_5F00_ML04AzureM9.png" alt="" /></p>
<p>After few seconds you will see the output of this web service on the bottom of the page as:</p>
<p><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/4377.010716_0009_ML04AzureM10.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/4377.010716_5F00_0009_5F00_ML04AzureM10.png" alt="" /></p>
<p>&nbsp;</p>
<h2>How to consume the Web Service from an R script?</h2>
<p>Just click on the "Response/Request" link near the "TEST" button. It will open a new page with sample codes. Copy/Paste the R code into a new page in RStudio.</p>
<p><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/2526.010716_0009_ML04AzureM11.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/2526.010716_5F00_0009_5F00_ML04AzureM11.png" alt="" /></p>
<p>In this sample code you have to update 2 lines. One is the key (password) to access the web service that we created. Copy the key in the web service management page:</p>
<p><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/4336.010716_0009_ML04AzureM12.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/4336.010716_5F00_0009_5F00_ML04AzureM12.png" alt="" /></p>
<p>And type this key into the following line by deleting the "abc123"</p>
<p><em>api_key = "abc123" # Replace this with the API key for the web service </em></p>
<p>Also you should update the web service input parameters. Following line</p>
<p><em> "Values" = list( list( "0" ), list( "0" ) ) </em></p>
<p>with</p>
<p><em> "Values" = list( list( "3578" ), list( "6000" ) ) </em></p>
<p>In this sample two different input values provided, 3578 and 6000. You can provide as much as you want by putting comma between them.</p>
<p>&nbsp;</p>
<p>If you have just installed the RStudio (we mentioned how to install it in the first ML post) on your machine, then you will get two error message when you run the sample code:</p>
<ol>
<li>Error in library("rjson") : there is no package called 'rjson'</li>
<li>Error in library("RCurl") : there is no package called 'RCurl'</li>
</ol>
<p>Our sample code uses these packages and they are not installed to RStudio by default. You can install them from Tools-&gt;Install Packages menu.</p>
<p><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/6685.010716_0009_ML04AzureM13.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/6685.010716_5F00_0009_5F00_ML04AzureM13.png" alt="" /></p>
<p>Just type the missing package name in the text box and press install. Do it both for "RCurl" and "RJson"</p>
<p><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/4062.010716_0009_ML04AzureM14.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/4062.010716_5F00_0009_5F00_ML04AzureM14.png" alt="" /></p>
<p>After all, you can press CTRL+ALT+R button combination to run the R code. In the console window you will see the output of the web service with predicted values of the input Xs.</p>
<p>&hellip;</p>
<p>$Results$output1$value$Values</p>
<p>[1] "<span style="background-color: yellow;">3606</span>.16504920019" "<span style="background-color: yellow;">6030</span>.31943595806"</p>
<p>&hellip;</p>]]></content:encoded>
    </item>
    <item>
      <title>ML 03 – Which version of R and R Packages running on Azure Machine Learning Service?</title>
      <link>https://docs.microsoft.com/archive/blogs/mustafakasap/ml-03-which-version-of-r-and-r-packages-running-on-azure-machine-learning-service</link>
      <pubDate>Mon, 28 Dec 2015 15:03:53 GMT</pubDate>
      <dc:creator><![CDATA[Mustafa Kasap]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/mustafakasap/2015/12/28/ml-03-which-version-of-r-and-r-packages-running-on-azure-machine-learning-service/</guid>
      <description><![CDATA[It is possible to run not only Python but also custom R scripts on Azure Machine Learning (AML)...]]></description>
      <content:encoded><![CDATA[<p>It is possible to run not only Python but also custom R scripts on Azure Machine Learning (AML) service. There exist several R versions and many optional R packages around. What about compatibility? Is AML possible to run the same R script that is already running on your local machine? Which R packages are installed on AML?
</p><p>Following experiments will answer the above questions and we will develop our first AML experiment with a custom R script.
</p><p>
 </p><p>In our previous <a href="http://blogs.msdn.com/b/mustafakasap/archive/2015/10/26/01-machine-learning-and-r.aspx">blog post</a>, we mentioned about R and R Studio and also developed a simple R script that runs an ML model. 
</p><p style="margin-left: 36pt"><em>(quote from prev. post) You can get the free open source development environment and libraries from <a href="https://www.r-project.org">https://www.r-project.org</a>. Moreover, a free IDE with GUI can be found at <a href="https://www.rstudio.com">https://www.rstudio.com</a>. There also exist hundreds of open source algorithms, software libraries under <a href="https://cran.r-project.org">https://cran.r-project.org</a>.
</em></p><ol><li>Open <strong>R Studio</strong> and type the following simple code on the console window and press ENTER
</li></ol><p style="background: white"><span style="color:blue; font-family:Lucida Console; font-size:10pt">    &gt; version
</span></p><p style="background: white; margin-left: 18pt">
 </p><p>    output will be something like:
</p><p><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/5584.122815_2305_ML03Whichv1.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/5584.122815_5F00_2305_5F00_ML03Whichv1.png" alt=""/>
	</p><p>    Here we run the R command named "version" which returns the R version related details and print them on the command window. <strong>version.string</strong> or <strong>minor/major</strong> values in the output window are the version of R environment installed on our machine. In our case local R version is: 3.1.0
</p><ol><li><div>Now try to do the same in AML. Referring to our <a href="http://blogs.msdn.com/b/mustafakasap/archive/2015/12/28/more-on-machine-learning-amp-azure-machine-learning-service.aspx">previous blog post</a>, open Microsoft Azure ML Studio, create a blank Experiment.
</div><p>
 </p><p><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/7673.122815_2305_ML03Whichv2.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/7673.122815_5F00_2305_5F00_ML03Whichv2.png" alt=""/>
			</p><p>
 </p></li><li><div>From the toolbar/modules bar on the left, drag and drop an "Execute R Script" module on the empty canvas. If you can't find the "Execute R Script" module within tens of other modules, just type one of the words in "Execute R Script" into the search box on the left top corner of the window on modules bar.
</div><p>
 </p><p><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/0310.122815_2305_ML03Whichv3.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/0310.122815_5F00_2305_5F00_ML03Whichv3.png" alt=""/>
			</p><p>
 </p></li><li><div>Referring the above screenshot, click on the module (make the "Execute R Script" module selected). Then you will see properties window on the right side of the main window. Under properties window, you can write your custom R script within the "R Script" text box.
</div><p>
 </p><p>Select all text inside "R Script" textbox and delete them. Now copy/paste the following custom R code inside the textbox.
</p><p>        
</p></li></ol><div style="text-align: center"><table style="border-collapse:collapse" border="0"><colgroup><col style="width:353px"/></colgroup><tbody valign="top"><tr style="height: 107px"><td style="padding-left: 7px; padding-right: 7px; border-top:  solid 0.5pt; border-left:  solid 0.5pt; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt"><p>v &lt;- <span style="color:#cc00ff">version</span>
						</p><p>property &lt;- as.character(<span style="color:#cc00ff">names</span>(v))
</p><p>value &lt;- as.character(v)
</p><p>data.set &lt;- as.data.frame(cbind(property, value))
</p><p>maml.mapOutputPort("<span style="color:#a50021">data.set</span>");</p></td></tr></tbody></table></div><p style="margin-left: 36pt">
 </p><p style="margin-left: 36pt"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/6518.122815_2305_ML03Whichv4.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/6518.122815_5F00_2305_5F00_ML03Whichv4.png" alt=""/>
	</p><p style="margin-left: 36pt">
 </p><ol><li><div>Now press on the RUN button on the bottom of the window to run this experiment. Once the experiment run successfully, you can see the green checkmark on right top corner of the canvas and each module in the experiment.
</div><p><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/7288.122815_2305_ML03Whichv5.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/7288.122815_5F00_2305_5F00_ML03Whichv5.png" alt=""/>
			</p></li><li><div>So what is the output of this experiment? In AML, almost every module has input and output ports. Each module is a part of execution pipeline. To see the output of this R module, click on the <strong>port number 1 </strong>on "Execute R Script Module". Then select "Visualize" command from the popup menu items.
</div><p><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/5444.122815_2305_ML03Whichv6.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/5444.122815_5F00_2305_5F00_ML03Whichv6.png" alt=""/>
			</p></li><li><div>Clicking on the Visualize command will open another window with the results that we expected. Evaluating the result window, output is same as our local result. We are running exactly the same R environment as AML.
</div><p><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/6014.122815_2305_ML03Whichv7.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/6014.122815_5F00_2305_5F00_ML03Whichv7.png" alt=""/>
			</p></li><li>What about the installed R packages on AML? Typing command "installed.packages()" in R Studio will print out the local installed package list. To do the same in AML, just copy paste the following script as we do for "version" and view the result from <strong>port number 1</strong>
		</li></ol><div style="text-align: center"><table style="border-collapse:collapse" border="0"><colgroup><col style="width:623px"/></colgroup><tbody valign="top"><tr><td style="padding-left: 7px; padding-right: 7px; border-top:  solid 0.5pt; border-left:  solid 0.5pt; border-bottom:  solid 0.5pt; border-right:  solid 0.5pt"><p>data.set &lt;- data.frame(installed.packages())
</p><p>maml.mapOutputPort("<span style="color:#a50021">data.set</span>")</p></td></tr></tbody></table></div><p>
 </p><p>TODO: In our upcoming post, we will mention about installing and running custom R packages. Developing own R learning model and using it in a native AML experiment.
</p>]]></content:encoded>
    </item>
    <item>
      <title>ML 02 - More on Machine Learning and Azure Machine Learning Service</title>
      <link>https://docs.microsoft.com/archive/blogs/mustafakasap/ml-02-more-on-machine-learning-and-azure-machine-learning-service</link>
      <pubDate>Mon, 28 Dec 2015 10:06:00 GMT</pubDate>
      <dc:creator><![CDATA[Mustafa Kasap]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/mustafakasap/2015/12/28/ml-02-more-on-machine-learning-and-azure-machine-learning-service/</guid>
      <description><![CDATA[Machine learning uses computers to run predictive models that learn from existing data in order to...]]></description>
      <content:encoded><![CDATA[<p><span style="font-family: Times New Roman; font-size: 12pt;">Machine learning uses computers to run predictive models that learn from existing data in order to forecast future behaviors, outcomes, and trends. <a href="https://azure.microsoft.com/en-us/documentation/articles/machine-learning-what-is-machine-learning">Azure Machine Learning</a> (AML) is a powerful cloud-based predictive analytics service that makes it possible to quickly create and deploy predictive analytics models as analytics solutions. Predictive analytics uses various statistical techniques - in this case, machine learning - to analyze collected or current data for patterns or trends in order to forecast future events. As the name implies, Azure Machine Learning Service eliminates the infrastructure, management, software installation etc. related issues and lets the user focus on the development of his/her AML models and publish them as ready to use scalable web services. </span></p>
<p><span style="font-family: Times New Roman; font-size: 12pt;">AML service have the capability to run both custom R and Python scripts along with several preinstalled Python, <a href="https://cran.r-project.org">R software libraries</a>. With Free and Standard service tiers, it is possible to create an AML workspace and start using the service immediately. Please note that the free tier doesn't cover <a href="https://azure.microsoft.com/en-us/pricing/details/machine-learning/https:/azure.microsoft.com/en-us/pricing/details/machine-learning/">all available features</a> and designed for developers to have them general overview about the service. To start using any tier of this service you need a Microsoft account and then following the <a href="https://studio.azureml.net/Home">https://studio.azureml.net/Home</a> address you can activate your free subscription. For testing the whole AML features, you need a <a href="https://azure.microsoft.com/en-us/pricing/free-trial/">Microsoft Azure account</a>. </span></p>
<p><span style="font-family: Times New Roman; font-size: 12pt;"><strong>Machine Learning Studio </strong> </span></p>
<p><span style="font-family: Times New Roman; font-size: 12pt;">Machine Learning Studio (MLS) is a browser-based tool used to develop predictive models by dragging, dropping, and connecting predefined or custom modules / scripts. Once you created a free AML service account you can start using MLS directly from <a href="https://studio.azureml.net">https://studio.azureml.net</a>. Or If you have an Azure subscription, want to test the full features of AML, then you first create an Azure Storage where you will store your AML data, custom scripts, saved models etc. and a machine learning workspace that will be a base to the MLS for developing your custom solutions. </span></p>
<p><span style="font-family: Times New Roman; font-size: 12pt;">Follow the below pictorial guide to create an AML workspace. As highlighted on the image, you can select any existing azure storage account from the listbox. Your custom data uploaded to be used in experiments, the experiment results, python notebooks etc. all will be stored in this storage area. </span></p>
<p style="text-align: center;"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/6012.100915_2000_MoreonMachi1.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/6012.100915_5F00_2000_5F00_MoreonMachi1.png" alt="" /></p>
<p><span style="font-family: Times New Roman; font-size: 12pt;">Once you have created an ML workspace, you can access the <a href="https://azure.microsoft.com/en-us/documentation/articles/machine-learning-what-is-ml-studio/">Machine Learning Studio</a> web page, browser based tool for creating predictive analytics models. </span></p>
<p style="text-align: center;"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/4477.100915_2000_MoreonMachi2.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/4477.100915_5F00_2000_5F00_MoreonMachi2.png" alt="" /></p>
<p>&nbsp; &nbsp;</p>
<p><span style="font-family: Times New Roman; font-size: 12pt;">Below image is a screenshot of the landing page of <a href="https://studio.azureml.net/">AML studio</a>. Description of the numerated regions are as: </span></p>
<p style="text-align: center;"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/0268.100915_2000_MoreonMachi3.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/0268.100915_5F00_2000_5F00_MoreonMachi3.png" alt="" /></p>
<ol>
<li>Tabs that you can access your experiments, published web services, Python notebooks, your and third-party dataset, ready to use trained models and settings like user authorization to your AML Studio.</li>
<li>List all the saved experiments of your own.</li>
<li>Sample ML solutions developed by Microsoft for your reference.</li>
<li>List of filtered solutions.</li>
<li>Third party ML solutions developed and published by AML users.</li>
<li>Copy selected solution from one of your workspace to another.</li>
<li>Preview of the selected solution diagram.</li>
<li>List of workspaces that you are authorized to access. Can switch to any other workspace from this menu.</li>
</ol>
<p><span style="font-family: Times New Roman; font-size: 12pt;">For creating a new experiment, click on the Experiments tab and then click on the button named NEW on the bottom left corner of the window. If you haven't done yet, you should definitely click on the "Experiment Tutorial" tile to see step by step animated tutorial about creating a new experiment. </span></p>
<p style="text-align: center;"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/4382.100915_2000_MoreonMachi4.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/4382.100915_5F00_2000_5F00_MoreonMachi4.png" alt="" /></p>
<p style="text-align: center;">&nbsp; &nbsp;</p>
<p><span style="font-family: Times New Roman; font-size: 12pt;">If you already experienced the "experiment tutorial" then click on the "Blank Experiment" to create a new experiment that we will be using to show some of the AML features on it. </span></p>
<p><span style="font-family: Times New Roman; font-size: 12pt;">In the future ML posts we will be creating new AML experiments based on this guide. </span></p>]]></content:encoded>
    </item>
    <item>
      <title>Azure WebJobs &amp; JobHostConfiguration</title>
      <link>https://docs.microsoft.com/archive/blogs/mustafakasap/azure-webjobs-jobhostconfiguration</link>
      <pubDate>Sat, 26 Dec 2015 14:09:46 GMT</pubDate>
      <dc:creator><![CDATA[Mustafa Kasap]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/mustafakasap/2015/12/26/azure-webjobs-jobhostconfiguration/</guid>
      <description><![CDATA[In the previous post we experienced:
Messages in the queue seems not to be processed in the same...]]></description>
      <content:encoded><![CDATA[<p>In the <a href="http://blogs.msdn.com/b/mustafakasap/archive/2015/12/26/azure-webjobs-with-storage-queue-and-exceptions.aspx">previous post</a> we experienced:
</p><ul><li>Messages in the queue seems not to be processed in the same order they are placed in the queue. Check Step20 in the prev. post. Message 3 seems to be  processed after message 4 and 5.
</li><li>When a message arrived to the queue, it is not triggering WebJob method immediately. It is processed after few seconds (check step 14 in the prev. post)
</li><li>When you have several messages waiting in the queue, some of them processed concurrently. 
</li><li>After 5<sup>th</sup> unsuccessful message processing attempt, it is moved into another queue called Poison.
</li></ul><p>Is there a way to control this behavior? Yes. Just add the following lines into your WebJob's Main method and update the values as desired.
</p><p><span style="color:black; font-family:Consolas; font-size:9pt; background-color:white">
			<span style="color:blue">static<span style="color:black">
					<span style="color:blue">void<span style="color:black"> Main()
</span></span></span></span></span></p><p><span style="color:black; font-family:Consolas; font-size:9pt; background-color:white">        {
</span></p><p style="margin-left: 72pt"><span style="color:black; font-family:Consolas; font-size:9pt; background-color:white">
			<span style="color:#2b91af">JobHostConfiguration<span style="color:black"> config = <span style="color:blue">new<span style="color:black">
							<span style="color:#2b91af">JobHostConfiguration<span style="color:black">();
</span></span></span></span></span></span></span></p><p style="margin-left: 72pt"><span style="color:black; font-family:Consolas; font-size:9pt; background-color:white">  config.Queues.BatchSize = 8;
</span></p><p style="margin-left: 72pt"><span style="color:black; font-family:Consolas; font-size:9pt; background-color:white">  config.Queues.MaxDequeueCount = 4;
</span></p><p style="margin-left: 72pt"><span style="color:black; font-family:Consolas; font-size:9pt; background-color:white">  config.Queues.MaxPollingInterval = <span style="color:#2b91af">TimeSpan<span style="color:black">.FromSeconds(15);
</span></span></span></p><p style="margin-left: 72pt">
 </p><p style="margin-left: 72pt"><span style="color:black; font-family:Consolas; font-size:9pt"><span style="background-color:white">
				<span style="color:blue">var<span style="color:black"> host = <span style="color:blue">new<span style="color:black">
								<span style="color:#2b91af">JobHost<span style="color:black">(</span></span></span></span></span></span></span>config<span style="background-color:white">);
</span></span></p><p style="margin-left: 72pt"><span style="color:black; font-family:Consolas; font-size:9pt; background-color:white">
			<span style="color:green">// The following code ensures that the WebJob will be running continuously<span style="color:black">
				</span></span></span></p><p style="margin-left: 72pt"><span style="color:black; font-family:Consolas; font-size:9pt; background-color:white">  host.RunAndBlock();
</span></p><p><span style="color:black; font-family:Consolas; font-size:9pt; background-color:white">        }
</span></p><p>
 </p><p><span style="color:black; font-family:Consolas; font-size:9pt; background-color:white">In the above code, lines 5-7 are the default code generated by VisualStudio. We added lines 1-4 and here is their description.
</span></p><p>
 </p><p><span style="color:black; font-family:Consolas; font-size:9pt; background-color:white"><strong>BatchSize</strong>: This parameter defines the number of messages to be processed concurrently. If you set it to 1 in the previous blog post scenario, you will see that the messages in the queue will be processed one by one in the queue order. If you have powerful WebApp instance in Azure, you can increase this number to process multiple messages at the same time without so much performance drop in your WebApp.
</span></p><p>
 </p><p><span style="color:black; font-family:Consolas; font-size:9pt"><strong>MaxDequeueCount</strong>: In the prev. blog post step 20, we saw that after 5<sup>th</sup> unsuccessful message processing attempt, message is moved into Poison queue. This parameter sets how many trials needed before putting a message into Poison queue. Important: Unless there exist other messages waiting in the queue that are not in concurrent processing stage, there is no time interval between trials! So if there exists enough resources, retry occurs immediately. In your case, if you need other processes to be completed before the next trial, just use thread.Sleep inside the trigger method.
</span></p><p>
 </p><p><span style="color:black; font-family:Consolas; font-size:9pt"><strong>MaxPollingInterval</strong>: In the prev. blog post step 14, we observed that the message arrived to the queue are not processed immediately. Because WebJob checks the queue every MaxPollingInterval time span to see if there is a new message arrived. You can adjust this frequency by MaxPollingInterval parameter.
</span></p><p>
 </p>]]></content:encoded>
    </item>
    <item>
      <title>Azure WebJobs with Storage Queue and Exceptions</title>
      <link>https://docs.microsoft.com/archive/blogs/mustafakasap/azure-webjobs-with-storage-queue-and-exceptions</link>
      <pubDate>Sat, 26 Dec 2015 13:20:00 GMT</pubDate>
      <dc:creator><![CDATA[Mustafa Kasap]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/mustafakasap/2015/12/26/azure-webjobs-with-storage-queue-and-exceptions/</guid>
      <description><![CDATA[Azure WebJobs are like console applications running in the same host environment with the Azure...]]></description>
      <content:encoded><![CDATA[<p>Azure <a href="https://azure.microsoft.com/en-us/documentation/articles/websites-dotnet-webjobs-sdk-storage-queues-how-to/">WebJobs</a> are like console applications running in the same host environment with the Azure WebApplications.  You can trigger a console application method when there is a Queue message in Azure queue. In this post we will simply demonstrate how to handle a new queue message with a WebJob and mention about the result of an exception in the Queue message trigger in the WebJob.
</p><p>Briefly if WebJob method triggered by a queue message, the message is processed by that method successfully and the message automatically removed from the queue. IF there will be an exception occurred during the processing of the message, then WebJob will retry several times, and after some unsuccessful retrial, the message is moved to Poison queue. Below we will showcase this scenario.
</p><p>
 </p><p style="margin-left: 18pt">1. Create a new azure WebJob project
</p><p><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/7103.122715_0206_AzureWebJob1.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/7103.122715_5F00_0206_5F00_AzureWebJob1.png" alt=""/>
	</p><p>2. Create a new storage account to create a test scenario.
</p><p style="margin-left: 18pt"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/8182.122715_0206_AzureWebJob2.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/8182.122715_5F00_0206_5F00_AzureWebJob2.png" alt=""/>
	</p><p style="margin-left: 18pt">3. Give a name (i.e. "testscenario") and set parameters of the new storage account to be created. 
</p><p><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/0753.122715_0206_AzureWebJob3.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/0753.122715_5F00_0206_5F00_AzureWebJob3.png" alt=""/>    
</p><p style="margin-left: 18pt">4. Copy the storage connection string. (PS: I have deleted this account/password before the blog post) 
</p><p style="margin-left: 36pt"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/7522.122715_0206_AzureWebJob4.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/7522.122715_5F00_0206_5F00_AzureWebJob4.png" alt=""/>
	</p><p style="margin-left: 36pt">
 </p><p style="margin-left: 18pt">5. Open App.Config file from project explorer and paste the connection string into the corresponding fields.
</p><p style="margin-left: 36pt"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/4073.122715_0206_AzureWebJob5.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/4073.122715_5F00_0206_5F00_AzureWebJob5.png" alt=""/>
	</p><p style="margin-left: 36pt">
 </p><p style="margin-left: 18pt">6. In the server explorer window, right click on the "testscenario-&gt;Queues" item and select "Create queue". Give a name "queue" to the new queue service. (It must be same as the name given in function.cs file)
</p><p style="margin-left: 36pt"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/7853.122715_0206_AzureWebJob6.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/7853.122715_5F00_0206_5F00_AzureWebJob6.png" alt=""/>
	</p><p style="margin-left: 36pt">
 </p><p style="margin-left: 18pt">7. In a new window it will ask you storage account key. Paste just the accountKey value that you can find either in the properties window of the storage account or inside the connectionstring that you paste into App.Config file.
</p><p><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/8524.122715_0206_AzureWebJob7.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/8524.122715_5F00_0206_5F00_AzureWebJob7.png" alt=""/>
	</p><p style="margin-left: 18pt">8. Now when you double click on your newly created queue service name, management window will open. In this window you can see existing messages waiting in the queue, add new message to the queue etc.
</p><p style="margin-left: 36pt"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/3326.122715_0206_AzureWebJob8.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/3326.122715_5F00_0206_5F00_AzureWebJob8.png" alt=""/>
	</p><p style="margin-left: 36pt">
 </p><p style="margin-left: 18pt">9. Now without making any changes (except the ones that we made in App.Config file), start the WebJob application in Debug mode locally.
</p><p style="margin-left: 36pt"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/4807.122715_0206_AzureWebJob9.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/4807.122715_5F00_0206_5F00_AzureWebJob9.png" alt=""/>
	</p><p style="margin-left: 18pt">10. Console window will open and waits a new message to arrive to the queue. Once a new queue message arrives, it will process it and finish its job (check Function.cs file)
</p><p style="margin-left: 36pt"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/6076.122715_0206_AzureWebJob10.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/6076.122715_5F00_0206_5F00_AzureWebJob10.png" alt=""/>
	</p><p style="margin-left: 36pt">
 </p><p style="margin-left: 18pt">11. Screenshot of the console application waiting for a new queue message.
</p><p><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/5808.122715_0206_AzureWebJob11.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/5808.122715_5F00_0206_5F00_AzureWebJob11.png" alt=""/>
	</p><p>
 </p><p style="margin-left: 18pt">12. Now open the queue management window and add a new test message to the queue manually.
</p><p><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/2768.122715_0206_AzureWebJob12.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/2768.122715_5F00_0206_5F00_AzureWebJob12.png" alt=""/>
	</p><p style="margin-left: 36pt">
 </p><p style="margin-left: 18pt">13. When you added a new message, you can see the message on the queue management window.
</p><p><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/6153.122715_0206_AzureWebJob13.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/6153.122715_5F00_0206_5F00_AzureWebJob13.png" alt=""/>
	</p><p>
 </p><p style="margin-left: 18pt">14. Few seconds (1, 5, 10… will mention more on the next post) after adding the new queue message, WebJob will receive it and process it. In the console window you can see the information message telling that a message caught.
</p><p style="margin-left: 36pt"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/4010.122715_0206_AzureWebJob14.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/4010.122715_5F00_0206_5F00_AzureWebJob14.png" alt=""/>
	</p><p style="margin-left: 36pt">
 </p><p style="margin-left: 18pt">15. Press the Refresh button on the Queue management window. You will see that the processed message become invisible, deleted from the queue automatically after got processed.
</p><p style="margin-left: 36pt"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/7462.122715_0206_AzureWebJob15.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/7462.122715_5F00_0206_5F00_AzureWebJob15.png" alt=""/>
	</p><p style="margin-left: 36pt">
 </p><p style="margin-left: 18pt">16. Now for testing our scenario, add the following lines of code by updating function.cs file. This code will print out the received message content in the console window (or in the WebJob output window on Azure management portal) and If the content of the message contains "Hello" than it will throw an exception.
</p><p><span style="color:black; font-family:Consolas; font-size:7pt; background-color:white">
			<span style="color:blue">public<span style="color:black">
					<span style="color:blue">static<span style="color:black">
							<span style="color:blue">void<span style="color:black"> ProcessQueueMessage([<span style="color:#2b91af">QueueTrigger<span style="color:black">(<span style="color:#a31515">"queue"<span style="color:black">)] <span style="color:blue">string<span style="color:black"> message, <span style="color:#2b91af">TextWriter<span style="color:black"> log)
</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></p><p><span style="color:black; font-family:Consolas; font-size:7pt; background-color:white">        {
</span></p><p><span style="color:black; font-family:Consolas; font-size:7pt; background-color:white">            log.WriteLine(message);
</span></p><p>
 </p><p><span style="color:black; font-family:Consolas; font-size:7pt; background-color:white">
			<span style="color:#2b91af">Console<span style="color:black">.WriteLine(<span style="color:#a31515">"Received message: {0}"<span style="color:black">, message);
</span></span></span></span></span></p><p><span style="color:black; font-family:Consolas"><span style="font-size:4pt; background-color:white">                     </span><span style="color:blue"><span style="font-size:7pt; background-color:white">if<span style="color:black"> (message.Contains(<span style="color:#a31515">"Hello"<span style="color:black">))</span></span></span></span><span style="font-size:4pt; background-color:white">
				</span></span></span></p><p><span style="color:black; font-family:Consolas; font-size:7pt; background-color:white">
			<span style="color:blue">throw<span style="color:black">
					<span style="color:blue">new<span style="color:black">
							<span style="color:#2b91af">Exception<span style="color:black">();
</span></span></span></span></span></span></span></p><p><span style="color:black; font-family:Consolas; font-size:7pt"><span style="background-color:white">        }</span>
		</span></p><p>
 </p><p style="margin-left: 18pt">17. Before starting the WebJob application (or if it is running, then close it) lets add some messages to the queue. In the below example the third of four message that is added to the queue has the content "Hello". 
</p><p style="margin-left: 36pt"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/5736.122715_0206_AzureWebJob16.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/5736.122715_5F00_0206_5F00_AzureWebJob16.png" alt=""/>
	</p><p style="margin-left: 36pt">
 </p><p style="margin-left: 18pt">18. Now start the WebJob in Release mode (if in Debug mode, every time the exception occurs the execution breaks. You need to press continue button in the debug window each time. So we continue our scenario in Release mode) and wait messages to be processed.
</p><p style="margin-left: 36pt"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/7077.122715_0206_AzureWebJob17.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/7077.122715_5F00_0206_5F00_AzureWebJob17.png" alt=""/>
	</p><p>
 </p><p style="margin-left: 18pt">19. When you press Start button in Release mode, there will be a warning message, press "Continue Debugging". By this way our application will run without any break in an exception case.
</p><p style="margin-left: 36pt"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/5342.122715_0206_AzureWebJob18.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/5342.122715_5F00_0206_5F00_AzureWebJob18.png" alt=""/>
	</p><p>
 </p><p style="margin-left: 18pt">20. In the console window, we will see that all messages are processed. Messages with the content "Hello" are re-processed 5 times and after unsuccessful 5<sup>th</sup> processing attempt, they are moved into Poison Queue.
</p><p><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/7827.122715_0206_AzureWebJob19.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/7827.122715_5F00_0206_5F00_AzureWebJob19.png" alt=""/>
	</p><p style="margin-left: 18pt">21. If you open the "Server Explorer" and refresh the Storage Queue node by right click and then Refresh command, you will see the newly created "Queue-Poison" named queue. Inside this queue you can find the messages that are not successfully processed after 5<sup>th</sup> processing attempt.
</p><p><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/8407.122715_0206_AzureWebJob20.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/8407.122715_5F00_0206_5F00_AzureWebJob20.png" alt=""/>
	</p><p>
 </p><p>For more details on retrial counts, concurrent queue message processing etc. please refer  <a href="http://blogs.msdn.com/b/mustafakasap/archive/2015/12/26/azure-webjobs-amp-jobhostconfiguration.aspx">http://blogs.msdn.com/b/mustafakasap/archive/2015/12/26/azure-webjobs-amp-jobhostconfiguration.aspx</a>
	</p><p>
 </p>]]></content:encoded>
    </item>
    <item>
      <title>ML 01 - Machine Learning and R</title>
      <link>https://docs.microsoft.com/archive/blogs/mustafakasap/ml-01-machine-learning-and-r</link>
      <pubDate>Mon, 26 Oct 2015 19:33:00 GMT</pubDate>
      <dc:creator><![CDATA[Mustafa Kasap]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/mustafakasap/2015/10/26/ml-01-machine-learning-and-r/</guid>
      <description><![CDATA[In this post I will mention about Machine Learning and its practical and theoretical usage samples...]]></description>
      <content:encoded><![CDATA[<p><span style="font-size: 12pt;">In this post I will mention about Machine Learning and its practical and theoretical usage samples around Open Source Software and Microsoft technologies. Machine learning is programming computers to optimize a performance criterion using example data or past experience </span><span style="font-size: 10pt;">(1)</span><span style="font-size: 12pt;">. In another words making computers more intelligent, making them have insights, giving them the ability to predict the missing data in the whole. To succeed these goals or more, you need data. More data you have, more precise decisions, forecasts, intelligence capability the computer will have. Here not only the amount of data is important, but also the quality and content of the data is also important. </span></p>
<p><span style="font-size: 12pt;">Imagine you want to make weather forecast and based on previous data (data that you have) you want to predict tomorrows weather status. If you have just few data samples from the past and all these samples are collected during the winter time, then you may not predict tomorrow's data precisely. You need data covering not only winter time period but all days, seasons of the year. On the other hand, if you have data with whole coverage of the seasons but only previous year's daily data, it may also not be enough for precise weather forecast because you need more historical data. You need not only last year data but may need years of past data. Also for better prediction not only the comprehensive past weather data may be enough but also you may need additional data, parameters such as air pollution data per region, moisture, soil humidity etc. </span></p>
<p><span style="font-size: 12pt;">to summarize, you may need: </span></p>
<ul>
<li><span style="font-size: 12pt;">Massive amount of past data (not only previous few days or years). </span></li>
<li><span style="font-size: 12pt;">Comprehensive data. (data homogeneously distributed over cyclic time period, not only from specific session but from all sessions). </span></li>
<li><span style="font-size: 12pt;">Additional parameters/data that affects the data value to be predicted (not only temperature but humidity data etc.). </span></li>
</ul>
<p><span style="font-size: 12pt;">In almost every programming language you can develop programs with machine learning algorithms but there is a dedicated programming language and environment for this purpose called R. R is a language for statistical computing and graphics. You can get the free open source development environment and libraries from <a href="https://www.r-project.org"><span style="color: #0563c1; text-decoration: underline;">https://www.r-project.org</span></a>. Moreover, a free IDE with GUI can be found at <a href="https://www.rstudio.com"><span style="color: #0563c1; text-decoration: underline;">https://www.rstudio.com</span></a>. There also exist hundreds of open source algorithms, software libraries under <a href="https://cran.r-project.org"><span style="color: #0563c1; text-decoration: underline;">https://cran.r-project.org</span></a>. In the next series of this post, we will mention about <a href="https://azure.microsoft.com/en-us/services/machine-learning/"><span style="color: #0563c1; text-decoration: underline;">Microsoft Azure Machine Learning service</span></a> which is running custom R, Python scripts together with pre-installed CRAN libraries. </span></p>
<p><span style="font-size: 12pt;">Let's start working on a sample project where we will make data prediction based on existing dataset, set of data samples gathered from observations, either by manual processing or from sensor like devices. Assuming you have Microsoft Excel or similar tool; create two columns <strong>X</strong> and <strong>Y</strong>, and 30 rows with header and data values from 1 to 29. Here there is no specific reason of selecting 1 to 29 range, it might be 1 to 100 or -50 to -15 whatever you prefer. Below image is the plot of these X, Y data pairs on an Excel chart. </span></p>
<p style="text-align: center;"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/1780.102715_0233_01MachineLe1.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/1780.102715_5F00_0233_5F00_01MachineLe1.png" alt="" /></p>
<p><span style="font-size: 12pt;">It is very intuitive that for any X value, the corresponding Y value is same as the X. Here the Y values are labels that corresponds to X values; which means you know the label of a specific X value. Now create a new column named <strong>YNoise</strong> where you will create 29 random numbers each range between -1 to 1. You can use <strong>"=IF(RANDBETWEEN(0,1), -1 * RAND(), RAND())"</strong> or a better function to generate these random values. Finally create two new more columns named <strong>X</strong> and <strong>YwNoise, </strong>copy original <strong>X</strong> values to the new <strong>X</strong> column and then take the sum of original <strong>Y</strong> and <strong>YNoise</strong> columns and put the result in new <strong>YwNoise</strong> column. Plot the resulting values on a new chart. </span></p>
<p style="text-align: center;"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/1373.102715_0233_01MachineLe2.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/1373.102715_5F00_0233_5F00_01MachineLe2.png" alt="" /></p>
<p><span style="font-size: 12pt;">Assume the original dataset (without noise) is the ideal set that we are trying to model, predict. In real world scenario, you don't have any clue about this ideal dataset and with ML techniques you attempt to find the best model that mimics the ideal dataset. For the sake of this example we provide a portion of this ideal dataset together with its formulation which is <strong>X = Y</strong>. Based on this formula if we take X = 100, which is not in our existing dataset (we have X values that range from 1 to 29, not 100), we can directly say that the corresponding Y value is 100. Because we know the formula, we can predict the corresponding value of any X. </span></p>
<p><span style="font-size: 12pt;">In real life, most of the time you don't have ideal data. Your labels (in above sample Y values) are affected from various, mostly unpredicted, dynamic parameters / noise. To simulate this dynamic parameters, that's is the reason we add random noise to the ideal dataset. With this noisy dataset (<strong>X</strong> and <strong>YwNoise</strong>), it is not that easy to find the formulation or relation between these two columns (especially in the case of a more complex and in big data). When we plot this noisy dataset on to chart, it is intuitive that there is a <strong>linear relation</strong> with X and Y values. Using <a href="https://en.wikipedia.org/wiki/Linear_regression"><span style="color: #0563c1; text-decoration: underline;">Linear Regression</span></a> method, if we fit (best fit) a line on the noisy dataset, we can get the formula of this line (something like <strong>y = mx+b</strong>, for this specific example <strong>m = 1</strong> and <strong>b = 0</strong>) and using this formula, we can predict corresponding Y value of any other X value which is not in our existing dataset. </span></p>
<p>&nbsp;</p>
<p style="text-align: center;"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/2671.102715_0233_01MachineLe3.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/2671.102715_5F00_0233_5F00_01MachineLe3.png" alt="" /></p>
<p>&nbsp;</p>
<p><span style="font-size: 12pt;">Dataset that we used is very simple and in two dimension. In real life scenario you may have more complex and multidimensional data. i.e. you may have X1, X2, X3, &hellip;XN and Y columns, where Y is the label of X1 to XN value set. Here X1 maybe price value of a car, X2 maybe engine power, X3 max speed, X4 time to reach 100 mph/sec and Y is the brand of the car. Having this car dataset, in the future you may have any X1 to X4 values and predict the possible brands of the car (Y value). </span></p>
<p><span style="font-size: 12pt;"><strong>Summary</strong>: Having a dataset where you don't have any relation information within the data, you may build a model to predict missing values of a new data sample that is not in your initial dataset. </span></p>
<p><span style="font-size: 12pt;">As mentioned earlier, size of the dataset is also important. Considering the below sample, if we have only 4 samples in our dataset then following the above procedures to find the best fit line (linear regression) and its formula over these three point is more difficult. As seen on the chart below there may be many alternative lines (L1, L2, L3) passing through these three points. And each line will take us to different formulation, so completely different result set. i.e. for <strong>x = 27</strong>, taking L1 formulation the <strong>y = 40</strong>, L2 formulation the <strong>y = 26</strong>, L3 formulation the <strong>y = 21</strong>. </span></p>
<p style="text-align: center;"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/8055.102715_0233_01MachineLe4.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/8055.102715_5F00_0233_5F00_01MachineLe4.png" alt="" /></p>
<p style="text-align: justify;"><span style="font-size: 12pt;">Below is another sample but with larger size of dataset. There are 30 points but if we look at this data cluster, which is cumulated in a specific region, from a larger scale, again we may draw more than one line fitting on the dataset. In closer scale, it seems that there is no big difference but from a larger scale, again the result will be very different among the lines that we fit on the dataset. </span></p>
<p style="text-align: center;"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/2210.102715_0233_01MachineLe5.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/2210.102715_5F00_0233_5F00_01MachineLe5.png" alt="" /></p>
<p><span style="font-size: 12pt;"><strong>Linear or Non-Linear </strong></span></p>
<p><span style="font-size: 12pt;">In the next sections we will go in detail about using the right model, algorithm in our ML solution. For now, we will try to keep the simplicity and mention about the basics. For the sample dataset case that is mentioned earlier, we used linear regression method. Without having knowledge about the ideal dataset, intuitively we decided about linear method. What if we have a dataset in larger scale that spread on different clusters and not linear? Take a look at the below chart: </span></p>
<p style="text-align: center;"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/8561.102715_0233_01MachineLe6.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/8561.102715_5F00_0233_5F00_01MachineLe6.png" alt="" /></p>
<p>&nbsp;</p>
<p><span style="font-size: 12pt;">For the above dataset, linear regression is not the best model. Still we can find best fitting line that passes from these two cluster but it will not give precise results about finding the missing values. Using non-linear models will give more precise results, i.e. fitting 3<sup>rd</sup> degree cubic polynomial <img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/0640.102715_0233_01MachineLe7.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/0640.102715_5F00_0233_5F00_01MachineLe7.png" alt="" /> may be the right decision. Below image represents the 3<sup>rd</sup> degree polynomial fitted on our dataset. </span></p>
<p style="text-align: center;"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/4452.102715_0233_01MachineLe8.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/4452.102715_5F00_0233_5F00_01MachineLe8.png" alt="" /></p>
<p><span style="font-size: 12pt;">Again we can't guarantee that the cubic polynomial is the best option. What if there were other data values in another cluster that is not on the path of the curve? Than we have to find another method. This shows us the importance of data size, quality and also the model that we are using. If we have some insights about the data that it is somehow linear, then using linear model is the best option because of its simplicity and computation resource requirements. Using more complex models for simple cases, datasets is also another option but it is waste of computation resource and time consuming approach. So it is very important to use the correct model in the right place. </span></p>
<p><span style="font-size: 12pt;">All we mentioned are about two dimensional data and not always it is possible to build a model with polynomials. Because the higher degree the polynomial more complex the computation it requires. What if we have multidimensional data? Imagine the below surface with parameters <strong>x</strong> and <strong>y</strong>, then the labels as <strong>z</strong>. </span></p>
<p style="text-align: center;"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/1541.102715_0233_01MachineLe9.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/1541.102715_5F00_0233_5F00_01MachineLe9.png" alt="" /></p>
<p><span style="font-size: 12pt;">Depending on the complexity, computation time constraint, Accuracy, computation memory constraint etc. there exist many algorithms like neural networks, decision trees and we have to find the best algorithm to build our solution. </span></p>
<p><span style="font-size: 12pt;"><strong>RStudio </strong></span></p>
<p><a href="https://www.rstudio.com"><span style="color: #0563c1; font-size: 12pt; text-decoration: underline;">RStudio</span></a><span style="font-size: 12pt;"> is one of the most commonly used Open Source IDE for developing programs in <a href="https://www.r-project.org/about.html"><span style="color: #0563c1; text-decoration: underline;">R language</span></a>. In this section we will use this tool to get a brief overview about the R language, its syntax and capabilities. You can copy/paste the below R code into a new RScript editor in RStudio and run it with CTRL+ALT+R key combination. This self-explanatory code generates a dataset, plot it on a chart and write it in a CSV file for further use. </span></p>
<p style="text-align: center; margin-left: 18pt;"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/0676.102715_0233_01MachineLe10.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/0676.102715_5F00_0233_5F00_01MachineLe10.png" alt="" /></p>
<p style="margin-left: 18pt;">&nbsp;</p>
<p style="background: whitesmoke;"><span style="color: #999988; font-family: Courier New; font-size: 10pt;"><em># Generate noisy data for supervised learning sample</em></span></p>
<p style="background: whitesmoke;"><span style="color: #999988; font-family: Courier New; font-size: 10pt;"><em># Generate dataset that ranges from -20 to 20 with step value 1</em></span></p>
<p style="background: whitesmoke;"><span style="color: black; font-family: Courier New; font-size: 10pt;">x<span style="color: #333333;"> <span style="color: #687687;">&lt;-<span style="color: #333333;"> <span style="color: black;">seq<span style="color: #687687;">(-<span style="color: #009999;">70<span style="color: #333333;">, <span style="color: #009999;">70<span style="color: #333333;">, <span style="color: #009999;">3<span style="color: #687687;">)</span></span></span></span></span></span></span></span></span></span></span></span></p>
<p style="background: whitesmoke;">&nbsp;</p>
<p style="background: whitesmoke;"><span style="color: #999988; font-family: Courier New; font-size: 10pt;"><em># Generate a point cloud around the line</em></span></p>
<p style="background: whitesmoke;"><span style="color: #999988; font-family: Courier New; font-size: 10pt;"><em># with n slope of 1 and a y-intercept of 0</em></span></p>
<p style="background: whitesmoke;"><span style="color: black; font-family: Courier New; font-size: 10pt;">noise_magnitude<span style="color: #333333;"> <span style="color: #687687;">=<span style="color: #333333;"> <span style="color: #009999;">5</span></span></span></span></span></p>
<p style="background: whitesmoke;"><span style="color: black; font-family: Courier New; font-size: 10pt;">m<span style="color: #333333;"> <span style="color: #687687;">&lt;-<span style="color: #333333;"> <span style="color: #009999;">1</span></span></span></span></span></p>
<p style="background: whitesmoke;"><span style="color: black; font-family: Courier New; font-size: 10pt;">b<span style="color: #333333;"> <span style="color: #687687;">&lt;-<span style="color: #333333;"> <span style="color: #009999;">0</span></span></span></span></span></p>
<p style="background: whitesmoke;"><span style="color: black; font-family: Courier New; font-size: 10pt;">y<span style="color: #333333;"> <span style="color: #687687;">&lt;-<span style="color: #333333;"> <span style="color: black;">m<span style="color: #333333;"> <span style="color: #687687;">*<span style="color: #333333;"> <span style="color: #687687;">(<span style="color: black;">x<span style="color: #333333;"> <span style="color: #687687;">+<span style="color: #333333;"> <span style="color: black;">noise_magnitude<span style="color: #333333;"> <span style="color: #687687;">*<span style="color: #333333;"> <span style="color: black;">rnorm<span style="color: #687687;">(<span style="color: black;">x<span style="color: #687687;">))<span style="color: #333333;"> <span style="color: #687687;">+<span style="color: #333333;"> <span style="color: black;">b<span style="color: #333333;">; </span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></p>
<p style="background: whitesmoke;">&nbsp;</p>
<p style="background: whitesmoke;"><span style="color: #999988; font-family: Courier New; font-size: 10pt;"><em># plot point cloud on a chart</em></span></p>
<p style="background: whitesmoke;"><span style="color: black; font-family: Courier New; font-size: 10pt;">plot<span style="color: #687687;">(<span style="color: black;">x<span style="color: #333333;">, <span style="color: black;">y<span style="color: #687687;">) </span></span></span></span></span></span></p>
<p style="background: whitesmoke;">&nbsp;</p>
<p style="background: whitesmoke;"><span style="color: #999988; font-family: Courier New; font-size: 10pt;"><em># combine two columns to create data grid</em></span></p>
<p style="background: whitesmoke;"><span style="color: black; font-family: Courier New; font-size: 10pt;">linoise<span style="color: #333333;"> <span style="color: #687687;">&lt;-<span style="color: #333333;"> <span style="color: black;">cbind<span style="color: #687687;">(<span style="color: black;">x<span style="color: #333333;">, <span style="color: black;">y<span style="color: #687687;">)</span></span></span></span></span></span></span></span></span></span></p>
<p style="background: whitesmoke;">&nbsp;</p>
<p style="background: whitesmoke;"><span style="color: #999988; font-family: Courier New; font-size: 10pt;"><em># write out to a CSV file</em></span></p>
<p style="background: whitesmoke;"><span style="color: black; font-family: Courier New; font-size: 10pt;">write.csv<span style="color: #687687;">(<span style="color: black;">linoise<span style="color: #333333;">, <span style="color: black;">file<span style="color: #333333;"> <span style="color: #687687;">=<span style="color: #333333;"> <span style="color: #dd1144;">"linoise.csv"<span style="color: #333333;">, <span style="color: black;">row.names<span style="color: #333333;"> <span style="color: #687687;">=<span style="color: #333333;"> <span style="color: #990073;">FALSE<span style="color: #687687;">)</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></p>
<p><span style="font-size: 12pt;">Using the dataset generated with the above R code, we will train a linear regression model by using an R function "LinearModel" with "<strong>lm</strong>" command. Next we define three new random x values which does not exist in our dataset. Here I selected 95, 51 and 33. You can pick any other number of random values that you wish. In this example try to pick numbers between -100 to 100 otherwise don't forget to update the axis limit parameters of the <strong>"plot"</strong> command in the following code. With the below code, aim is to plot our dataset on a chart, fit a line on this dataset. Predict the corresponding y values of the random x values that you picked and plot them on the chart with red color marks. </span></p>
<p style="background: whitesmoke;"><span style="color: #999988; font-family: Courier New; font-size: 10pt;"><em>#read data into variable</em></span></p>
<p style="background: whitesmoke;"><span style="color: black; font-family: Courier New; font-size: 10pt;">csvdata<span style="color: #333333;"> <span style="color: #687687;">&lt;-<span style="color: #333333;"> <span style="color: black;">read.csv<span style="color: #687687;">(<span style="color: #dd1144;">"linoise.csv"<span style="color: #687687;">)</span></span></span></span></span></span></span></span></p>
<p style="background: whitesmoke;">&nbsp;</p>
<p style="background: whitesmoke;"><span style="color: #999988; font-family: Courier New; font-size: 10pt;"><em>#create a linear model using the existing data</em></span></p>
<p style="background: whitesmoke;"><span style="color: black; font-family: Courier New; font-size: 10pt;">fit<span style="color: #333333;"> <span style="color: #687687;">&lt;-<span style="color: #333333;"> <span style="color: black;">lm<span style="color: #687687;">(<span style="color: black;">y<span style="color: #333333;"> <span style="color: #687687;">~<span style="color: #333333;"> <span style="color: black;">x<span style="color: #333333;">, <span style="color: black;">csvdata<span style="color: #687687;">)</span></span></span></span></span></span></span></span></span></span></span></span></span></span></p>
<p style="background: whitesmoke;">&nbsp;</p>
<p style="background: whitesmoke;"><span style="color: #999988; font-family: Courier New; font-size: 10pt;"><em># define one or more random X value that you </em></span></p>
<p style="background: whitesmoke;"><span style="color: #999988; font-family: Courier New; font-size: 10pt;"><em># want to find their corresponding Y labels</em></span></p>
<p style="background: whitesmoke;"><span style="color: black; font-family: Courier New; font-size: 10pt;">rnd<span style="color: #333333;"> <span style="color: #687687;">&lt;-<span style="color: #333333;"> <span style="color: black;">data.frame<span style="color: #687687;">(<span style="color: black;">x<span style="color: #333333;"> <span style="color: #687687;">=<span style="color: #333333;"> <span style="color: black;">c<span style="color: #687687;">(<span style="color: #009999;">95<span style="color: #333333;">, <span style="color: #009999;">51<span style="color: #333333;">, <span style="color: #009999;">33<span style="color: #687687;">))</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></p>
<p style="background: whitesmoke;">&nbsp;</p>
<p style="background: whitesmoke;"><span style="color: #999988; font-family: Courier New; font-size: 10pt;"><em># Using the linear model fit, predict Y values</em></span></p>
<p style="background: whitesmoke;"><span style="color: black; font-family: Courier New; font-size: 10pt;">py<span style="color: #333333;"> <span style="color: #687687;">=<span style="color: #333333;"> <span style="color: black;">predict<span style="color: #687687;">(<span style="color: black;">fit<span style="color: #333333;">, <span style="color: black;">rnd<span style="color: #687687;">)</span></span></span></span></span></span></span></span></span></span></p>
<p style="background: whitesmoke;">&nbsp;</p>
<p style="background: whitesmoke;"><span style="color: #999988; font-family: Courier New; font-size: 10pt;"><em># Plot existing data on the chart</em></span></p>
<p style="background: whitesmoke;"><span style="color: black; font-family: Courier New; font-size: 10pt;">plot<span style="color: #687687;">(<span style="color: black;">csvdata<span style="color: #687687;">$<span style="color: black;">x<span style="color: #333333;">, <span style="color: black;">csvdata<span style="color: #687687;">$<span style="color: black;">y<span style="color: #333333;">, <span style="color: black;">xlim<span style="color: #687687;">=<span style="color: black;">c<span style="color: #687687;">(-<span style="color: #009999;">100<span style="color: #333333;">, <span style="color: #009999;">100<span style="color: #687687;">)<span style="color: #333333;">, <span style="color: black;">ylim<span style="color: #687687;">=<span style="color: black;">c<span style="color: #687687;">(-<span style="color: #009999;">100<span style="color: #333333;">, <span style="color: #009999;">100<span style="color: #687687;">)<span style="color: #333333;">, <span style="color: black;">xlab<span style="color: #333333;"> <span style="color: #687687;">=<span style="color: #333333;"> <span style="color: #990073;">NA<span style="color: #333333;">, <span style="color: black;">ylab<span style="color: #333333;"> <span style="color: #687687;">=<span style="color: #333333;"> <span style="color: #990073;">NA<span style="color: #687687;">)</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></p>
<p style="background: whitesmoke;"><span style="color: #999988; font-family: Courier New; font-size: 10pt;"><em># find and plot best fit line on the point data</em></span></p>
<p style="background: whitesmoke;"><span style="color: black; font-family: Courier New; font-size: 10pt;">abline<span style="color: #687687;">(<span style="color: black;">fit<span style="color: #687687;">)</span></span></span></span></p>
<p style="background: whitesmoke;">&nbsp;</p>
<p style="background: whitesmoke;"><span style="color: #999988; font-family: Courier New; font-size: 10pt;"><em># plot the 3 randon points and their calculated labels as RED dots on the same chart</em></span></p>
<p style="background: whitesmoke;"><span style="color: black; font-family: Courier New; font-size: 10pt;">par<span style="color: #687687;">(<span style="color: black;">new<span style="color: #333333;"> <span style="color: #687687;">=<span style="color: #333333;"> <span style="color: #990073;">T<span style="color: #687687;">)<span style="color: #333333;"> <span style="color: #999988;"><em># draw on existing chart</em></span></span></span></span></span></span></span></span></span></span></p>
<p style="background: whitesmoke;"><span style="color: black; font-family: Courier New; font-size: 10pt;">plot<span style="color: #687687;">(<span style="color: black;">rnd<span style="color: #687687;">$<span style="color: black;">x<span style="color: #333333;">, <span style="color: black;">py<span style="color: #333333;">, <span style="color: black;">pch<span style="color: #687687;">=<span style="color: #009999;">19<span style="color: #333333;">, <span style="color: black;">col<span style="color: #687687;">=<span style="color: #dd1144;">"red"<span style="color: #333333;">, <span style="color: black;">xlim<span style="color: #687687;">=<span style="color: black;">c<span style="color: #687687;">(-<span style="color: #009999;">100<span style="color: #333333;">, <span style="color: #009999;">100<span style="color: #687687;">)<span style="color: #333333;">, <span style="color: black;">ylim<span style="color: #687687;">=<span style="color: black;">c<span style="color: #687687;">(-<span style="color: #009999;">100<span style="color: #333333;">, <span style="color: #009999;">100<span style="color: #687687;">)<span style="color: #333333;">, <span style="color: black;">xlab<span style="color: #333333;"> <span style="color: #687687;">=<span style="color: #333333;"> <span style="color: #990073;">NA<span style="color: #333333;">, <span style="color: black;">ylab<span style="color: #333333;"> <span style="color: #687687;">=<span style="color: #333333;"> <span style="color: #990073;">NA<span style="color: #687687;">)</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></p>
<p><span style="font-size: 12pt;">Executing the above code will result in the following chart. It is clear that the linear model that we constructed is working as expected because plot of the randomly picked 3 <strong>x</strong> values and their corresponding y values lies exactly on the line. </span></p>
<p><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/2555.102715_0233_01MachineLe11.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/2555.102715_5F00_0233_5F00_01MachineLe11.png" alt="" /></p>
<p style="margin-left: 18pt;"><span style="font-size: 12pt;">To conclude, along with the practical ML definition, we have demonstrated a simple ML sample scenario with a simple code written in R language. </span></p>
<p style="margin-left: 18pt;">&nbsp;</p>
<p style="margin-left: 18pt;"><span style="font-size: 12pt;">I would love to hear what you think about ML. Please leave your thoughts and questions in the comments box below.</span></p>
<p style="margin-left: 18pt;">&nbsp;</p>
<ol>
<li><a href="https://mitpress.mit.edu/books/introduction-machine-learning-0"><span style="color: #0563c1; font-size: 12pt; text-decoration: underline;">Introduction to Machine Learning, Ethem Alpaydin</span></a></li>
</ol>]]></content:encoded>
    </item>
    <item>
      <title>Nesnelerin interneti (IoT) ve Microsoft Azure - 1</title>
      <link>https://docs.microsoft.com/archive/blogs/mustafakasap/nesnelerin-interneti-iot-ve-microsoft-azure-1</link>
      <pubDate>Thu, 09 Oct 2014 14:00:00 GMT</pubDate>
      <dc:creator><![CDATA[Mustafa Kasap]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/mustafakasap/2014/10/09/nesnelerin-interneti-iot-ve-microsoft-azure-1/</guid>
      <description><![CDATA[Microsoft&rsquo;un bulut işletim sistemi merkezinde yer alan nesnelerin İnternet&rsquo;i (IoT) ile...]]></description>
      <content:encoded><![CDATA[<p>Microsoft&rsquo;un <a href="http://www.microsoft.com/en-us/server-cloud/cloud-os/">bulut işletim sistemi</a> merkezinde yer alan nesnelerin İnternet&rsquo;i (IoT) ile ilgili olarak bir&ccedil;ok yeni &uuml;r&uuml;n ve ara&ccedil; hakkında bilgiler paylaşılmaya başlandı (bkz. <a href="http://www.microsoft.com/windowsembedded/en-us/intelligent-systems-service.aspx">Microsoft Intelligent System Services</a>). Ericson, Cisco ve bazı diğer firmalar 2020 yılında 50 milyar ve &uuml;zeri birbirine bağlı cihaz olacağını &ouml;ng&ouml;r&uuml;rken, Morgan Stanley bu rakamın 75 Milyar, IDC ise 2020 yılı sonunda bu rakamın 212 Milyar olacağını &ouml;ng&ouml;r&uuml;yor. &Ccedil;ok yakın gelecekte ger&ccedil;ekleşecek olan b&ouml;ylesine &ouml;nemli bir değişime hazır mıyız? Sizlere nesnelerin İnternet&rsquo;i, kısaca IoT konusunda Microsoft&rsquo;un &ccedil;&ouml;z&uuml;mlerini &ouml;rnekleri ile bu yazımda ve dizinin IoT konulu sonraki yazılarında sıra ile bahsetmeye &ccedil;alışacağım.</p>
<p>Sens&ouml;rler (duyargalar bkz. <a href="http://www.tdk.gov.tr/">www.tdk.gov.tr</a>) teknolojideki gelişmeler ile &ccedil;ok daha d&uuml;ş&uuml;k maliyete &uuml;retilebilmekte. &Ouml;rneğin Texas Instruments&rsquo;ın &uuml;zerinde 6 duyarga (sıcaklık, nem, basın&ccedil;, ivme, jiroskop ve manyetometre), kontrol &uuml;nitesi ve bluetooth low energy veya bluetooth 4.0, kısaca BLE vericisi olan CR2032 saat pili ile uzun yıllar &ccedil;alışabilen <a href="http://www.ti.com/ww/en/wireless_connectivity/sensortag/index.shtml">SensorTag</a> &uuml;r&uuml;n&uuml;n&uuml; 25$&rsquo;a satın alınabilmekte. Bu duyargalardan bir veya birka&ccedil;ı bilgisayar oyunlarından, ev otomasyonuna kadar g&uuml;nl&uuml;k hayatın bir&ccedil;ok alanında kullanılmaktadır. Bulut bilişim gibi hizmetlerin sunduğu y&uuml;ksek depolama (<a href="http://azure.microsoft.com/tr-tr/documentation/services/storage/">Microsoft Azure Depolama</a>) ve hesaplama (<a href="http://azure.microsoft.com/tr-tr/documentation/services/cloud-services/">Microsoft Azure Hesaplama</a>) g&uuml;c&uuml; gibi &ouml;zellikler bu duyargalardan s&uuml;rekli olarak &ccedil;ekilecek anlık verinin arşivlenip analiz edilmesi i&ccedil;in olduk&ccedil;a ucuz ve hızlı olanaklar sunmakta, yeni ufuklar a&ccedil;maktadır.</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/4834.1.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12/4834.1.jpg"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/4834.1.jpg" original-url="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12/4834.1.jpg" alt="" width="284" height="267" border="0" /></a>&nbsp;</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/6886.2.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12/6886.2.jpg"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/6886.2.jpg" original-url="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12/6886.2.jpg" alt="" width="432" height="267" border="0" /></a>&nbsp;</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/5141.3.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12/5141.3.jpg"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/5141.3.jpg" original-url="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12/5141.3.jpg" alt="" width="653" height="264" border="0" /></a></p>
<p>SensorTag Developer Kit unboxing. (SD Kart boyut karşılaştırması i&ccedil;in eklenmiştir)</p>
<p>&nbsp;</p>
<p>Bu yazımda sizlere Microsoft Windows Phone 8.1 veya BLE destekli Windows tablet kullanarak SensorTag duyargalarından gelen veriyi toplayıp Microsoft Azure depo alanına atmaktan bahsedeceğim. Eğer sizlerde ileride yayınlayacağım IoT konularına temel oluşturacak bu uygulamayı denemek, geliştirmek isterseniz <a href="https://tisensortag.codeplex.com/">https://tisensortag.codeplex.com</a> adresinden kaynak kodlarını yayınladığım projeyi inceleyebilirsiniz. Bu kaynak kodların derlenip Windows Phone uygulama mağazasında yayınlanmış haline ise <a href="http://www.windowsphone.com/en-us/store/app/ti-sensortag/b88323c5-6e1b-4e6a-a9ae-dd2d3ba14790">bu adresten</a> ualaşabilir, bir SensorTag cihazı ile birlikte test edebilirsiniz.</p>
<p>&nbsp;</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/7142.4.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12/7142.4.jpg"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/7142.4.jpg" original-url="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12/7142.4.jpg" alt="" width="383" height="335" border="0" /></a>&nbsp;&nbsp; <a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/7674.5.jpg" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12/7674.5.jpg"><img src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/7674.5.jpg" original-url="http://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12/7674.5.jpg" alt="" width="290" height="511" border="0" /></a></p>
<p>SensorTag &uuml;zerindeki IR Thermometre ile &ccedil;ay suyu sıcaklığı ekranda.</p>
<p>&nbsp;</p>
<p>Uygulama belirlediğiniz sıklıkta (&ouml;rneğin her saniye) 6 duyargadan aldığı verileri Microsoft Azure Storage hizmeti altında Microsoft Excel tablosuna benzer bir formatta &ouml;l&ccedil;&uuml;m zamanı bilgisi ile saklamaktadır. Bir yıl boyunca her saniyede yapacağımız &ouml;l&ccedil;&uuml;m bilgisinin tamamının Microsoft Azure&rsquo;da saklanmasının maliyeti ise ~1TL dir (Farklı saklama y&ouml;ntemi, verinin arşivden okunması, farklı hizmetler kullanarak &uuml;zerinde analizler yapılmasının maliyeti ayrıdır, ilerideki yazılarımızda bu konulardan da bahsedeceğiz).</p>
<p>Peki, bir veya onlarca yıl boyunca her saniye yapılan sıcaklık, nem, basın&ccedil;, ivme ve jiroskop &ouml;l&ccedil;&uuml;m bilgisinin bizim i&ccedil;in anlamı nedir? Bu kadar &ccedil;ok bilgiyi nasıl anlamlandırabiliriz? Nasıl analiz edebiliriz? Bundan &ccedil;ok ama &ccedil;ok daha fazla miktardaki veriyi <a href="http://azure.microsoft.com/tr-tr/documentation/services/hdinsight/">Microsoft Azure HDInsight</a> hizmetini kullanarak &ccedil;ok kısa s&uuml;rede analiz edebilir, g&ouml;rsel raporlar halinde analiz sonu&ccedil;larını&nbsp;sunabiliriz.</p>
<p>&Ouml;rneğin yatağa yerleştirilecek SensorTag ile uyku kalitesini, oda iklim koşullarını zamana g&ouml;re analiz etmek, cepte taşınacak SensorTag ile zamana g&ouml;re ne kadar hareket edildiğini g&ouml;zlemlemek vs. senaryolardan sadece bazılarıdır. Bu verilerin 1-2 kişi değil de &uuml;lke genelinde binlerce kişiden geldiğini d&uuml;ş&uuml;n&uuml;rsek toplumda hangi profilde (<a href="http://azure.microsoft.com/tr-tr/documentation/services/mobile-services/">Microsoft Azure Mobil Servisler</a> ile sosyal medya hesabından alınacak profil, &ouml;rneğin cinsiyet, bilgisi.)&nbsp; hangi kesimi daha fazla hareket ediyor, deniz seviyesinden farklılığa g&ouml;re uyku kalite haritası vs. &ccedil;ıkarılabilir.</p>
<p>Tabii ki bu duyargalardan gelecek veriler sadece b&uuml;y&uuml;k veri analizi i&ccedil;in kullanılmamaktadır. &Ouml;rneğin buzdolabına yerleştirdiğimiz duyarga elektrik kesintisinde veya buzdolabı arızasında <a href="http://azure.microsoft.com/tr-tr/documentation/services/service-bus/">Microsoft Azure Hizmet Veri Yolu (ServiceBus)</a> hizmeti yardımı ile ilgili olabilecek herkesin marka model den bağımsız olarak ister cep telefonuna, ister masa&uuml;st&uuml; bilgisayarına bir uyarıda g&ouml;nderebilir.</p>
<p>IoT konusunda devam edecek olan bu yazı dizisinde Microsoft Azure Servislerinin farklı kullanım senaryolarını anlatıyor olacağız.</p>
<p>&nbsp;Proje kaynak kodlar:&nbsp;<a href="https://tisensortag.codeplex.com/">https://tisensortag.codeplex.com</a>&nbsp;</p>
<p>Windows Phone Uygulaması:&nbsp;<a href="http://www.windowsphone.com/en-us/store/app/ti-sensortag/b88323c5-6e1b-4e6a-a9ae-dd2d3ba14790">http://www.windowsphone.com/en-us/store/app/ti-sensortag/b88323c5-6e1b-4e6a-a9ae-dd2d3ba14790&nbsp;</a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>]]></content:encoded>
    </item>
    <item>
      <title>Windows Azure ve Hadoop ile Büyük Veri Analizi - 2</title>
      <link>https://docs.microsoft.com/archive/blogs/mustafakasap/windows-azure-ve-hadoop-ile-byk-veri-analizi-2</link>
      <pubDate>Fri, 08 Nov 2013 07:38:00 GMT</pubDate>
      <dc:creator><![CDATA[Mustafa Kasap]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/mustafakasap/2013/11/08/windows-azure-ve-hadoop-ile-byk-veri-analizi-2/</guid>
      <description><![CDATA[Bu yazı dizisinin ilk bölümüne konu bütünlüğü için...]]></description>
      <content:encoded><![CDATA[<p align="justify">Bu yazı dizisinin ilk bölümüne konu bütünlüğü için <a title="http://blog.microsoft.com.tr/windows-azure-ve-hadoop-ile-buyuk-veri-analizi-1.html" href="http://blog.microsoft.com.tr/windows-azure-ve-hadoop-ile-buyuk-veri-analizi-1.html">http://blog.microsoft.com.tr/windows-azure-ve-hadoop-ile-buyuk-veri-analizi-1.html</a> adresinden ulaşabilirsiniz.</p>  <p align="justify"><b><u>HDInsight işlemci kümesi yaratmak</u></b></p>  <p align="justify">Hadoop kurulumu için ihtiyacımız olacak temel kaynak “Storage” hizmetidir. Verilerin saklanacağı bu alan için Azure yönetim sayfasından, Storage hizmet sayfasına (Resim 2.1) geçip, “New” (Resim 2.2) seçiminde bulunarak yeni bir veri saklama hizmeti oluşturulmalı. </p>  <p align="justify"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/3716.image_529591A8.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/3716.image_5F00_529591A8.png"><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/0535.image_thumb_4459A969.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/0535.image_5F00_thumb_5F00_4459A969.png" width="604" height="424" /></a></p>  <p align="justify">Resim 2: Windows Azure ana sayfa.</p>  <p align="justify">Yeni “Storage” hizmeti oluşturmak için açılan sihirbaz yardımı ile “Storage” hizmetine bir isim vermeniz gerekir (Resim 3.1). İsim tanımı yapıldıktan sonra “Create Storage Account” diyerek Hadoop için gerekli veri saklama alanını oluşturabilirsiniz. Bu hizmet sistem yoğunluğuna göre saniyeler içerisinde oluşturulacak ve sonrasında Hadoop kurulumu için temel gereksinim tamamlanmış olacak.</p>  <p align="justify"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/8726.image_5A431BB9.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/8726.image_5F00_5A431BB9.png"><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/0336.image_thumb_25391D3A.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/0336.image_5F00_thumb_5F00_25391D3A.png" width="604" height="422" /></a></p>  <p align="justify">Resim 3: Azure Storage oluşturma sihirbazı.</p>  <p align="justify">HDInsight servis kullanım talebinizin kabulü ve servis kullanım portalinin aktivasyonu sonrası Windows Azure portalinden “HDInsight” (Resim 4.1) sekmesine tıklayınız. Açılacak sayfada “Create an HDInsight Cluster” (Resim 4.2) düğmesine tıklayınız. Bu sayfadan aynı zamanda varsa mevcut HDInsight kümelerinizin detaylarını da görüntüleyebilirsiniz.</p>  <p align="justify"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/3022.image_1E1C7173.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/3022.image_5F00_1E1C7173.png"><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/1258.image_thumb_36AE9F74.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/1258.image_5F00_thumb_5F00_36AE9F74.png" width="604" height="422" /></a></p>  <p align="justify">Resim 4: HDInsight hizmet görüntüleme sayfası.</p>  <p align="justify">HDInsight kümesi yaratma seçimi yapıldıktan sonra çıkacak sihirbaz yardımı ile kurulacak işlemci kümesinin özelliklerini ayarlayabilirsiniz. Sihirbaz aracılığı ile HDInsight kümesine bir isim (Resim 5.1), bu küme içerisinde yer alacak düğüm sayısı (Resim 5.2) ve yaratılacak kümenin yönetim portaline erişim için şifre (Resim 5.3) ile hangi “Storage” hizmeti üzerine kurulacağını (Resim 5.4) belirtmeniz gerekir. Bu hizmet için Resim 3.1’de tanımladığınız “Storage” ismini listeden seçiniz.</p>  <p align="justify">Düğüm sayısını arttırarak daha fazla işlemci gücü elde edebilirsiniz fakat Azure hizmetini ücretli olarak kullanıyorsanız bu sayının arttırılması maliyeti de arttıracaktır. Ücretsiz deneme hizmeti kullanıyorsanız, bu sayının arttırılması sizin için ayrılmış aylık X dolarlık yada X saatlik hizmet kredisinin daha hızlı tükenmesine neden olacaktır. Test amaçlı kullanımlarda düğüm sayısını en az oranda tutulması kredinin daha geç tükenmesini sağlayacaktır.</p>  <p align="justify"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/5482.image_6CB31E81.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/5482.image_5F00_6CB31E81.png"><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/1050.image_thumb_50A4F047.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/1050.image_5F00_thumb_5F00_50A4F047.png" width="604" height="422" /></a></p>  <p align="justify">Resim 5: HDInsight hizmet kümesinin kurulumu.</p>  <p align="justify">Oluşturulacak HDInsight servisinin yönetim paneline erişim için kullanılacak yönetici ismi “admin”, şifresi ise Resim 5.3’teki alanda tanımlayacağınız şifre olacaktır. Yönetim paneline erişim için gerekli URL adresini kurulum tamamlandıktan sonra Resim 4’te belirtilen sayfadan görebileceksiniz.</p>  <p align="justify">Yukarıda belirtilen özelliklerin tanımından sonra “Create HDInsight Cluster” bağlantısına tıklayarak kurulum işlemini başlatabilirsiniz. Kurulum tamamlandıktan sonra Resim 6’da belirtilen “Status” kolonunda “Running” ifadesi yer almalı. Resim 6.1 ile gösterilen bağlantıyı takip ederek Hadoop işlemci kümesindeki ana bilgisayara uzak bilgisayar bağlantısı ile bağlanabilir, işlem güncesini inceleyebilir, direkt komut satırından işlemlerinizi başlatabilirsiniz. Bu tarz işlemleri direkt ana bilgisayar üzerinden yapmak yerine, Internet’e bağlı herhangi bir bilgisayardaki Web gezgini üzerinden sihirbaz aracılığı ile yapmak isterseniz Resim 6.2 ile gösterilen bağlantıyı takip etmeniz gerekmektedir. Bu bağlantı ile açacağınız web sitesinde Hadoop işlemci kümesini kontrol edebilir, küme içerisinde yer alan makinelerin performans vs. analizlerini grafiksel olarak takip edebilirsiniz.</p>  <p align="justify"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/2570.image_1B9AF1C8.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/2570.image_5F00_1B9AF1C8.png"><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/2541.image_thumb_6690F348.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/2541.image_5F00_thumb_5F00_6690F348.png" width="604" height="422" /></a></p>  <p align="justify">Resim 6: Windows Azure HDInsight ana sayfası.</p>  <p align="justify">Hadoop işlemci kümesine web arayüzü ile erişim için Resim 6.2 deki bağlantıyı takip ederek yönetim paneline giriş yapabilirsiniz. Bunun için Resim 7’de görüntülenen kullanıcı giriş ekranındaki ilgili alanlara Resim 5.3’de belirttiğiniz kullanıcı adı ve şifreyi giriniz. Resim 5’deki gibi sihirbazı kullanarak Hadoop kümesi yarattıysanız kullanıcı adınız “admin” olarak belirlenir. </p>  <p align="justify"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/2577.image_1C957256.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/2577.image_5F00_1C957256.png"><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/4162.image_thumb_75C9ECC6.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/4162.image_5F00_thumb_5F00_75C9ECC6.png" width="624" height="286" /></a></p>  <p align="justify">Resim 7: Yönetim Paneli</p>  <p align="justify">Yönetim paneli (Resim 8) üzerinden sistemdeki düğümler ile “remote desktop” bağlantısı kurabilir, düğümlerdeki iş durumlarını görüntüleyebilir Örnek kod – projeleri mevcut küme üzerinde çalıştırabilirsiniz.</p>  <p align="justify"><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/5187.image_0C1F920C.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/5187.image_5F00_0C1F920C.png"><img title="image" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/12/metablogapi/2313.image_thumb_0D83B4DE.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-12-metablogapi/2313.image_5F00_thumb_5F00_0D83B4DE.png" width="624" height="546" /></a></p>  <p align="justify"></p>  <p align="justify"></p>          <p>Resim 8: Yönetim Paneli</p>  <p>Bir sonraki yazı dizimizde Hadoop üzerinde büyük ölçekli bir metin bilgisi içerisindeki kelimelerin kullanım sıklık oranlarının nasıl çıkarılacağı üzerinde bir örnek yapacağız.</p>]]></content:encoded>
    </item>
  </channel>
</rss>