How to build VennLit App for comparing lists in Python using Streamlit
Key Takeaways
The video demonstrates how to build the VennLit App for comparing lists in Python using Streamlit, a web application framework, and matplotlib library for creating Venn diagrams. It showcases the app's capabilities in determining important features for classification projects and drug discovery.
Full Transcript
welcome back to the data professor youtube channel in this video i'm going to show you how you could create the event lit web application in python using the streamlight library and so if you're wondering what this application is capable of let's say that you want to compare the elements that are inside two or three lists of values in your data science project for example if you have two classes that are being used for classification you want to figure out which features are important for each of the two classes that you want to classify or if you're building a bioinformatics prediction model for example for drug discovery you want to figure out which molecular features are important for a molecule being active and which are important for a molecule being inactive or those features that have no influence at all on the bioactivity values and so this particular application will help you to determine that and so let's get started all right and so let's get started in building the van lit streamlit application so first thing is to load up your code editor of choice and then you want to load in the codes provided in the github repo mentioned in the video description so at a high level here we have a total of approximately 137 lines of code and so before going further let me show you how the application looks like so we're going to run it by typing in streamlet run trimlet underscore app.py enter wait a moment all right and therefore the application is loaded let me minimize this and so this is the event lid application so what it allows you to do is create a vans diagram so here's the option for which you could choose whether to have advanced diagram that compares between two lists or three lists so at default it's going to select two lists and so let me show you how to use this we're going to minimize that and then we're going to type in the elements for example we have two lists right so the first list will be containing the following numbers one two three four five enter and then the second list we're going to have it overlap at number four five six seven eight enter and then we're going to call it the first list to be list a and the second list to be list b hit on enter and that's all so you get a vans diagram showing the overlap between the two lists list a and list b which has an overlap of two numbers and there are three numbers in list a that are not found in list b and there are three that are found in list b but not in a right so which numbers are found in both lists so you guessed it numbers four and five right four and five are found in both lists so let's have a look we have a header here saying list info and if we click on common elements we're going to see how many elements are in common between the two lists which is two which is the number here and which elements are in common so we see that numbers four and five are common right numbers four and five are common between the two lists and how about the unique numbers in list one or list a here the unique numbers is numbers one two three and in list b the unique numbers is six seven eight and you could also download this particular data in the three csv files here you could click on list one csv which will contain the elements in list number one which is here four five two one three so the numbers are not sorted you could feel free to modify the code so that all of the results are sorted and this list two and then we have the common elements let's have a look the common elements four and five and so let's have a look at the three list comparison so here we have three lists let's say that we want to have number four five to be common and then we're going to have numbers 9 10 and 11 and we're going to call this list c and now we have the advanced diagram for the three list number that are in common there will be two elements that are in common we can see here that there are no elements that are in common between two of the list but only between the three lists so common size is here common number two so feel free to figure out how to find other common elements in the other regions of the vents diagram such as the one here here and here and feel free to share the code to your implementation you could think of this as a sort of an exercise for which to practice and so let's go back to the code so you can see here that we import the necessary libraries in the first four lines of code so we have streamlit which is the web framework we import matplotlib.pyplot as plt and the vans diagram here are created using the matplotlib underscore event library and then they have the van2 and event3 functions and we also import pandas as pd so line number six will essentially print the header of the application called vent lit which is shown here and we use the emoji of this red circle and then we have an expander which contains information about the web application where we could click on it and then that will allow it to expand and if we click on it again it will hide and collapse let's have a look the navigation on the sidebar is shown here and so we use the radio button to allow the user to select between two lists or three lists and then if the user selects on the to list it will do the following from lines number 24 until lines number 97 and if we select the three list it will perform functions on lines 1 1 until lines 137 and so in both two lists and three lists we're going to use essentially the same logic and so i'm going to explain the logic for the two lists and then the same thing applies for the three list let's have a look so lines 24 so if the radio button is selected here to be two lists it will implement the following code statements so here we have st sub header to be input which is right here and let me minimize this a bit and then and as you can see here we've created two columns using the st.columns function and then we assigned it to code 1 and code 2. and then the contents of the first column will be the list box here tests the st.text area and then we call it list one which is right here and then we use the split function so that it will split each of the elements here into an individual element as part of a list and then we have the list one name which is right here to type in the name of the list using the st.text input function and then the same thing is provided on column two and here we use a conditional statement that if the list 1 and list 2 are not empty then we're going to do the following we're going to print out the output subheader and then we're going to create the plots using the matplotlib function to create the placeholder to the plot and then we're going to use the van2 function to create the advanced diagram and as input argument here we're going to apply the set function to list1 and set function to list2 so that the common elements will be able to be figured out and then the name of the list that are displayed here are provided here list1 name and list2 name and then finally we use the matplotlib functions to display the figure and then we're going to assign the placeholder of the figure and the fake variable inside as input argument to the st pi plot function so that the figure here is shown in the application and now we're going to compute some information about the common elements and the unique elements of the venn's diagram so the common elements here will be figured out by using the set function dot intersection of this one and two and then we're going to reassign the following as a list to the same variable name and then we're going to figure out the length of the elements so how many number of elements are in the list so this will tell us the size of the common right here and the number is two and elements as four and five and here we will create a button called common elements which is the one shown here and if we click on the common elements button it will display the following information which is shown here and then we're going to figure out the list difference between one and two and we're going to figure out the unique elements for list a and the unique elements for list b which are provided here and then we create two additional buttons called list one and list two which is here and the same logic applies if we click on the button for list one information of list one will appear which will be information about the unique elements of list one and if list two is clicked then it will display the information about the list too and then right here line number 78 we're going to have the download data subheader displayed here and then we have the download data function which will essentially take the data of the list and it's going to repackage it so that we're able to use it here for downloading the data of list one list two and also the common elements and so when we load the application for the first time no data is provided here and therefore it will satisfy the condition for else and it will say enter data to proceed which is right here and so we apply the same logic for comparison of the two lists for comparison of the three lists and instead of two columns we have three columns as shown here three columns and here same thing it will check whether we have already populated the boxes here the input boxes if we have already populated then it's going to do the following functions and it's going to create the advanced diagram using the event 3 function of the matplotlib van library and the same functionality will be performed so feel free to customize this particular application with other data of the common elements for each of the three lists so let me show you some of the use case that you could do for this particular application let's say we have two lists right remember the bioinformatics from scratch tutorial that i have so typically we wanted to predict whether a molecule is active or inactive and for molecules belonging to the active class and for those molecule belonging to the inactive class we wanted to see is there any common molecular fingerprints or features that are in common between molecules that are inactive and molecules that are active well for example if we have fingerprints or features we could type it in here in list one and list two so that we see which one are specific to actives and which one are specific to inactives let me show you so i have two lists i will call it active and inactive and the list one will contain the list of fingerprint names or the feature names let's call it feature 001 feature 002. and imagine you have thousands or hundreds of these features and i'm going to customize the number here and then there you go so we have three common features then we have two that are unique to the active and to the inactive so which are unique to the active will mean that the features here are important for a molecule being active and the features that are present in the inactive means that it is essential for a molecule being inactive and features that are provided in both it doesn't affect the activity of the molecules so this is a particular use case that you could apply to your own data science projects to figure out which features or fingerprints that are important for the class that you are predicting and so i'd love to hear from you how you intend to apply this particular ventlet application to your own data science project and so drop it down in the comments section thank you for watching until the end of the video if you reach this far in the video please drop a book emoji and while you're at it smash the like button subscribe if you haven't already hit on notifications so that you'll be notified of the next video and as always the best way to learn data science is to do data science and please enjoy the journey
Original Description
In this video, we're going to build the VennLit App for comparing lists via a Venn diagram in Python using Streamlit.
🔗 GitHub https://github.com/dataprofessor/vennlit
🔗 Demo App https://share.streamlit.io/dataprofessor/vennlit
Support my work:
👪 Join as Channel Member:
https://www.youtube.com/channel/UCV8e2g4IWQqK71bbzGDEI4Q/join
✉️ Newsletter http://newsletter.dataprofessor.org
📖 Join Medium to Read my Blogs https://data-professor.medium.com/membership
☕ Buy me a coffee https://www.buymeacoffee.com/dataprofessor
Recommended Resources
📚 Books https://kit.co/dataprofessor
😎 Taro (Tech Career Mentorship) https://www.jointaro.com/r/dataprofessor/
📜 Google Data Analytics Professional Certificate https://imp.i384100.net/google-data-analytics
🤔 Interview Query https://www.interviewquery.com/?ref=dataprofessor
🖥️ Stock photos, graphics and videos used on this channel https://1.envato.market/c/2346717/628379/4662
Subscribe:
🌟 Coding Professor https://www.youtube.com/channel/UCJzlfIoF8nmWqJIv_iWQVRw?sub_confirmation=1
🌟 Data Professor https://www.youtube.com/dataprofessor?sub_confirmation=1
Disclaimer:
Recommended books and tools are affiliate links that gives me a portion of sales at no cost to you, which will contribute to the improvement of this channel's contents.
#datascience #machinelearning #dataprofessor
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from Data Professor · Data Professor · 0 of 60
← Previous
Next →
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
How a Biologist became a Data Scientist
Data Professor
WEKA Tutorial #1.1 - How to Build a Data Mining Model from Scratch
Data Professor
WEKA Tutorial #1.2 - How to Build a Data Mining Model from Scratch
Data Professor
WEKA Tutorial #1.3 - How to Build a Data Mining Model from Scratch
Data Professor
Computational Drug Discovery: Machine Learning for Making Sense of Big Data in Drug Discovery
Data Professor
Quotes #1 on Big Data and Data Science
Data Professor
Quotes #2 on Big Data and Data Science
Data Professor
Quotes #3 on Big Data and Data Science
Data Professor
Quotes #4 on Big Data and Data Science
Data Professor
Quotes #5 on Big Data and Data Science
Data Professor
Data Science 101: Starting a Data Science / Data Mining Project
Data Professor
Data Science 101: CRISP-DM - Data Mining / Data Science in 6 Steps
Data Professor
R Programming 101: How to Define Variables
Data Professor
R Programming 101: Read and Write CSV files
Data Professor
Data Science 101: Basic Command-Line for Data Science
Data Professor
Strategies for Learning Data Science in 2020 (Data Science 101)
Data Professor
Building your Data Science Portfolio with GitHub (Data Science 101)
Data Professor
R Programming 101: Setting up R programming environment (R, RStudio and RStudio.cloud)
Data Professor
Exploratory Data Analysis in R: Towards Data Understanding
Data Professor
Exploratory Data Analysis in R: Quick Dive into Data Visualization
Data Professor
Machine Learning in R: Building a Classification Model
Data Professor
Machine Learning in R: Repurpose Machine Learning Code for New Data
Data Professor
Data Science 101: Deploying your Machine Learning Model
Data Professor
Machine Learning in R: Deploy Machine Learning Model using RDS
Data Professor
Data Pre-processing in R: Handling Missing Data
Data Professor
Machine Learning in R: Speed up Model Building with Parallel Computing
Data Professor
Data Science 101: Overview of Machine Learning Model Building Process
Data Professor
Web Apps in R: Building your First Web Application in R | Shiny Tutorial Ep 1
Data Professor
Web Apps in R: Build Interactive Histogram Web Application in R | Shiny Tutorial Ep 2
Data Professor
Web Apps in R: Building Data-Driven Web Application in R | Shiny Tutorial Ep 3
Data Professor
Web Apps in R: Building the Machine Learning Web Application in R | Shiny Tutorial Ep 4
Data Professor
Web Apps in R: Build BMI Calculator web application in R for health monitoring | Shiny Tutorial Ep 5
Data Professor
Machine Learning in R: Building a Linear Regression Model
Data Professor
What programming language to learn for Data Science? R versus Python
Data Professor
How to Become a Data Scientist (Learning Path and Skill Sets Needed)
Data Professor
Using Python in R
Data Professor
Interpretable Machine Learning Models
Data Professor
Making Scatter Plots in R [Data Visualisation in R series]
Data Professor
Machine Learning in Python: Building a Classification Model
Data Professor
Compare Machine Learning Classifiers in Python
Data Professor
Hyperparameter Tuning of Machine Learning Model in Python
Data Professor
Practical Introduction to Google Colab for Data Science
Data Professor
File Handling in Google Colab for Data Science
Data Professor
Pandas for Data Science: Create and Combine DataFrames / Rename Columns
Data Professor
Machine Learning in Python: Building a Linear Regression Model
Data Professor
Machine Learning in Python: Principal Component Analysis (PCA) for Handling High-Dimensional Data
Data Professor
How to Plot an ROC Curve in Python | Machine Learning in Python
Data Professor
Installing conda on Google Colab for Data Science
Data Professor
Use native R on Google Colab for Data Science
Data Professor
How to Save and Download files from Google Colab
Data Professor
Easy Web Scraping in Python using Pandas for Data Science
Data Professor
Data Science for Computational Drug Discovery using Python (Part 1)
Data Professor
Pandas Profiling for Data Science (Quick and Easy Exploratory Data Analysis)
Data Professor
Exploratory Data Analysis in Python using pandas
Data Professor
Quick tour of PyCaret (a low-code machine learning library in Python)
Data Professor
How to Upload Files to Google Colab
Data Professor
How to Install and Use Pandas Profiling on Google Colab
Data Professor
How to Adjust the Style of Pandas DataFrame
Data Professor
How to use Bamboolib for Data Wrangling in Data Science
Data Professor
How to use Pandas Profiling on Kaggle
Data Professor
More on: Prompt Craft
View skill →Related Reads
📰
📰
📰
📰
Are You Realizing The Power Of Your Archived Customer Data?
Forbes Innovation
5 SQL queries every data analyst ends up googling
Dev.to · sofrito
Du Navigateur à la Base de Données : Le Chemin le Plus Court pour les Tableaux Web
Dev.to · circobit
The Future of Experimentation: Predictive, Ethical and Autonomous
Medium · Data Science
🎓
Tutor Explanation
DeepCamp AI