How to Build Your First Data Science Web App in Python - Streamlit Tutorial #1

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments

There's also a somewhat equivalent package to this for R users. The package is called Shiny.

👍︎︎ 3 👤︎︎ u/kids_eat_drugs 📅︎︎ Jun 09 2020 🗫︎ replies

Nice tutorial

👍︎︎ 2 👤︎︎ u/Nasroodotcom 📅︎︎ Jun 09 2020 🗫︎ replies
Captions
have you ever wanted to build a data-driven web application for your data science projects but perhaps you might be intimidated by the difficulty of coding in Django or in flask if you answered one or all of the above then you want to watch this video to the end because I'm gonna show you how you could build a data-driven web application in just a few lines of code and so without further ado let's get started so the name of the Python library that allows you to build a simple data-driven web application is called streamlet actually this Python library was brought to my attention by one of the subscriber of this YouTube channel so please give a big hand to Iqbal for recommending this excellent Python library that will allow you to develop a simple data-driven web application for your data science project and so the first thing that you want to do is head over to the streamlet website by typing in streamlet io and so i'm gonna provide you the link in the description of this video so this is the website of streamlet and as you will see it says that it is the fastest way to build a data application and so here you can see that you could build a OpenCV web application from within streamlet and you could add a lot of interactive elements as well so in order to get started you want to install stream lid and so you could do that by typing in pip install streamlet and after the installation process is finished you could type in streamlet hello in order to check that it has successfully been installed and as you can see here a simple web application could be built in just a few lines of code and you will see in this second example that you could also add widgets to the web application as well and so this slider widget will allow you to select numbers just by sliding the slider bar and in this third example here you could deploy your web application easily using git and there you have it a minimal framework for building a powerful web application while just requiring you just a few lines of code and so here are some of the gallery of web application built using streamlet so let's have a look at the gallery okay so this awesome web application using tensorflow was built in streamlet and there are other awesome examples of streamlet applications that were built by the user community and so here are just a selection of these so if you have built a web application using swim lint you could also share it via Twitter and the streamlet web site will be showcasing your web application in this gallery page so you can see here that a wide variety of web applications have been built using swim live okay so now that we have a brief introduction about streamlet let's have a look at how we can build one for ourselves okay so the first thing that you want to do is fire up your terminal so if you're using a Microsoft Windows you want to type in the search bar CMD and then you will see a terminal prompt coming up and in this terminal prompt you want to type in pip install and then stream live and then hit enter and since I have already installed streamlet so I'm gonna proceed with showing you how you can build the application so I install streamlet inside the Conda environment and so I want to activate my environment by typing in Conda activate DP I've created a Python file called my app py and the contents of the file is shown here so you can see that it is approximately 20 lines of code so if you deduct the empty spaces then it should be less than 20 lines of code and so aside from installing streamlet in this example you also want to install y finance so you could type in pip install Y finance ok and after you have done so then you want to type the following lines of code in but for your convenience I'm gonna share you the link to this file on the data professor github so you want to check in the description of this video and download this file ok so the first 3 lines of code are just simply importing the Y finance as YF import streamlet SST import pandas as PD and then this block of code we're going to write the header of the web application so as you will see here that this is in markdown language and with the hash tag here it is indicating that this line is a heading type 1 so it's gonna be a big text and then it's going to be an ordinary text saying shown are the stop closing price and volume of Google and then here in this blocks of code I've taken from the towards data science article so you want to check that already go out and give this article a clap and so I extracted some lines from this article and so this line of code will be the ticker symbol of Google and so it is goog l and then in this line of code we're gonna take in the ticker symbol of Google and so we're gonna retrieve historical data of Google stock price with a period set at one day and the starting date is May 31st 2010 with a ending date of May 31st 2020 and then we're gonna save this into the ticker data frame and then the contents of this data frame will comprise of the following columns open high low close volume dividends and stop splits okay so in this web application we're going to show you two line chart and we're gonna show the closing price and also the volume okay and so this is a very simple web application and you could customize this to your own liking so I'm gonna show you that we could also edit the contents of the file and the web application will be serving the updated version in real time all right so let's type in CD desktop because this file is on the desktop and then I'm gonna type in stream lip run and then the name of the application which is my app py enter and that's it okay so it's gonna spawn up a web server and this is what you're gonna see a simple stock price application so let me show you side by side the code and the application all right here so here the simple stock price up here is the heading and since it is one hash tag it means that it is having the heading one style each one in HTML language but if we have two then it will be a bit smaller so let's save it and then it detects that the source file has changed and then we should select always with run and then we should select always to rerun and so it's gonna update to be a bit smaller as you will see here and if I add additional hash tag and save it it will be even smaller game so I'm gonna change it back to one hash tag and so it is heading one let me try okay so let's maybe modify this a bit in markdown manner so closing price I'm gonna make a bold volume I'm gonna make it bold and in italic see so you could customize the style in markdown style so you want to refer to the markdown cheat sheets and I think this is a good one to refer to so the markdown cheat sheets by Adam Pritchard and it has everything that you would ever wanted to know about markdown alright so you could ask cool stuff in here you could add less unordered lists you could add links you could add images you could add tables okay like for example let me copy this and then I'm gonna just put it here all right so it's the table okay very neat right okay but let's delete it for simplicity so the ticker symbol is Google so we can even customize the ticker symbol to be other values as well so let's say a a pl for Apple save it and then this is the price for Apple so I could update this like that okay as you can see it will update automatically to the website okay so this is the date range that are shown in this line chart and this is the actual line chart so if I wanted to delete one of them and then save it then only one will be shown okay and let's say that I want to write something in okay so I'm gonna write here the heading one closing price maybe make it heading - all right and I'm gonna do the same for the volume as you will see this is the customized version okay so if you zoom in zoom out you could even do that as well this is a interactive charts and if you want to zoom to the original version you would just double click on it right same thing here just double click on it and it'll go to the original state and so there you have it a data-driven web application in just a few lines of code and if you're finding value in this video please give it a thumbs up and subscribe if you haven't yet done so and hit on a notification bell in order to be notified as soon as a new video has been released and as always the best way to learn data science is to do that of science and please enjoy the journey thank you for watching please like subscribe and share and I'll see you in the next one but in the meantime please check out these videos
Info
Channel: Data Professor
Views: 171,232
Rating: 4.9562659 out of 5
Keywords: Data Professor, data science, machine learning, streamlit, build web app with python, build data apps, build data app with python, model deployment machine learning, simple web app using python, streamlit python, streamlit tutorial, build a data science web app with streamlit and python, how to use streamlit, machine learning streamlit, machine learning web app, deploy machine learning, deploy data science, python web app, web app python, how to streamlit
Id: ZZ4B0QUHuNc
Channel Id: undefined
Length: 10min 56sec (656 seconds)
Published: Sat Jun 06 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.