Author: unmeshballal

Integrating Machine Learning APIs in Microsoft Bot framework Apps

bot, is a software application that runs automated tasks over the Internet. Typically, bots perform tasks that are both simple and structurally repetitive, at a much higher rate than would be possible for a human alone. The largest use of bots is in searching, in which an automated script fetches, analyzes and files information from web servers at many times the speed of a human.

In this blog we will guide the reader in creating a bot that will enable you to quickly do data analytics. e.g. to begin with steps for doing text based sentiment analysis.

Solution being developed using following Microsoft Technologies:
1. Microsoft Bot Framework
2. Machine Learning APIs for Sentiment analysis

Here are the steps:
Microsoft Bot framework application

1. Add a Bot template in Visual Studio 2015 Community edition as per instructions given from this link

2. Create a bot template based Visual Studio C# solution using the downloaded template. add and update the following code to the template created code to update the messages:

public class MessagesController : ApiController{
/// POST: api/Messages
/// Receive a message from a user and reply to it
public async Task Post([FromBody]Message message) {
if (message.Type == "Message") {
// calculate something for us to return
int length = (message.Text ?? string.Empty).Length;
string sentimentResponse = GetSentimentResponse.GetSentiment(message.Text);
return message.CreateReplyMessage($"Your message {length}. " + sentimentResponse);
}
else {
return HandleSystemMessage(message);
}
}

3. Using bot emulator ensure that bot is responding to messages as per the code. Now that the bot is created we will integrate it in Skype so that we can use an existing application that makes our bot immediately usable Refer to this link for registering the bot with Skype.

Machine Learning APIs for Sentiment analysis

4. Next step is to integrate the Microsoft Machine API’s check this link for details:

5. The user text (e.g. entered in Skype) is used for sentiment analysis as shown in the code below:
public static String GetSentiment(string message) {
try {
string myComment = message.Replace(' ', '+');
HttpClient client = new HttpClient();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

string key = "AccountKey:" + "";
byte[] creds = System.Text.Encoding.UTF8.GetBytes(key);
client.DefaultRequestHeaders.Add( "Authorization", "Basic "+ System.Text.Encoding.UTF8.GetString(creds));
HttpResponseMessage response = client.GetAsync("https://api.datamarket.azure.com/data.ashx/amla/text-analytics/v1/GetSentiment?Text=" + myComment).Result;
if (response.IsSuccessStatusCode) {
var data = response.Content.ReadAsStringAsync().Result;
var product = JsonConvert.DeserializeObject(data);
return $"Your sentiment is {product.Score}. Have a good time";
}
else message = response.ReasonPhrase;
}
catch (Exception ex) {
Console.WriteLine(ex.Message);
}
return message;
}
}

6. This code demonstrates how we can integrated Machine Learning API using the Microsoft bot framework

Many More such use case can be integrated similarly e.g. SMS being sent for some specific activity in a Industrial establishment.

Advertisements

Hosting an Industrial Device Online

IOT (INTERNET OF THINGS) AND INDUSTRIAL DEVICES

The Internet of Things (IoT, sometimes Internet of Everything) is the network of physical objects or “things” embedded with electronics, software, sensors, and connectivity to enable objects to exchange data with the manufacturer, operator and/or other connected devices based on the infrastructure of International Telecommunication Union’s Global Standards Initiative.
The Internet of Things allows objects to be sensed and controlled remotely across existing network infrastructure, creating opportunities for more direct integration between the physical world and computer-based systems, and resulting in improved efficiency, accuracy and economic benefit.(Wikipedia)

BENEFITS OF IOT (INTERNET OF THINGS)

• Access Dashboard information from anywhere about a device
• Enhanced customer service
• Increased revenue from services and/or products
• Improved use of assets in the field
• More information to feed big data/analytics efforts
• Identifying Areas of development
• Remote asset management and/or asset tracking
• Security (e.g., 4G cameras)
• Energy data management
• Condition-based monitoring
• Fleet management

HOW TO BRING ANY DEVICE IN IOT (INTERNET OF THINGS)

