Create a complex Machine Learning model in one line with Libra
One-liner modeling query for non-expert usage
One-liner modeling query for non-expert usage
In recent times, there are many explosion of data-related projects, especially the one that using machine learning as the backbone. In the business industry projects, many machine learning is applied to create a prediction model (predict occurrences, churns, fraud, etc.).
The problem with all of the machine learning is that we need to learn the complex codes, and the result sometimes is too complicated for the non-expert.
For a reason above, now there is present a machine learning python package for non-expert called Libra. The premise of this package is straightforward: They prioritize ease of use and ergonomics; means creating a machine learning model in the fewest lines as possible.
Libra
So, what exactly is this Libra package? According to their statement, it is a machine learning API to let us build and deploy machine learning in just one line of code. How neat is that!
Moreover, Target detection, preprocessing, and scoring are done by default. What we only need to do is selecting the model and input the data.
Let’s just try how it works.
Before we are installing our Libra package, we need to have Python 3.6 version or higher installed. Anything lower than that would not work. To install the package, we just need to run the following code in the command prompt.
pip install libra
After you have done installing the package, we would try how is the package works. Let’s set up all the necessary things we would use. First, for the purpose of our learning, I would use the dataset from Kaggle about education here. The following image is the data information.
Now, let’s say that we want to create a prediction model to classify the Class columns. Using Libra, it makes all things easier.
#The only thing we need to import
from libra import client
In Libra, the dataset is still needed to be read from the external; say, CSV files. That is why we would create a client class that reads the file directly.
#Creating a client object that read the data to create the prediction model
edu_client = client('xAPI-Edu-Data.csv')
The above codes are all we need; The next part is more like querying the model in the way that we want and get the result immediately.
Currently, the only machine learning model present in Libra is:
Neural Network
Convolutional Neural Network
Support Vector Machine
Nearest Neighbors
Decision Tree
K-Means Clustering
And several Natural Language Processing, including:
Text Classification
Document Summarization
Image Caption Generation
Although, for our case, we only would try using the Neural Network model. Let’s try to create the prediction model then. In order to create a prediction model, we need to call the machine learning we want from the client method.
In our example, it would be .neural_network_query
accepting a text in the parameter. The query we pass is a simple English text, such as ‘classify the class’ or ‘estimate accurately the StudentAbsenceDays’. What is important is the target column; you need to specify it in the query. After that, the API would predict whether it is a classification or regression problem. Let’s see in the example below.
#Creating the model by simple query, for example classify the class. Using Libra, you would need to specify which column you want as the target and the rest would be preprocessed automatically
edu_client.neural_network_query('classify the class')
Just using a simple query, the model is preprocessed automatically, and the learning process is initiated. Furthermore, all the repetition processes and the metrics also present immediately.
Additionally, the model presents us with the accuracy and model loss plot during each epoch.
If you want to know all the parameters you could pass in the model, please consult the API guide here.
Libra also provides a more in-depth analysis of the model. We could access the analysis by running the following code.
edu_client.analyze()
Above, we get the Overall metrics, including the ROC curve and the confusion matrix. With this, we can analyze our model quicker.
Conclusion
In this article, I have outline how we could use Libra to create a machine learning prediction in just one model. Almost all the tedious parts are done by the API, and we only need to see the result.
It doesn’t mean that it could replace data understanding and feature engineering, as the main part of the API here is to create a machine learning model, not creating new features.
I hope it helps!