How to Build a Streamlit App (Beginner level Streamlit tutorial) - Part 1

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey what's up everyone today i want to show you how to build a front end for your data science project using this awesome tool that i found called streamlight so stream math is basically like i don't know what you call it an api or maybe a library where you it's just very easy to write some python code and they took care of everything you just need to call some very simple functions to show things on a web page so let me show you some examples here for example someone built uh interactive code 19 dashboard with streamlid everything you see here is basically part of streamlet there is not much extra customization or anything done so you know there is a sidebar that you can pop in and out that's also built in uh you can decide the user or not there's sections you can show plot so this looks like it's more of like a um visualization sort of application you can also get input from the user let's look at another one you can have 3d um graphs 3d plots you know very interactive plots and yeah you can you know you can again get some input from the user and change your visualizations accordingly but you can also showcase the machine learning algorithms that you built because it's just it just works using python it's very simple in that sense so let's get started i'll show you how to do uh build a front end for your data science project under an hour it might even be under half an hour to be honest it's pretty simple to set up so the first thing that we want to do is just create a folder for your project so what i'm going to do i'm going to call this my awesome streamlet front end and in there i'm just going to create a folder where i can put my data and i'll just fire up sublime and here just for now i'm going to say import streamlight but we first also need to install streamlight so i'm just writing stuff down to save my project okay so once i have this what i want to do is to install streamlet so i will start my terminal how you install streaming is using pip so you have to make sure that you have pip installed on your computer as far as i know python if you already have python your computer python comes with pip so you don't have to do anything extra but if you just google installing pip on your computer this should be pretty straightforward so once you do that all you need is pip streamlet or install streamlet and yeah now i have streaming on my computer uh how can you check this you can do this you can set up python on your terminal and then say uh import streamlet and if there are no errors nothing that means that you have streamlight on your computer now but before going further and actually starting to build our front end i think it's a very good idea to write it down on a piece of paper and imagine what you want it to look like because if you just start typing things just start coding things you might want to change them in the future it might get very complicated so i prefer first writing it down on paper and here is my design that i made for this application so basically what i have is i first want to have a title and under that i want to do an explanation of what what is this project about why did i choose to do it and then i will have a small section about the data set that i found where did i find it just general information about the data set and maybe some plots maybe some histograms showing the distribution of the data set and then i want to have a section where i talk about the features that i came up with during future engineering then i can do a little list where i explained the different features that i found and finally i will have a model training section with some input from the user i would like to have a slider where people can choose the max depth that the model should have and then a drop down menu where they can choose a number of estimators that my random forest should have and maybe also i'll give them a list of features and tell them to select one of the features to use as an input to my model and then on the column next to it i want to show the model performance using different metrics so this is the plan that i have and i think the best thing to do first is to create the containers that i want to have so how do we do containers in streamlit this is something that was very recently uh published actually very recently launched before that there were no options to do this but what you do is basically so there are two things in streamlight you have containers and you have columns containers create sections in a horizontal way and columns create sections in a vertical way so that you can have two things next to each other so that's pretty neat again you can still have the sidebar but i don't want to have the sidebar for this project i just want to use the whole width of the page and to do that so first let's let's first create the container so i would like to have a header container it's very simple to create something extremely so i imported streamlight before what i'm going to say is import stream it as sd so i don't have to write stream every time so i'll just do streamlet so st dot beta container and it basically creates a container now i have a container called header and what i'm going to do is next i want to talk about my data sets i'm going to say data set sd beta container and next i have the features section and finally i have model training and that's it basically uh now they are created but we don't have anything in them so maybe before we run our project for the first time i can write something so to write something inside the header or inside a certain container what we have to do is just say with the name of the container and that's all and you just of course have to make sure of the indentation and you can then write whatever you want so i'm going to say sd so streamlight title i'm going to say welcome to [Music] my awesome data science project and that's all i save and now i'm going to run this project and then we can see how it looks let's get out of this one okay um right now i'm there i just need to go to desktop and my awesome stream front end and then i will say streamlet run main.pi because that's the name of my python file and it's ready here so let's see oh i wrote this wrong i guess should be lowercase title that will do yeah now i have my uh first thing there i have my first title so from now on we can already actually start to organize our code i will say my data set section i have my features section and finally i have my modal training section actually i'm going to change the name to be a bit better like this okay so now that we have it let's maybe create the titles that i wanted to so um title is the biggest thing on the app so you should only have it once so this will be like a title of the page and next time you want to create a title for different sections what you should use is streamled heather yes and what i'm going to say here is the name of the data set today i'm using the new york city taxi data set so i will just say new york city taxi data set and i will say here the features i created and then same here it will just say time to train model okay and we can also just add some text and this text will be in a very small font it's just for descriptions and what i can say is in this project i look into the trends um you can you can write more descriptions as as long as you want it and then i will say where i found this data set and whatever information that you want to give about it uh features will have a list where i describe things and here i also want to have some description okay so now i save this my app is still running what i can do is actually go here and then choose on a toast either rerun or always rerun if you say always rerun every time you make a change it's going to rerun if you don't say that you're going to have to click rerun again so i'm just going to say always rerun and there we have it we have the first title we have different sections and we have some of the descriptions here so that's great the next thing that i want to do is actually bring in my data and start visualizing my data but let's do this in the next video thanks for watching the video i hope you enjoyed it and if you liked the video don't forget to give it a like and even maybe subscribe because i'm more or less here every week i'm trying to bring you the content about becoming a data scientist and don't forget to also go check out my website so you want to be a data scientist.com there i share weekly articles i have a podcast where i interview other data scientists and data professionals and i have free and paid resources i have courses on data science both for understanding where you want to go with data science and also getting practical hands-on experience on data science i mean that's actually the name of my course hands-on data science so go and check those out and i'll see you around
Info
Channel: Mısra Turp
Views: 21,440
Rating: 4.9691834 out of 5
Keywords:
Id: -IM3531b1XU
Channel Id: undefined
Length: 11min 27sec (687 seconds)
Published: Sun Dec 13 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.