Machine Learning is a part of Artificial Intelligence, which consists of algorithms and improving automatically with time. In order to apply machine learning to different datasets, we need to clean the data and prepare it for the machine learning phase. Also, we need to identify the data or problem whether it is Regression, Classification, etc.
There are many machine learning algorithms that we can use for our prediction, regression, classification, etc. problems. But we need to call them individually and pass our data into them as parameters. It is very difficult to try different algorithms and choose the one which has the highest accuracy and lowest error.
Autogluon is an open-source python library that automates the whole process of machine learning and helps in achieving high accuracy. It automatically trains and predicts the models in just a single line of code. It works on different types of datasets i.e. Tabular, Image, Text, etc.
In this article, we will explore how Autogluon can be used to train a model that is best for a given Tabular Dataset.
We will start by installing Autogluon using pip install mxnet autogluon.
- Importing Required Libraries
For loading the dataset we will be working on we need to import pandas and for machine learning algorithms we will import autogluon.
import pandas as pd
from autogluon import TabularPrediction as task
- Loading the Dataset
Here we will work with a dataset that contains different attributes from an Advertising department of an MNC, it contains attributes like Sales, TV, etc. In this dataset Sales is the target variable. We will split and store these datasets into test and train data.
- Machine Learning using Autogluon
Now as we have imported the dataset we require, we will apply our final step which is to use Autogluon for predictor and performance function. We will set labels as ‘Sales’ as it is our target variable. It will automatically detect which type of problem it is i.e. whether it is regression, classification, etc.
predictor = task.fit(train_data=df2, label='Sales')
It foes through different regression models which are the best ones and returns you the name of the different models which are used, their validation time, and also validation RMSE.
Now let us print the performance of the test data using the performance function and see what is the RMSE for the best-fitted model.
performance = predictor.evaluate(test_data)
Here we can see that the performance of the model is quite good as the error is quite low. We can save these models by explicitly providing the location to save or autogluon saves the model in the directory where it is running.
In this article, we saw how easily and effortlessly we created different models for tabular datasets and found out the best model for the given dataset. We also saw what is the performance of the model to verify whether it is the best model or not. Autogluon saves a lot of time by automating the whole process of machine learning.
If you loved this story, do join our Telegram Community.
Also, you can write for us and be one of the 500+ experts who have contributed stories at AIM. Share your nominations here.
An aspiring Data Scientist currently Pursuing MBA in Applied Data Science, with an Interest in the financial markets. I have experience in Data Analytics, Data Visualization, Machine Learning, Creating Dashboards and Writing articles related to Data Science.