Scikit-learn, TensorFlow, PyTorch, Keras… but what about Libra?
By: Ugo Loobuyck
Tags: Data Science, Python, Framework, Machine Learning, Deep Learning

Welcome all! In the first episode of this series, I investigated the four most known machine learning frameworks and discussed which of these you should learn depending on your needs and goals.

Of course, we all know how PyTorch and TensorFlow are overwhelmingly effective and thorough when it comes to building deep learning algorithms from scratch. Similarly, Scikit-learn comes with excellent non-neural solutions and a whole lot of convenient data processing and evaluation functions.

Today, I would like to draw your attention to something different: a rising machine learning framework, Libra, that absolutely deserves your attention and has tripled its amount of GitHub stars in only a week (reaching 1.8K)!

In this article, I will cover:

The basic concept of the framework The interesting features I spotted The expected downsides A concrete use example

I. Base Concept

Libra is an easy-to-use machine learning framework that will allow you to load data, process it, train models and visualize results with only a few lines of code.

The major advantage of this framework is its user-friendliness and beginner-friendliness. The diagram below shows about how fast you can setup an ML project compared to more common frameworks:

This literally means that you can come with no or nearly no technical machine learning knowledge and implement a full project in about 5 minutes.

The library is built for Python (⩾3.6) and revolves around a Client object that will handle your data but also the models you want to build, inference, plotting, etc.

You can easily install and initialize the library in a project with only lines of code: first, you need to install Libra and all the dependencies in your environment with pip install libra . Next, simply write from libra import client in a Python file and you’re all set!

II. Interesting Features

Photo by Tim Mossholder on Unsplash

The first interesting feature I noticed is that some “queries” try to infer what is asked of them: for example, if you call a neural_network_query(), the only required argument is a quick explanation of what you want to do, like “please model the median number of households”.

The target variable in your data will then be determined through the parsing of your explanation and computing the levenshtein distance on the column names.

Kind of cool, right?

Moreover, you can simply load your .csv data file and it will automatically be handled in a Pandas DataFrame and preprocessed for you during the query, which is convenient if you want fast results!

The fact that Libra relies on other machine learning libraries means that all ML tasks are virtually doable. Here is a list of the currently available queries, and includes Feedforward NN, CNN, SVM, Text generation, Sentiment analysis, etc.

When you fine tune a model in with the Libra client, the evaluation results and plots are automatically displayed for you. Here is an example where I tried to predict sentiment scores of tweets from this Kaggle dataset using a simple neural network:

The project is growing pretty fast and even though the core development has been done, you can put your skills to use and contribute by adding missing bits of code and correcting bugs!

III. Downsides

Photo by Bernard Hermant on Unsplash

The major downside you will experience with an ML framework that is so beginner-friendly is process over-simplification: by providing such high-level wrapping techniques, you sort of lose the sense of control over what is happening.

For example, when using the “neural network query”, the number of distinct target variables in your data will determine if a classification or regression task will be performed, and you will not have a choice in the neural net’s architecture details.

As of today (August 2020), Libra is still being developed by the creators and the community, meaning that a lot of bugs appear here and there, which can be discouraging at first.

Even though Libra is a relatively new machine learning framework, it hasn’t (yet) re-invented the wheel, and relies on popular libraries like Keras, Transformers, Scikit-learn and NLTK. This mainly means that the number of hard dependencies is quite high, and can be an issue if you like to keep a light environment.

IV. Simple Project Example

To show you how easy and fun it is to use Libra, let’s implement a small project together: based on the beginning of J.R.R Tolkien’s Silmarillion, we will generate new text with only 3 lines of code.

Libra will load GPT-2 from OpenAI and generate new text for us.

In the following Gist, the first line is actually the input file I fed the network with. All the rest was automatically output by the model, and it’s pretty amazing!

The model probably was pre-trained on the entire book, but the output grammar and generation relevance is nonetheless very good.