Monday 16 January 2017

How to extract images that are generated by Azure Machine Learning Studio

Motivation for this post

Azure Machine Learning Studio from Microsoft can be used to easily build your data science solutions component by component. One of the major benefits is that in each component you can easily add in some visualizations. When you are satisfied with your data solution you can build a web service from this solution. In this blog post I will show you how you also can extract the visualizations from this web service so that you don't lose the visualizations when you are automating your data science solution.

Building the ML Experiment

We will build a simple experiment in Azure ML that imports a data file. Next, the input is connected to an R Module. The main goal of this R module is to draw a graph with a bar chart.




To see this graph chart you can right click on the right dot of the module and select visualize.


In the resulting window under the title Graphics you see the image that you want to extract under the graphics title. This will be an example graph that we want to extract in an automated way.

Building the Web service

Next, we will build the web service that corresponds to this experiment. For this web service we need an input and an output. With the input we can read in a blob storage file and the output we are going to connect with the right dot from the R module. This is the one that you also used to generate the visualization. By making this the output we are going to save the content of the window that we visualized in the previous paragraph in a blob storage file. 



So the major two tasks that are still left for us are to execute the web service to generate the output blob and next to parse this output blob storage file. The web service will be generated in a way similar to the way that you you normally generate a web service from Azure ML. We will describe these steps further in an upcoming blog post. 

Executing the Web service

We will execute the web service in the same way that we normally execute a web service generated from Azure ML. The major difference will now be on how we will parse the output file. We will only be focussing on the latter part. First we read in this file and print it's contents to the console to have a better idea of what the file looks like.



We see that this file starts with R Output JSON, we recognize some JSON formatting and we also see a larger part of text written in random letters and numbers following each other. This part is actually the image represented in PNG encoding in this JSON file.

Based on this analysis we know that we need to perform the following tasks to extract this picture. 

1. Find the location of the first "{
2. Extract the JSON text from the file
3. Parse the result as a JSON object
3. Loop over the sections in the JSON object and locate the section that has graphic as title
4. Decode the resulting values for the image as a PNG and write to a file
5. Open the file that you have saved and admire your work.

The code that you need for this you can find in the picture below.

Resulting graph


Below you can find the extracted images from the web service. If you want to use this image directly in html you actually don't need to execute this extra step. 

Conclusion


In this post I explained how you can extract images that are generated in Azure Machine Learning Studio. This is a step that might help you out in speeding up your data science prototypes. 





9 comments:

  1. Thanks for helping us understand this topic. You have written it in a way that makes it very simple to understand. Thank you so much.


    BIM documentation in USA
    VIZUALIZATIONS

    ReplyDelete
  2. Project Management
    I am impressed with your work and skill.Fabulous outfit.Thank you so much.Good job. Keep posting
    VISUALIZATION SERVICES

    ReplyDelete
  3. From this blog, I can know more regarding azure cloud migration services. It is really useful for those who want to more about it.
    azure cloud migration services

    ReplyDelete
  4. So informative. I was searching like this for a few days. Thank you for sharing this information.
    second hand mobile phones for sale

    ReplyDelete
  5. I will create 350 high da profile backlinks manually
    High Authority SEO Profile Backlinks is one of the amazing procedures to expand the rankings of your site in well-known web crawlers like Google.
    With great backlinks, your site can rank on Google Top #1. So considering the benefit of getting Rankings just as to expand the traffic.
    I will make your top-notch Profile Backlinks.

    ReplyDelete
  6. Caesars Casino Review (2021) - Get $10 Free with No Deposit
    Caesars filmfileeurope.com Casino Review · 1. 바카라사이트 Claim your $10 free bonus and receive up https://jancasino.com/review/merit-casino/ to $20 https://septcasino.com/review/merit-casino/ in casino febcasino credits (30 Free Spins) · 2. Play Slots at Caesars Casino.

    ReplyDelete
  7. This comment has been removed by the author.

    ReplyDelete