As shown in the diagram a device can be enabled by first adding a native webserver so relevant its data can be made available in a dashboard and is searchable. This step may require adding a hardware component or native component and then hosting on a local web server. This is possible on embedded Linux OS for all other types of device it needs to be seen how the webserver can be hosted.

Online Device Block Diagram

As shown in the diagram a GSM based mobile device can ensure the connectivity to the internet. The socket communication can be done with the online device server and device once the device is brought online. The online device app will host the web server that will send the request to the socket server.

To prepare the solution we need to have
1. Socket Client – on the device
2. Socket Server – on the web
3. Reverse HTTP Protocol Relay Server – on the web
4. Hosting of the HTTP Server on AWS cloud or any other cloud provider

SAMPLE CODE

Source code for above solution is freely available and can be downloaded from:
https://github.com/pmunmesh/onlinedevices

Increasing online sales reach through referral’s

Dictionary meaning of referral is – an act of referring someone or something for consultation, review, or further action.
– the directing of a patient to a medical specialist by a GP.
– a person whose case has been referred to a specialist doctor or a professional body.
– Referrals is not a new concept and we all know it works with improved relationships, word of mouth etc..

If we look closer into the minds of the customer and see what ticks is the cost-benefit, trust and potential guarantee of improved relationship.

Online sales and offline sales referrals and can be depicted from the diagram below:

ReferralCycle

Its clear that there is a demand for better service and typically buyer is in need for not only just an advise but also advise that has some credibility hence customer is waiting for the right idea that works! In a offline model its a lot of communications through phone before this is possible.

An online referral comes as a perfect fit for much needed requirement. Even then its not guaranteed that a referral always works but it improves the chances. At the least if a customer is not able to make a decision – the very indecision typically leads to asking or seeking for an advise – and then with correct matched-advise results in a good referral.

To conclude an online application when referred by someone for a requirement can be known much easily and hence can enable better business results. Although it necessary for customer to expresses its requirement online to the seller.

Implementing Six Sigma practices for better Quality

In a typical software development and testing projects – Agile and SDLC (Software Development Life cycle) practices are sufficient although to further improve quality beyond a certain extent advanced techniques are required. In this article the discussion is about how six sigma can be introduced to further improve the quality of the software product development and its delivery. For illustration purpose a software organization can be depicted as consisting the following:

• Business
• Process and
• People

pic1m

In the above diagram improvements cannot be introduced although its enough to deliver the projects as per customer requirements. Six sigma techniques provides the possibilities for further improvements by adding to activities that can be introduced that will also further the overall organizational capabilities. Hence the purpose of improving the quality is just one aspect of overall capability improvements that are possible and can be depicted in the diagram shown below:

pic3m

It is also observed that due to reporting to client/customer andt changing customer expectations the basic software testing in the SDLC processes is not enough hence additional data needs to be collected in ensuring reporting and also demonstrating quality as per customer expectations. Thus its imperative to improve by training in teams throughout organization and to be familiar with the additional activities to improve quality. These are categorized as below:

• Each team will have at least one six sigma champion – if not team member manager that can be designated.
• The designated team member will perform checks on the following sub-tasks

    • Continuous improvement
    • Maintaining customer satisfaction / loyalty by asking questions
    • Root cause analysis as a process
    • Identifying the performance metrics and reporting QA and development activities to client and stake holders
    • Voice of customer – understanding and establishing the end user/consumer
    • Trend analysis of requirements, delivery and issue tracking
    • Cause and effect analysis as a process
    • Identifying a process to fulfill a requirement and helping in improving it in discussion with client and within organization
    • Identifying and improving by taking special initiatives on poor quality areas

pic2m

• In addition its possible to build on following capabilities :

    • ISO 9000
    • Project Management

• Further Each project and product development can customize the development process by introducing the Plan – Do – Check – Act process for development activities

• Continue to strict adherence to Agile and other SDLC practices for software development activities


The result of doing the above tasks will result in overall quality improvement.

