DEV Community

Cover image for Create a hotel customer reviews classification with Azure

Posted on

Create a hotel customer reviews classification with Azure


The Experiment #102 researches about the possibilities of applying Cognitive Services and Deep Learning to understand and manage a huge amount of information from human interactions without the human intervention. We will discover if the Artificial Intelligence is capable of collect all this raw data, classify it and manage all the different situations.


The project tries to simulate an automatic classification of comments or reviews in a business environment. Any company wants to identify critical requests as soon as possible to try to solve it before them become a big problem, regardless of the number of messages that arrive, or the language in which them were wrote, or the time that them were sent.


For this simulation it is been chosen the case of an hotel. We will imagine that the customers have access to a mobile application in which they can leave their comments, complaints and suggestions. They can use images to illustrate their point of view or location and text messages to explain it. Due to content, the reviews will be classified as good, neutral or bad.

In this case we want to classify each comment and identify the bad, urgent and important ones to manage them quickly and, if it were necessary, report to a different human agent depends of the location (room, bar, restaurant, swimming pool, etc), who will can solve it properly.


First, we are going to create an Azure Notebooks project where we can set up a Notebook server. Then we will create and upload some files based on Python to deploy a Text Summarization service in an Azure Machine Learning Workspace. After that, we will construct and train a simple deep neural network classification model, with Keras and Tensorflow, that will classify the hotel customers reviews.

Also, we will perform the integration with the Azure Cognitive Services along with the Azure Machine Learning. We will use Computer Vision API to collect information from pictures or photographs and Text Analytics API to extract data from human utterances.


The principal advantage of using Cognitive Services and Deep Learning in this case is the possibility of identifying very quickly the reviews or comments that needs to be carefully manage by a human been because of its importance or its urgency.

Even if tons and tons of messages arrive, we can be sure that the most critical messages will be identified and treated immediately and the rest of them will be classified and stored correctly.

This way a company will save money and resources and will be very much efficient attending customers’ requests.


We tried to simulate hotel customer inputs from different sources (01) like Social Media, this hotel reviews (02) will be send to an Artificial Intelligent for its analysis.

We used Azure Notebooks with Jupyter to create, train and deploy the services we need. Ones of them are Containerized Services (03) we trained with Deep Learning like the Summarize Service (05) and the Classification Service (06). Others are Cognitive Services (04) we used directly from Microsoft like Computer Vision (07) and Text Analytics (08).

If you want to read more go to this post.

Step by Step

1. How to create an Azure Notebooks project

First, we can access this Azure Notebooks Service by visiting and then, we can create a new Azure Notebooks Project from “My Projects”.

If you want to see the whole process just go to this post.

2. How to construct a Deep Neural Network

Keras is a Python library that allows us to construct Deep Learning models. First, we must import all needed modules and download the text analytics files from our GitHub repository. The cells of the “.ipynb” script look like this:

import re
import nltk
import uuid
import os
import numpy as np
import pandas as pd
import tensorflow as tf
import keras
from keras import models, layers, optimizers, regularizers
from keras.models import Sequential
from keras.layers import Dense, Activation
from keras.utils import to_categorical

import urllib.request
data_location = './data'
base_data_url = ''
filesToDownload = ['reviews_labels.txt', 'reviews_texts.txt', '', '']

os.makedirs(data_location, exist_ok=True)

for file in filesToDownload:
    data_url = os.path.join(base_data_url, file)
    local_file_path = os.path.join(data_location, file)
    urllib.request.urlretrieve(data_url, local_file_path)'stopwords')'punkt')

import sys
import textanalytics as ta
Enter fullscreen mode Exit fullscreen mode

If you want to see the whole process just go to this post.

3. How to deploy Azure Cognitive Services

Computer Vision is an Azure Cognitive Service that allow us to get information from an image. It analyzes the image environment, detects objects inside them and classifies all of them by assigning tags and labels. We can find this resource in our Azure Portal under the “AI + Machine Learning” group:

After deploying the service, we must look and write down at the subscription key and the endpoint to integrate the service in our project.

If you want to see the whole process just go to this post.

4. How to use Microsoft Flow to send alerts

We have created a very simple C# console project to simulate the reception of hotel reviews. The program makes HTTP requests to the different services we have previously deployed to collect all the information from the image and text of the review. These services include containerized services like Summarize or Classification and Cognitive Services like Computer Vision or Text Analytics.

All review data will be stored in a SQL database. This is the database definition:

CREATE TABLE [dbo].[review](
    [id] [int] IDENTITY(1,1) NOT NULL,
    [text] [nvarchar](MAX) NULL,
    [class] [nvarchar](64) NULL,
    [sentiment] [nvarchar](64) NULL,
    [summary] [nvarchar](2048) NULL,
    [keys] [nvarchar](1024) NULL,
    [image] [nvarchar](1024) NULL,
    [captions] [nvarchar](1024) NULL,
    [categories] [nvarchar](1024) NULL,
    [tags] [nvarchar](1024) NULL,
    CONSTRAINT [PK_review] PRIMARY KEY ([id])
Enter fullscreen mode Exit fullscreen mode

If you want to see the whole process just go to this post.

To keep reading about these topics, check out the following links:


Azure Logic Apps

Top comments (0)