In more than one occasion, we proved that using Keras library to solve a text classification problem is the best choice for rapidly building a strong and efficient Deep Learning model.
Today, following our insight on text classification challenges, we want to spread the word on how Keras is helpful to address our clients machine learning needs and what are the advantages of using it instead of using other well-known neural network libraries like Tensorflow.

Keras is a python library that offers, nearly off the shelf, notorious deep learning models. It has been developed in a way that makes the library easy to learn and use. Keras team idea behind their work is to facilitate machine learning research as they state that the goal is to: “Being able to go from idea to result with the least possible delay is key to doing good research”.

Since TensorFlow 2.0, Keras is integrated to TensorFlow and is recommended as a high-level API.

Advantages Keras offers us

One of the practicalities we find in using Keras is the fact that it offers APIs for every step we go through in our prediction journey from pre-processing to prediction and evaluation (see figure 1 for prediction steps).

Besides, we are offered the choice between the Sequential Model API for building Neural Networks as a stack of layers or the Functional API to handle multi-input / multi-output complex models or the Model Subclassing API to obtain a fully customizable model.

To sum up, the API is very user friendly and offers the level of abstraction needed.

What kind of challenges can be addressed with Keras?

For one of our clients' cases, we were in the possession of unstructured data namely free format text that was mostly labeled. As the best performances observed for text classification has been performed with deep learning algorithm https://nlpprogress.com/english/text_classification.html, we decided to explore the use of Convolutional Neural Networks (CNN) and Long-Short Term Model (LSTM) algorithms.

To avoid intensive pre-processing steps such as the removal of stop words or words' lemmatization, we relied on neural network capabilities to discard noise. Neural Networks should infer the latent variables from the text that learn the words with strong influence on the classification outcome.

We still had to perform one necessary pre-processing task to transform our input text dataset into a matrix of coded sequences and to codify the data output as well.  For the input transformation, we used the “text_to_sequences” Keras function followed by the “pad_sequences” function to have equal length entries. Output labels codification was based on the assignation of a different code to each possible class.

The dataset was then ready to be processed with machine learning algorithms, and we could shape our classification model with Keras' sequential API. Very simple models don't require more than 2 lines of code to be set. In fact, our baseline algorithm can be composed of a dense layer that sets the neurons learning the parameters from input data and an activation layer yielding the output class.

The last 2 steps to obtain our first results are compiling the model with the right loss function and a good optimizer function then fitting the model with the input and output data.

With an iterative approach, we obtained impressive results described in this client case (https://openwt.com/en/cases/99-correct-product-assignments-thanks-our-ai). In fact, given the product manufacturer description, we successfully classify the product's brand and attributes helping our client to streamline their online product placement on their e-commerce platform.

You can read more about machine learning use case: Text classification and AI Email classification

Other news

View all
Read more
Read more
Read more
Help us improve our website
To improve content and enhance your experience, we use cookies for analytics purposes.
Decline all cookies