Further following metrics can be measured:

• Improved predictability
• Delivering the project on time and as per schedule
• Better resource management
• Improved customer satisfaction

How to Enable Devices for Internet of Things?

Definition of Internet of Things

Internet of Things is broad term used for many objects and their virtual representations within the internet architecture. Detailed descriptions can be found in the Wiki link – http://en.wikipedia.org/wiki/Internet_of_Things

In this discussion the scope is limited to devices that is shown in the diagram below:

Image

What is the Problem with the devices?

In internet of things terminology the device of concern is not directly connected to internet or has no access to internet. The level of sharing of information and thus status of various components is not adequate to make decisions. A decision typically require availability of various metrics parameters, some of these are:

  • Productivity
  • Application analytics
  • Feature enhancements and components upgrades
  • New integrations
  • Cost reductions ideas
  • Data Trends

A standalone device is not designed to provide the advanced data on continual basis – one of the many reasons being it’s not connected and is not available on the web. The resources using these devices are also isolated due to the nature of work surrounding the devices. Some of the examples of these devices are in industrial environments of:

  • Oil and Gas Industry
  • Manufacturing Industry
  • Consumer Industry

It is known thing that in these industries it’s neither appropriate nor cost effective at design time to provide the interfaces.

Design and feature tradeoffs of existing designs

When the devices were designed the design was done so that it solves the main problem e.g. a gas sensor is designed to first successfully detect the gas values and provide data to the immediate environment. The design of hardware also and any other visual display is primarily intended only to serve the purpose and not necessarily justify the cost of added benefits. Although the enterprises would benefit better integrated systems not always all legacy devices would have the connectivity when the product is designed.

How do we solve the problem?

There are many ways to solve the above problem some of the methods are:

  • Use industry standard platform e.g. Windows embedded OS and enable web server interfaces
  • Ethernet network enable devices
  • Add Wi-fi enabled device interface
  • Add Bluetooth interface to provide networking support
  • Enable web server access – users should be able to access the device using a URL. The status of device and external interface functionality
  • Enable exporting of data trends in reports
  • Web service API for uploading data for external apps

How to enable the devices for IoT?

  • Enable web server access – users should be able to access the device using a URL. The status of device and external interface functionality
  • Enable exporting of trend reports
  • Remote access to device
  • Web service API for uploading data for external apps
  • etc..

What are the added benefits of connected devices?

Connected devices can be easily integrated into various external systems to better e nablethe overall deployment in enterprises.

In Search of Value in Software Testing

It’s important to value the work done by a Tester. Though a tester will typically create and modify own assets namely the test cases, test execution results these are not necessarily quantifiable in terms of productivity and hence there is need to take help of better metrics. Typically the following are widely used:

• Number of Test Cases
• Test Execution Rate
• Defect Finding Rate

A Testing project consists of Test Deliverables – these include testing and its results. A product is measured in identifying defects in code and is correctly identified by defect rate.

What are the other metrics?
The product quality requires consideration for the other metrics

• Quality of Test Cases
• Quality of Execution
• Quality of Defects

These metrics are a result of what result these produce. Though before we can proceed with the next step it’s important to measure more critical “Quality Metrics”.

To understand the issue let us look at the developer live cycle (SDLC). A Developer spends considerable time in designing the product and identify use cases. The main use case and secondary uses are thoroughly understood and then code logic is developed and implemented. The code is then tested and defects reported. These do cover most of the testing although it cannot be said that all is done. During our testing of small and large test projects it was observed that following additional techniques were required to further improve the testing efforts and add value to testing process. These methods are well known and very useful for identifying the defects and improving overall quality

Root cause analysis using Fishbone Diagram
• Test case documentation standard Checklists
• Verification Checklists
• Preparing the Modular flow (and understanding) of the code.

In the above methods fishbone diagram as shown has shown the maximum benefit:

Fishbone diagram

Fishbone diagram

Having a process oriented approach and applying all of the above techniques the rate for defect finding was found to be improving and quantifiable.

Additional reading can be found here

