BUSINESS INSIGHTS

Aug 29, 2018

Cognitive Services Labs: Experimental Tools to Explore

David Eldersveld Posted by David Eldersveld

In addition to the primary Cognitive Services tools that BlueGranite has previously explored SearchVision, Speech, Language, and Knowledge Microsoft has experimental APIs under the name of Cognitive Services Labs. While you should not use these APIs in production, they offer a glimpse into pre-built AI that Microsoft may eventually promote as a supported API.

Cognitive Services Labs Tools

Get more detail about the different Cognitive Services Labs APIs here.

Vision Project Gesture
Vision Project Ink Analysis
Search Project Local Insights
Search Project Event Tracking
Search Project Answer Search
Search Project URL Preview
Language Project Conversation Learner
Language Project Personality Chat
Knowledge Project Knowledge Exploration
Knowledge Project Academic Knowledge
Knowledge Project Entity Linking
Knowledge Project Anomaly Finder
Knowledge Project Custom Decision


Anomaly Finder Example

As a data professional, I frequently work with Power BI, SQL Server, and a variety of tools in the Azure Data Platform. Analysis over time is key to much of the data that I encounter. With time series data, one of the ways that I could benefit from Cognitive Services is to use pre-built AI for automated anomaly detection.

The Anomaly Finder API from Cognitive Services Labs flags each data point as an anomaly or not. An example of an anomaly would be a value that falls outside the expected range. The service also returns the expected value and the upper and lower thresholds outside of which it flags anomalies. As with other Cognitive Services, you don’t necessarily need to be a developer heavily reliant on code. Even Power BI can call the API without using any external tool or language.

With Power BI as an example, I’ll use transformations in Power Query to change the source table data into JSON. The API requires JSON keys named Timestamp and Value, but you can also include supporting fields. Why? The API response will not include the original Timestamps or Values, so additional fields help you tie the response back to your original data. In this case, I’ve included Order Date for each record. Having Order Date will later allow me to join the results to the original data on that field.

Here’s a glimpse at the data in tabular form prior to converting to JSON:

Cognitive Services Labs - Data Preview

Here’s a subset of the data that is in a form ready to send to the Anomaly Finder API:

{ "Period": 0.0, "Points": [{"Order Date":"2010-01-01","Value":194,"Timestamp":"2010-01-01"},{"Order Date":"2010-01-02","Value":11808,"Timestamp":"2010-01-02"},{"Order Date":"2010-01-03","Value":7936,"Timestamp":"2010-01-03"},{"Order Date":"2010-01-04","Value":402,"Timestamp":"2010-01-04"},{"Order Date":"2010-01-05","Value":6258,"Timestamp":"2010-01-05"},{"Order Date":"2010-01-06","Value":9385,"Timestamp":"2010-01-06"} [..]

Once the time series data is in the appropriate format to send in the body of the request, use Power Query to call the API as well. The Anomaly Finder API requires a POST request containing the authorization token and content type in addition to the body. In Power Query, this type of web request requires some manual M coding with the Web.Contents() function. In addition, since the response is JSON, use the Json.Document() function and then other functions to clean up the results. You may end up with something similar to the following M code.

= Json.Document(Web.Contents(_CogServUrl, [Headers = [#"Ocp-Apim-Subscription-Key" = _AuthKey, #"Content-Type" = "application/json"], Content = Text.ToBinary(Body)]))

After some transformation of the JSON, the results are in table format.

Cognitive Services Labs - Data Preview 2

I’ve also created a relationship between the original Orders table and the table containing the API results.

Cognitive Services Labs - Relationship

Finally, after adding the results to a visual, I can easily view any day with sales anomalies – all accomplished without leaving Power BI. 

Cognitive Services Labs - Anomaly Chart

Remember that Cognitive Services Labs contains a set of experimental APIs. Anomaly Finder is one of the many promising Lab APIs that will hopefully make its way to production-level Cognitive Services at some point. While it and the other experimental services are not appropriate for production workloads, they showcase future possibilities and the immense potential of using AI to enrich your solutions.

Getting Started with AI Webinar
David Eldersveld

About The Author

David Eldersveld

David is a Senior Consultant and Microsoft MVP who has employed skills in technology development, data integration, data analysis, and systems analysis for over ten years. David enjoys building BI and advanced analytics solutions with technologies such as SQL Server, Microsoft R, and Power BI. He is active in various technical communities. In addition to blogging for BlueGranite, he also writes at dataveld.com.

Latest Posts

Getting Started with AI Webinar