Now Reading
How To Build Interactive EDA In 2 Lines Of Code Using Pywedge

How To Build Interactive EDA In 2 Lines Of Code Using Pywedge

Venkatesh Rengarajan
  • Pywedge make_charts module creates 29 interactive plots, manipulate them & spend your quality time to uncover the pattern in Charts! pip install pywedge

Download our Mobile App


Exploratory data analysis (EDA) through charts is a highly important task to be conducted while doing Machine Learning tasks. As the proverb says, a picture can speak a thousand words, the Charts conveys numerous patterns just by visualizing them, which can help an analyst in choosing appropriate data pre-processing/ hyperparameters in the further steps.

There are multiple types of charts & each one of them can convey a different meaning. At times, it can be a daunting effort to plot various types of charts. Here comes an idea of a package/library…



Pywedge-Make_charts preview GIF by the Author

Pywedge — Make_Charts:

Make_Charts is an EDA addition to the Pywedge package. Make_Charts intends to plot various plots in a single line of code so that the user can spend quality time uncovering the pattern in the data using charts.

Make_Charts plots the following 8 different interactive plots for the given dataset along with interactive axis selection widgets, each type of chart tab has 4 independent chart widgets in a 2×2 grid style for easy comparing & analyzing the variables.

1. Scatter Plot

2. Pie Chart


Stay Connected

Get the latest updates and relevant offers by sharing your email.

3. Bar Plot

4. Violin Plot

5. Box Plot

6. Distribution Plot

7. Histogram 

8. Correlation Plot

Pywedge

Pywedge is a pip installable python package that intends to,

  1. Make multiple charts in a single line of code, to enable the user to quickly read through the charts and can make informed choices in further pre-processing steps
  2. Quickly preprocess the data by taking the user’s preferred choice of pre-processing techniques
  3. Make a baseline model summary, which can return ten various baseline models, which can point the user to explore the best performing baseline model.

In this article, we will mainly focus on Pywedge-Make_Charts.

Make_Charts using Pywedge

Make_Chart is a newly added class to the Pywedge package. 

Step 1: Install pywedge package 

!pip install pywedge

Step 2: Importing pywedge module

import pywedge as pw

Step 3: Load the data frame.  

import pandas as pd
train = pd.read_csv(‘https://raw.githubusercontent.com/taknev83/datasets/master/HR_Employee_Attrition.csv’)

Step 4: Instantiate the Pywedge_Charts class, which takes the following inputs & returns the Charts widget

mc = pw.Pywedge_Charts(train, c=None, y = ‘Attrition’)

Inputs:

 1. Dataframe

 2. c = any redundant column to be removed (like ID column etc., at present supports a single column removal, the subsequent version will provision multiple column removal requirements)

 3. y = target column name as a string 

 Step 5: Call the make_charts method from the instantiated class, which renders the following charts widget. Please preview the below demo video. 

charts = mc.make_charts()

Pywedge-Make_charts demo video by the Author

Pywedge make_charts creates random samples of the given dataset & plots all the charts. With all these interactive charts, users can explore the data by manipulating and can make informed choices in pre-processing the data.

Thanks to Plotly, the individual charts can be downloaded as an image.  

See Also
AWS Launches AppFlow, A New Tool For Managing The Flow Of Data

Interactive Charts Dashboard

Creating an interactive chart dashboard with Pywedge-Make_Charts is easy with the help of Voila Gridstack. Thanks to Voila. Viola turns Jupyter notebook into a standalone web application and voila gridstack is a template for voila dashboard. When the pywedge is pip installed, voila & voila gridstack will be installed as a part of pywedge dependencies.

Please find below a GIF preview of creating a make_chart dashboard using Voila Gridstack.

Pywedge-Make_Charts Dashboard using Voila Gridstack — Demo GIF by the Author

For Voila Gridstack related troubleshooting, if any, please refer to voila documentation at https://github.com/voila-dashboards/voila-gridstack

A couple of Hacks

To have the charts rendered in an optimal view inside the Jupyter Notebook, the below hacks can be helpful,

  1. Toggle Scrolling:

The output window of Jupyter notebook truncates the output of make_charts which renders a small scrollable window to view the charts, which is difficult to view all the 2×2 chart grids. Please enable toggle output under the cell tab to view the entire 2×2 chart grid. 

Image by the Author

2. Increase the width size of the Jupyter Notebook cells:

To maximize the viewing of the 2×2 grid layout of make_charts, it would be better if the width of the Jupyter Notebook increased to 100%. This can be done by running the below code in Jupyter notebook,

from IPython.core.display import display, HTML
display(HTML(“<style>.container { width:100% !important; }</style>”))

Conclusion:

The objective of Pywedge-Make_Charts is to simplify the machine learning environment so that the user can spend quality time analyzing & interpreting the charts. 

Please find the PyPi & GitHub links of Pywedge below,

PyPi — https://pypi.org/project/pywedge/

GitHub — https://github.com/taknev83/pywedge

Demo Notebook with Colab link (please execute the colab file to render the chart widget) 

Please feel free to pip install pywedge & explore make_charts and for any suggestions or improvements, please feel free to drop a line on my LinkedIn page. If you like the Pywedge-Make_charts, please star the GitHub repo 🙂 A separate method to handle time series Charts & models is planned & under development in Pywedge. 

What Do You Think?

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.
What's Your Reaction?
Excited
9
Happy
6
In Love
1
Not Sure
0
Silly
2

Copyright Analytics India Magazine Pvt Ltd

Scroll To Top