Raspberry Pi based Content Delivery Platform

 

The Raspberry Pi is a credit-card-sized single-board computer developed in the UK by the Raspberry Pi Foundation with the intention of promoting the teaching of basic computer science in schools. The Raspberry Pi has a Broadcom BCM2835 system on a chip (SoC), which includes an ARM1176JZF-S 700 MHz processor (The firmware includes a number of “Turbo” modes so that the user can attempt overclocking, up to 1 GHz, without affecting the warranty),VideoCore IV GPU, and was originally shipped with 256 megabytes of RAM, later upgraded to 512MB. It does not include a built-in hard disk or solid-state drive, but uses an SD card for booting and long-term storage. The Foundation’s goal is to offer two versions, priced at US$25 and US$35

Content Delivery Solution

Lets see how a Raspberry pi based content delivery solution can be developed for educational institutes or anyone who needs it. Educational institutes have primary objective to enable learning through various interactive programmable delivery of content. The setup can be installed in lounge areas or even in school classrooms. Content can be customized as per need and pre-added to a batch file based application that functions like a jukebox that open the YouTube video link using the default internet browser. Making the content delivery changes will be a custom requirement and can be remotely administered. The prototype application can be administered by modifying the configuration files that directly download content from LAN or any other source.

How can it be done ? – The Technology

FreeBSD  installed on the sd card and Apache based web application for each school/university as per need. Once device is started it boot the OS and start the web app on display with default player.

What Application?

Custom prototype application initially can be installed for demonstration that will play the YouTube demo videos.

Detailed Design – Block Diagram

Block diagram consists of Raspberry Pi device (with casing) connected to the LAN. The device is connected to a TV and speaker. When the device is started it will booted with output to TV and speakers as per the configuration setup. When the device is switched off no video is played.

Image

Specifications

Model A: Target price:         US$ 25           

Model B: Target price:         US$ 35

SoC: Broadcom BCM2835 (CPU, GPU, DSP, SDRAM, and single USB port)

CPU:   700 MHz ARM1176JZF-S core (ARM11 family)

GPU:  Broadcom VideoCore IV

              OpenGL ES 2.0 (24 GFLOPS)

              MPEG-2 and VC-1 (with license),

              1080p30 h.264/MPEG-4 AVC high-profile decoder and encoder

Memory (SDRAM):

Model A: 256 MB (shared with GPU)          

Model B: 512 MB (shared with GPU)

USB 2.0 ports:           1 (direct from BCM2835 chip)          

                            2 (via the built in integrated 3-port USB hub)

Video input:   A CSI input connector allows for the connection of a RPF designed camera module

Video outputs:           Composite RCA (PAL and NTSC),

                             HDMI (rev 1.3 & 1.4),

                             raw LCD Panels via DSI

                            14 HDMI resolutions from 640×350 to 1920×1200 plus various PAL and NTSC standards.

Audio outputs:           3.5 mm jack, HDMI, and, as of revision 2 boards, I²S audio  (also potentially for audio input)

Onboard storage:      SD / MMC / SDIO card slot (3,3V card power support only)

Onboard network:    None   10/100 Ethernet (8P8C) USB adapter on the third port of the USB hub

Low-level peripherals:          8 × GPIO, UART, I²C bus, SPI bus with two chip selects, I²S audio +3.3 V, +5 V, ground

Power ratings:           Model A: 300 mA (1.5 W)

Model B: 700 mA (3.5 W)

Power source:            5 volt via MicroUSB or GPIO header

Size:    85.60 mm × 53.98 mm (3.370 in × 2.125 in)

Weight:           45 g (1.6 oz)

Operating systems:    Arch Linux ARM, Debian Linux, Fedora, FreeBSD, Plan 9, Raspbian OS, RISC OS,Slackware Linux

References

  1. Boot file config settings http://elinux.org/RPi_config.txt
  2. MPEG2 license key: http://www.raspberrypi.com/
  3. Quick Start Guide: http://www.raspberrypi.org/quick-start-guide