Package: juvini
JUVINIA Comprehensive graphing tool for EDA. Like a profiler using Graphs.To install the package :pip install juviniIntroductionRequirementUsageBest PracticesIntroductionPlotting graphs are one of the most important aspects of EDA. Graphs give intuitive insights because it is processed by our natural neural networks trained and evolved non stop for years. This tool is designed to allow data science users to work on plotting the graphs rather than spending time on codes to do it. This tool has several levels. Highest level is where the user just have to input the entire data frame and the code will take care of giving all plots based on the data type for all combinations. Just like the way pairplot works for numerical datatypes.RequirementUser should have some idea on python. This can be run from jupyter as well as python consoleShould have good understanding of different graph types especially boxplot , scatterplot , barplot , countplot and distplotThis is not a must , but if the user has a clear understanding of the datatype associated with each column , then converting to the datatype will make the graph look better. For eg , if a column contains categorical value 1,2,3,4. Then it is better to convert it as object or category so that the tool will be able to guess it. Else it will assume the datatype as numeric and will plot for numeric related graphs.Note that there is feature within the juvini that will automatically consider a numeric column as category if the unique values in it are less than 5The tool will always treat first column as X axis , second input column as Y axis and if parameterhue_colis specified then it will search for this column on rest of the dataframe.Usageconsider the standard IRIS dataset.Here we modified it a bit to add a numeric column rating where values are 0.1.2.3. Even though it is categorical , we have purposely kept it as numerical column to show some use cases that will come in later sections.
It consists of 5 columnssepal_length - numericsepal_width - numericpetal_length - numericpetal_width - numericspecies - categoricalrating - numeric ( in fact it is categorical in real scenario )Sample outputsepal_length,sepal_width,petal_length,petal_width,species,rating5.1,3.5,1.4,0.2,setosa,14.9,3.0,1.4,0.2,setosa,14.7,3.2,1.3,0.2,setosa,04.6,3.1,1.5,0.2,setosa,35.0,3.6,1.4,0.2,setosa,05.4,3.9,1.7,0.4,setosa,14.6,3.4,1.4,0.3,setosa,35.0,3.4,1.5,0.2,setosa,04.4,2.9,1.4,0.2,setosa,14.9,3.1,1.5,0.1,setosa,15.4,3.7,1.5,0.2,setosa,0NUMERIC vs NUMERIC - to plot graph where two columns are numeric.Method :num_num(df[[num_col1,num_col2]])Examplessimple numeric to numeric plottingimportpandasaspdfromjuviniimportnum_numdf=pd.read_csv('iris_with_rating.csv')num_num(df[['sepal_length','sepal_width']])Truewait what if i want to add a hue parameter to it?
Just make sure to add the additional columnspeciesto the input dataframe and also add the parameterhue_col='species'num_num(df[['sepal_length','sepal_width','species']],hue_col='species')Trueadditional parametersx_name='xvalue' , the name that you want in x axis for the first column , sometimes the column name are different from the name you want to see in the graph.By default the first column name is takeny_name='yvalue' , same as x_name , but for Y axissize_figure=(13,4) , for playing around with the size. depending on size of the screen you may want to  change it. default is 13,4 with tight layouthue_cols , to plot the hue. See the above exampleCATEGORICAL vs CATEGORICAL - to plot graph where two columns that are categorical.Method :cat_cat(df[[cat_col1,cat_col2]])ExamplesThis will take the top 5 categories for each column and plot it. You can change this value 5 using parametersxcapandycapas mentioned below.
For each value of X , it will give the countplot for values in Y.
Also the tool will take care of all subplots and figure size etc. User do not have to figure out the sizing and subplot grid size.importpandasaspdfromjuviniimportcat_catdf=pd.read_csv('iris_with_rating.csv')cat_cat(df[['species','rating']])Truesimilarly interchanging first and second column will change the axiscat_cat(df[['rating','species']])cat_cat(df[['rating','species']])TrueBut wait , did we just use a numerical column to plot a categorical column?
Actually yes , if we know that it is categorical , we do not have to change the datatype and all unnecessary things. the code will take care of converting it to category.Fine , but what if there are too many categories and i simply need to have a gist of top few categories?
Yes that is also supported , simply provide the parameterxcap=<value>, the code will sort the categories based on its count and choose the top n values based on the input.additional parametersx_name='xvalue' , the name that you want in x axis for the first column , sometimes the column name are different from the name you want to see in the graph.By default the first column name is takeny_name='yvalue' , same as x_name , but for Y axissize_figure=(13,4) , for playing around with the size. depending on size of the screen you may want to  change it. default is 13,4 with tight layoutxcap=5 , will cap the maximum categories with top 5 based on its count for x axis 1st column , default 5ycap=5 , same as xcap , but will be applicable to y column.hue_cols , to plot the hue. See the above examplescols=3 , this is an experimental feature , use with caution. This parameter will control how many plots in one row. By default it is 3others=True , this is an experimental feature , use with caution. This parameter will put all the other values that are not coming in the top values provided into a category called 'restall'CATEGORICAL vs NUMERICAL - to plot graph where two columns where x is category and y is numeric.Method :cat_num(df[[cat_col1,num_col2]])ExamplesThis will take the top 5 categories of categorical column and plot numerical. You can change this value 5 using parametersxcapandycapas mentioned below.
For each value of X , it will give the boxplot corresponding to the numerical column in that. Additionally it will also give aggregate sum of the numerical values for each category.It is upto the user to decide which is useful. Boxplot is always useful , whereas the sum aggregate might help if you are looking at something like total votes etc. but if it is like sepal_width kind , then it may not be useful.Anyways no harm in giving both.importpandasaspdfromjuviniimportcat_numdf=pd.read_csv('iris_with_rating.csv')cat_num(df[['species','petal_length']])TrueCan we use a numerical column to plot a categorical column?
Actually yes , if we know that it is categorical , we do not have to change the datatype and all unnecessary things. the code will take care of converting it to category as long as you provide the column as first column in the inputFine , but what if there are too many categories and i simply need to have a gist of top few categories?
Yes that is also supported , simply provide the parameterxcap=<value>, the code will sort the categories based on its count and choose the top n values based on the input.How about the hue?
Yes , that also will work here. provide it likecat_num(df[['species','petal_length','rating']],hue_col='rating')Trueadditional parametersx_name='xvalue' , the name that you want in x axis for the first column , sometimes the column name are different from the name you want to see in the graph.By default the first column name is takeny_name='yvalue' , same as x_name , but for Y axissize_figure=(13,4) , for playing around with the size. depending on size of the screen you may want to  change it. default is 13,4 with tight layoutxcap=5 , will cap the maximum categories with top 5 based on its count for x axis 1st column , default 5hue_cols , to plot the hue. See the above exampleothers=True , this is an experimental feature , use with caution. This parameter will put all the other values that are not coming in the top values provided into a category called 'restall'. There are ratings 0-3. If we cap it to only top 2. Then the rest of the ratings will go into "restall" value.cat_num(df[['rating','petal_length']],xcap=2,others=True)TrueSingle NUMERICAL - to plot graph with just a numerical columnMethod :single_num(df[[num_col1]])ExamplesIt is not always the case that plot will need two columns. What if i just need to see a boxplot of a numeric column or the distribution of a numeric column?
For that we have the method which will give boxplot and distplot. It is usually used with the hue to give more insightsimportpandasaspdfromjuviniimportsingle_numdf=pd.read_csv('iris_with_rating.csv')single_num(df[['sepal_length']])TrueHow about the hue?
Yes , that also will work here. provide it likesingle_num(df[['sepal_length','species']],hue_col='species')Trueadditional parametersx_name='xvalue' , the name that you want in x axis for the first column , sometimes the column name are different from the name you want to see in the graph.By default the first column name is takensize_figure=(13,4) , for playing around with the size. depending on size of the screen you may want to  change it. default is 13,4 with tight layouthue_cols , to plot the hue. See the above exampleSingle CATEGORICAL - to plot graph with just a categorical columnMethod :single_cat(df[[cat_col1]])ExamplesIt is not always the case that plot will need two columns. What if i just need to see a boxplot of a categorical column or the distribution of a numeric column?
For that we have the method which will give boxplot and distplot. It is usually used with the hue to give more insightsimportpandasaspdfromjuviniimportsingle_catdf=pd.read_csv('iris_with_rating.csv')single_cat(df[['species']])TrueCan we use a numerical column to plot a categorical column?
Actually yes , if we know that it is categorical , we do not have to change the datatype and all unnecessary things. the code will take care of converting it to category as long as you provide the column as first column in the inputFine , but what if there are too many categories and i simply need to have a gist of top few categories?
Yes that is also supported , simply provide the parameterxcap=<value>, the code will sort the categories based on its count and choose the top n values based on the input.single_cat(df[['species']],xcap=2)TrueFine , what if i want to change not the xcap but the ycap?
Yes we can do that as well. Simply change the parameterycap=<value>just like the xcap.How about the hue?
Yes , that also will work here. provide it likesingle_cat(df[['species','hue_column']],hue_col='hue_column)single_cat(df[['species','rating']],hue_col='rating')Trueadditional parametersx_name='xvalue' , the name that you want in x axis for the first column , sometimes the column name are different from the name you want to see in the graph.By default the first column name is takensize_figure=(13,4) , for playing around with the size. depending on size of the screen you may want to  change it. default is 13,4 with tight layouthue_cols , to plot the hue. See the above examplexcap=5 , will cap the maximum categories with top 5 based on its count for x axis 1st column , default 5To make it more easierMethod :xy_autoplot(df[[col1,col2]])ExamplesWhat if i do not even care what the data type is. I just want the code to decide it based on the data type already present.Can i do that?Yes. There is a method which does exactly this. You will have to simply give two columns. The first column will be taken as X variable and second as Y variable. And based on the data type it will provide you the necessary graph.importpandasaspdfromjuviniimportxy_auto_plotdf=pd.read_csv('iris_with_rating.csv')xy_auto_plot(df[['sepal_length','species']])TrueDoes it support hue?
Yes , you can use the same parameterhue_col=<colname>and if the graph can handle hue , then it will use it.xy_auto_plot(df[['sepal_length','species']],hue='rating')Truecat_num(df[['rating','sepal_length']])TrueStill better and most comfortableMethod :juvini_profile(df[[list_of_cols]])ExamplesThis is the highest of all that combines all below features and give the entire story in a matter of one command.importpandasaspdfromjuviniimportjuvini_profiledf=pd.read_csv('iris_with_rating.csv')juvini_profile(df,hue_col='species')Numerical columns: ['sepal_length', 'sepal_width', 'petal_length', 'petal_width', 'rating']
Categorical columns: []
Analysis of numeric sepal_length and numeric sepal_lengthAnalysis of numeric sepal_length and numeric sepal_widthAnalysis of numeric sepal_length and numeric petal_lengthAnalysis of numeric sepal_length and numeric petal_widthAnalysis of numeric sepal_length and numeric ratingAnalysis of numeric sepal_width and numeric sepal_widthAnalysis of numeric sepal_width and numeric petal_lengthAnalysis of numeric sepal_width and numeric petal_widthAnalysis of numeric sepal_width and numeric ratingAnalysis of numeric petal_length and numeric petal_lengthAnalysis of numeric petal_length and numeric petal_widthAnalysis of numeric petal_length and numeric ratingAnalysis of numeric petal_width and numeric petal_widthAnalysis of numeric petal_width and numeric ratingAnalysis of numeric rating and numeric ratingTrueAn easier way to get the only related graphs to the dependent variableIn many cases we may not need all sorts of graph but rather interested in seeing the graph related to the target variable, to do use the featurejuvini_against_target(df[col_list],target_col=<target_variable>)importpandasaspdfromjuviniimportjuvini_profiledf=pd.read_csv('iris_with_rating.csv')juvini_against_target(df,target_col='species')