AutoVIML: Automating Machine Learning | by Himanshu Sharma | Towards Data Science

Machine Learning provides the advantage of studying algorithms which improves automatically with experience. There are ’n’ numbers of machine learning algorithms and techniques and generally, we need to test most of them in order to find the best prediction model for our dataset which has the highest accuracy.
Most of the machine learning methods like regression techniques, classification techniques, and other models are defined in Sklearn but in order to select which technique is best for our problem statement or our dataset, we need to try out all these models along with hyperparameter tuning and find out the best performing model. This takes a lot of time and effort which can be reduced using a python package named AutoVIML.
AutoVIML is an open-source python package that makes machine learning easy. What it does is, it renders your data through different machine learning models and finds out the best model with the highest accuracy for a given dataset. There is no need to preprocess the dataset to pass it to AutoVIML it automatically cleans your data, helps you in classifying the variables, performs feature reduction, can handle data with different types of variables like text, number, date, etc in a single model.
In this article, we will see how we can use AutoVIML in order to reduce the time and effort we put to create machine learning models. We will see what are the different parameters which we use in AutoVIML and what changes they have on our prediction.
Like any other python library, we will use pip to install autoviml.
pip install autoviml
from autoviml.Auto_ViML import Auto_ViML
For exploring AutoVIML you can use any dataset, here I am going to use a Heart Disease-related dataset which you can download from Kaggle. This dataset contains different attributes and the target variable.
import pandas as pddf = pd.read_csv('heart_d.csv')df
Now let us understand how we use autoviml to make a prediction model using this dataset and what parameters are there in AutoVIML.
#Basic Example with all parametersmodel, features, trainm, testm = Auto_ViML(    train,    target,    test,    sample_submission,    hyper_param="GS",    feature_reduction=True,    scoring_parameter="weighted-f1",    KMeans_Featurizer=False,    Boosting_Flag=False,    Binning_Flag=False,    Add_Poly=False,    Stacking_Flag=False,    Imbalanced_Flag=False,    verbose=0,)
In the code above we can clearly see how to create the model using AutoVIML and what are the parameters, we can use. Now let us discuss what are these parameters in detail.
train: It should contain the location of your dataset or if you have loaded it in a dataframe then the name of the dataframe. In this article we have loaded it in a dataframe named ‘df’ so we will set is as ‘df’.target: It contains the name of the target variable. In our case, the target variable name is “TenYearCHD”.test: It contains the test dataset. We can also leave it blank like this “” if we do not have any test dataset so that it will split the train dataset int train and test.sample_submission: We will leave it empty so that it will automatically create submission in our local directory.hyper_param: We will randomized search cv because it is 3X faster than Grid Search CV. We need to set this as “RS”.feature_reduction: We will set this as true so that it will take into consideration the most important predictor variable for model creation.scoring_parameter: You can give your own parameter for scoring or otherwise it will assume appropriate according to the model. We will use “Weighted-f1” here.KMeans_featurizer: This should be true for linear and False for XGboost or random classifier because it can lead to overfitting.boosting_flag: Used for boosting. Here we will keep it as False.binning_flag: By default, it is False and can be set to True when we want to convert the top numeric variables into binned variables.add_poly: We will set it as false.stacking_flag: By default it is False. If set to True, it will add an additional feature which is derived from predictions of another model. We will keep it as False.Imbalanced_flag: It will check data imbalance if set to TRUE and will remove data imbalance using SMOTING technique.Verbose: Generally used to print the steps that are performed. We will set it as 3.
train: It should contain the location of your dataset or if you have loaded it in a dataframe then the name of the dataframe. In this article we have loaded it in a dataframe named ‘df’ so we will set is as ‘df’.
target: It contains the name of the target variable. In our case, the target variable name is “TenYearCHD”.
test: It contains the test dataset. We can also leave it blank like this “” if we do not have any test dataset so that it will split the train dataset int train and test.
sample_submission: We will leave it empty so that it will automatically create submission in our local directory.
hyper_param: We will randomized search cv because it is 3X faster than Grid Search CV. We need to set this as “RS”.
feature_reduction: We will set this as true so that it will take into consideration the most important predictor variable for model creation.
scoring_parameter: You can give your own parameter for scoring or otherwise it will assume appropriate according to the model. We will use “Weighted-f1” here.
KMeans_featurizer: This should be true for linear and False for XGboost or random classifier because it can lead to overfitting.
boosting_flag: Used for boosting. Here we will keep it as False.
binning_flag: By default, it is False and can be set to True when we want to convert the top numeric variables into binned variables.
add_poly: We will set it as false.
stacking_flag: By default it is False. If set to True, it will add an additional feature which is derived from predictions of another model. We will keep it as False.
Imbalanced_flag: It will check data imbalance if set to TRUE and will remove data imbalance using SMOTING technique.
Verbose: Generally used to print the steps that are performed. We will set it as 3.
Now let us use all these parameters for our dataset and create the best performing model with the highest accuracy using AutoVIML.
model, features, trainm, testm = Auto_ViML(    train=df,    target="TenYearCHD",    test="",    sample_submission="",    hyper_param="RS",    feature_reduction=True,    scoring_parameter="weighted-f1",    KMeans_Featurizer=False,    Boosting_Flag=True,    Binning_Flag=False,    Add_Poly=False,    Stacking_Flag=True,    Imbalanced_Flag=True,    verbose=3)
Let us analyze the output we got.
Data Analysis Part
Data Analysis Part
2. Data Cleaning and Feature Selection
3. Data Balancing and Model Creation
4. Classification Report and Confusion Matrix
5. Model Visualizations
6. Feature Importance and Predictive Probability
In the above set, we saw how AutoVIML handles the data, clean it, balance the outcome variable, and create the best model along with visualizations to get a better understanding.
Similarly, you can explore AutoVIML using different datasets and share your experiences in the responses to this article. AutoVIML is an easy way to create best performing Machine Learning models according to your dataset.
Thanks for reading! If you want to get in touch with me, feel free to reach me on hmix13@gmail.com or my LinkedIn Profile. You can view my Github profile for different data science projects and packages tutorial. Also, feel free to explore my profile and read different articles I have written related to Data Science.