Using chatGPT to build a Machine Learning Web App in Python!

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments

To the OP and others posting videos with no explanation: please put in the effort to write a comment describing the content of your video so folks can quickly determine whether it is worth their time to click the play button. For now, we will let these posts stand; as the community grows, at some point we may have to start removing low effort posts like this.
Also for now, I won’t click the play button without some compelling comments; and I will downvote your post.

👍︎︎ 3 👤︎︎ u/BroadbandEng 📅︎︎ Jan 12 2023 🗫︎ replies
Captions
hey guys I'm avru and welcome back to my YouTube channel so this is another video on uh coding during the holiday session where we try to use a chat GPT which helps us to build web applications using streamlit right so this is something which I started in the last video and I'll be continuing as long as this holiday session goes on or maybe the weekends and it's more about building web apps where we try to understand the basics of it mainly using a streamlit and also why not use this powerful AI chat GPT which is crazy okay it is very powerful actual charge if it will help us to understand the code and we'll ask chat GPT we'll do the another main part out here is to how to use the charge if it is prompt to have the answer which we need in our debugging or let's say while adding new features to our web app so all this purpose will use chat GPT it's more like uh the fundamentals which you will roam around because LGBT gives explanation to each and every part of the code so in the last video when we were going through where we built something where we built a dashboard or we did an exploratory data analysis we use that gb10 we were successfully building that expiry data analysis app and we deployed it also in the streamlit cloud right uh we'll just quickly go through it this is the GitHub repository can go there you'll find all the overlaps which will build is entire GPT and also uh you will file the codes out there okay and we built this particular web app so this particular web app which is more about let me drag this thing but also you know in this whole course we will I will try to edit the my videos as less as possible because it's a holiday time and I really want to make it it's more of a raw version okay so this is the way up which we built in the last video it it shows it takes some data so and it tries to take the eyes data set by the way and then it tries to visualize the data using various plots here's the data frame there's a histogram plots all this recorded this is the code which we used all these codes were supplied by that activity okay we debuggles a few parts few tricks here and there let's say we can also make some interaction out here which we put it set to limit we see the changes happen there is a pair plot typical export digital analysis of the ielt data set and yeah that's it I mean we have commercial metrics box plot if we just press this button another widget of streamlit which helps us to plot something right now in this plot so like there are different types of which is okay the more we do the more we come across this widgets and we here we have the violin plot we can make all these changes and we can interact with this app so it's a typical expedited analysis which you deployed by the way you can get this you can access the uh this particular app using this URL holiday coding sessions not streamlit DOT app okay you can also go to this uh this particular GitHub repository here you will find uh the code the requirements file the requirement file was also created by chat GPT and uh we'll also find the app here just click here and go to that by the way I have also decided to write down few stuff in the medium blog post where you can also check how this map was built all this conversation between the prompt the user the right now I'm the user out here I have also put that the prompt and also the out from output from the LGBT that's also very uh crucial in our case so I am kind of having a written note of it also also published this this is in a draft preparation this is for the previous video I'll publish that also over medium so you can go to my uh medium page right here and more or less I have written down out here you can check all this medium post my YouTube channel where I've made a lot of extremely tutorials right so and also I'm also working with opener in our days so always is out there check it out let me know how how it goes and also if there is something bug or something report that cool so we are done with this part previous part quick recap and now let's come to today's part what we will build is we will build a machine learning web app today let's try out let's see how it works perfect so once I'm here I will not give some keywords this is the most important part one thing I have seen when I was playing around with chat GPT the important part is you have to be very careful with the keywords which you put in your prompt okay that's something very important so the keywords need to be very specific so that you actually understand what you want from it you know at the end of the day it's a powerful AI but we need to feed it properly okay so that's also one of this uh whole videos learning curve for me for I think for everyone how to feed the information to charge GPT so it gives us a relevant information to us the feedback to us which will be essentially very useful for us okay to build an app or debug our code or any other purposes so let's say today we want to build a machine learning load up using stream lead how can I write that field a stream lead machine learning way back using the python packages so we'll use the python packages we will use scikit-learn you know that's a very common python package which is available I mean I think I'll just open it here the psychic learn it's very commonly used uh scikit learn let's say we use pandas or you know dealing with the data sets and all these transponders is very crucial and also we use let's say C bone plus they also use C bone and plotting today with c bond for you know get the visualization part C board and of course we stream it I'm writing everything explicitly the packages which I need foreign also the benign tumor we can do we can have this classification of this random classifier model classified between the benign and malignant tumors using the random Forest classifier okay so this is our prompt which we will put in now which will fit into our uh AI or rgbt3 Ai and I'll run it now let's see what it gives us I'm expecting you to give us a whole process how to install everything that's the power okay that's where charging works amazingly for someone who when we are learning charge if it is the best way to learn the coding part okay and as you see it started with the necessary package to install so it started from how to install the psychic learn the pandas receive on the stimulate and the next part which is doing is importing so this is the first part here we just press enter all this packages will be installed okay so I won't be showing that part now uh but you can just click this thing okay peep install psyche learn Panda c bond streamlip it will be installed if you're in Windows you can just use a Windows Powershell and you just write this pip install or you can just use your you know git bash that also works pretty well in Windows in Mac OS you just need your uh need your terminal that's it and then you just use peep install the next thing which it says it's it's about importing the packages which is very useful because the package which you need to use in Python we need to import that so how can we do that we use import stream lead St Escalon this is a random first classifier which I explicitly mentioned to use the breast cancer data set again it has used it so it has followed all my commands in the prompt right that's why we need to use the keyword we feed it in the fill in our prompt and then we get the output as we need so what I will do is I will just copy this part I use vs code this was the previous part of the code which we have used what we will do now is we will create a streamit multi-page web app okay all this time our web app has only one page if I go to aware app it has only one page right I just want now a multi-page web app so how we're gonna do that extremely if you want to do that it's very essential to know we create a new folder called as Pages if I'm not wrong I think it's pages and we will just say email ml app maybe that's something we need machine learning app dot Pi okay so you have to create this machine learning.app you can just give any name however you want to okay once that part is done a new script file is open and I just paste it here okay so let's see if it works or not I really forgot if it's Pages or page it's something like that uh the pages this allows you to create a multi-page so I will use a very typical streamlined syntax which is called St dot data frame so I zoomed in a bit St dot data frame and we put DF inside okay and this is our Command Prompt I just pulled everything from the GitHub now the quality coding session your repository I'll clean it first and now I say streamlit run let's I will say streamlit app dot Pi so this is my student app.pi okay once I click this uh we will open in a local host let's see if that works well or not so it's opening a local host [Music] okay so that's the pages okay that's the folder name so this is a previous uh previous videos the entire app okay it's opening out here right and if I go to ml app now this is the app which we'll be building today uh what we did was we loaded this thing and then we will get the data frame we expect in data frame and I know why it's not still working let me also now hide this particular uh this this particular bar out here okay so that we see the code well I will first make this so I'll show you how wise treatment is so powerful because it's a real-time update so I press so it's not saved yet so I'll just save it now Ctrl s i press always run here if the code simple is right we see the whole data frame out here you see that so our first few lines of code we already have the data frame out there it was super easy so let me go a line by line so we imported all the packages here right and we loaded the breast cancer data set which is an inbuilt data set uh you within the within the scikit learn if I'm not wrong yeah that's all the SQL package from the data set we already imported this module and then we have X and Y which is basically you know we need to have the features and the target that's why we kept that way and now we create a data frame out of it using the pandas module which we imported here and we then dump our data frame in our app it's very simple right so this all was suggested by the chat GPT that's pretty cool right so once we have this part done it's working pretty well so let's go back to uh chat GPT again so I'll just move it here so let's see so once we do this part igp to say next you can visualize the data so cool okay why not we visualize our data app I don't know if this will work or not we copy the code we just make a pair plot so I'll just come in this part I'll just appear plot maybe I can put the terminal down because we don't need this terminal that much now good and I paste this code here and let's see if we can plot our Target out there or not okay it's a plot we are trying to solve so I understand why the paper is it's it's not working well I get in this error the runtime digital engineer so let me come in this part let's see if without pair plot we'll try it without visualizing it we will try to do it uh let's let's try to let's try to go to the next part of the code so many columns and rows it's kind of a lot of it that's something which is not working well so I'll just rather comment this part and the next part of the code which is our main aim to build or train a random Forest classifier right we take this part of the code and I run it here I fit it so basically we're calling the classifier that particular object you can say in that way and then we have the random forest classifier and then we just fit X and Y okay once we have that part we will use few of the streamlined widget so we just copy this part of the code to already fit our train our model out here right and then I will paste this part of the code so I copy it and I paste right and once we do that we're expecting a lot of stream mid widget to come up so I paste the always Siri run button out here and we already get a lot of stream bit widgets so this is happening because of this few lines of the code where we create slider every time so this is the slider which we're creating and this has a random value so because this part of the code is trying to take the user input in order to fit our trained model okay and uh our trained model has a lot of columns it's not only this five column that's why we get this particular error that X has five speech features but random for this classifier is expecting 30 features as input so now we cannot go on and put in each and every column name out here right that is like a lot of work so maybe we can ask chat GPT to Loop over all these columns and uh get the mean and the max or we can just get the maximum of it so that you know because the slider has the minimum value and the maximum value okay and we need to have a uh drag in between them in that way it will be easier for us not to write each and every slider so let us charge GPD to do that [Music] so I'm asking now to attribute to Loop over each and everything and to see if we can do this part we are hard coding so it again created the sidebar here and now it is looping over the column and it is trying to get the Minima and the Maxima of it and also the mean of it I'm I'm expecting the mean will be as the value the value of the default value and the Minima and the Maxima will be will be the the minimum value of the slide the maximum value of the slider so basically this has a minimum value if you see the minimum value out here is something open so it's basically zero the maximum value is 20 which is hard coding okay we don't want that part so let's use this few lines of code I like this part of code so I remove this part also we have we have established the train model here already I paste it here and let's see how it gives us now should be running the whole thing that's a default workflow of streamlit it runs from the very top of the script and we already get an error out here says num 5.64 error I think it's because slider value it has to be either in float or in integer all of them as float okay because here we have most of them as fluids we it's better if we Define them here [Music] so we have this part solved now we have all our features all the features that is available in our data set as a slider in the slide there is a value which is a default value there will be a mean value there is also the max value value okay so that's why we have this uh mean Max and the mean now we got another error out here which is numpy 64 which is coming from clf predict uh I think we need to whatever we get from this Loop we store into store that Loop and then we need to fill it in the predict to get a result oh yeah I think that's how we need to do it maybe we can ask we can actually ask that GPT to do that from Slider we need to store the value okay whatever the user gives it [Music] and we'll try to save it okay so I don't know if this will work well or not uh let's see let's try this part of the code and I don't know if this part will work well and then it uses user input dot append I would rather go in this way like you know user input and then I would go I will obtain make the painting to make it much more let's say we put input like this say slider input and then I would uh obtain this user input don't update this part I will use in this way okay you should put a paint and then I yeah maybe yeah let's do that maybe we will try to get the issue input in this way and a slider this thing I will put it inside that print okay and uh yeah and let's print yeah and then I will try to fill it here but I still think it won't work well because whatever is coming or will be a two-dimensional vampire if I'm not wrong after appending we need to reshape this part of code so I will now keep chat GPT this thing I will just give this part of the code here like this what I have modified and I'll ask chapter to you know work on this part okay yeah so I think it should use an Empire method to to to come to reshape it okay from One D from 2D to One D I think that should be something useful I think that child should go but we are strategy okay let's see what it does oh it's working oh cool it is working that's it perfect that's it so it's working pretty well now if I make a change out here anything whatever you can make a change out here you see it's from malignant to benign it went if I change here it is malignant so you see any change in the user interface from your front-end users there will be a change in your app that's the coolest part okay and I would change this as let's say let's I will make it kind of a markdown this is something which you can use markdown syntax which you use for your readme files GitHub it's very much useful in in our stream lead you know that's something new that's what I also wanted to add here markdown and I do it this way so you see the the way this is the header 2 we can also make header three if you want that's how you can do it or you can just put SD success or something whole idea of it it's working now okay we are we could establish an uh app where we are training with our data set and then uh input from the user end we'll create a difference in our prediction so it's basically checking with it and then the user change the imprint shows if it will be a malignant or a benign tumor that's the power of the front end which has been established here right now and we can play with it more and we can get these values okay okay so what else do you want to add into this let's say we want this uh this Roc curve all this thing we want that uh let's see can you give the accuracy model let's see if it remembers from where we left it okay so this is very powerful inside GPD by the way it remembers the first time what you have used out there okay that's something with the new features which came I think two weeks back these things were not saved beforehand so it remembers it remembers the context from where I was uh discussed uh we were discussing with that okay so other way which we could have also have done it is using this what tragically suggesting us here we can make this train test split up for data right uh that's also very useful to do or maybe here we are doing it right now here like this uh we can actually use this lines of code let's see whatever charge you between 3 has given us we'll put this thing here okay train test speed we have X and Y uh cool and when we have our prediction out here yeah so let's let's try this part of line and let's see how it gives us out here so we have an accuracy of 0.96 so that's something which we made beforehand okay what that jibino suggested us okay that's pretty cool and next we also have all this uh kind of a widget which you can control and Define a power or tumor malignant or benign okay these things will change whenever we make any changes out here you see the whole app will rerun and it will change according to that another thing which you also want to add foreign [Music] [Music] here it is we just need to copy and paste this part of the code we can do it at the end also okay it doesn't matter plot the ROC curve and here it is we have our Roc curve out there cool right we have a lot of features out here maybe we can also ask for what we could we fail to do out here it's the the pair plot right foreign features instead so let's ask for the first 10 features okay I think that's something which is not working well maybe it's a lot of columns so we stick to the first 10 features and let's see if it can charge GPD help us to make a pre-approve the first 10 features uh that's something will be not necessary to understand if the the air is because of this huge amount of data which shouldn't be or it's just because of the some there is some error within it or not [Music] so let's see if it can do with this few lines of the code the whole data frame now we will use only the first standard and now I'm I'll just reload okay just to ensure that it's not running what we left it back so if you see I get this error every time okay key error Target so this is something I will ask charge GPT and let's see if we can create a tag this error can be fixed or not so it's taking the 11th column achieve that will solve the whole case so I press always redone and it's re-running again but I get the same error so I give again the errors to persist give me another alternative right so we get a new [Music] okay [Music] throwing the same error so let's see oh I see I see so it has now converted to list let's respect charge if it is confidence and we try it again oh let's see something is happening now okay so this is not a huge issue I think I know why I'm not asking Chad Jeopardy now but we know import we have done it last video also matplot late as PLT okay to do anything I hope this is working okay if this works it's pretty good I mean he gave us a solution even after facing a couple of bugs right that's the power of 10 GB which I which we always want to leverage right so let's see if it works or not then you will get a nice spare plot it's very nice to see look at this this is pretty cool right so this is something which I wanted for a long time to do since it runs like every part of this code again from the very top that's why we see this lagging time it takes a bit more time that's why you can imagine why in the beginning it didn't work because it was trying to plot all of them right now it plotted how many so if I want to three four five six seven eight nine ten that made a lot of time okay that's something uh sadly I don't know I mean we haven't tried it maybe I could debug it or you guys can try it and let me know in the comment section how we can fasten this process so that's something took quite a long time if we Zoom it we have all the features out here I think I have to zoom in to see which feature is going okay so this is the main radius all this thing is plotted the first 10 if I'm not wrong in our code the first 10 is plotted after a lot of trial and error but charging Beauty did it for us okay so I'm happy that this worked until now okay so well we have created a machine learning app we have have seen a lot of features out here where the the front end user can interact we can play with these features but again this part will take a bit more time and actually use a stream with a session state to store this output that's how you can make this app run pretty faster but your user can play with all these features we use chat GP to get this out we use a for Loop using chat GPT let's not forget that part you get the accuracy level of this you make a very nice plot out here of your Roc curve what we did with chat GPT it's pretty cool right and next part one thing maybe which we should try okay we copy this entire line of codes and we ask chargpt remove this part of the code now our app literally has shouldn't have anything I just saved this part you see your app is blank this is the previous app which we used for a previous day check this video out uh it's about creating a Exquisite analysis today we are trying to create a machine learning app which has our breast cancer data set it's trying to build a classifier a random Forest classified model that's been used and we asked everything using chat GPT and now we are asking child GPT make a very nice code block out of it you see it is doing it very properly it's splitting the data sets it's writing the comments very properly very delicately right so I'll just copy and paste once it is done ready for us I will save this part and now if we see the whole app is running from the first part of the code first line of record about deploying this app in the server once we do that we can see it right uh maybe we need to add oh I see so we need to add one more thing which you forgot this will show us an error because we did add the requirements uh packages we update that so it extremely so three months so let's go here as you know extremely automatically push or put everything from the GitHub so as you can see it's already out there now Street meter this is the main app which is holiday coding sessions or streamlit.app it shows some error because of SQL okay so I'll paste it here let's see if any of the C born panda streamlit stream it okay we want to use as I said in the previous video we don't use this is the name of the version explicitly because we'll use the latest version so we don't care about that so the site you learn is added and now we use we see this error is there but that will also go away I think this is the main file out here uh so main app out here that was the local file which is no more existing because I have stopped the local server the in the main app we see this error this can only go away once we uh make a good push again foreign [Music] dependencies again because whenever there's a requirements file change it should be automatically also install the dependency that's why it takes a bit of time it is now on the server you all can access this app right my other videos on stream lead I have a streamlined tutorial already up there uh that's and also you can check other videos from my oh did I get an error out here oh I know why this error comes up it's mainly because of this part which we used in our previous app I haven't written it there so let me also fix this thing okay we did in the previous app also the same thing when we get this warning message out here anyway so this will get automatically restarted so yeah check out my other blogs out here which I'm also writing this blog about how I created the streamlit web app for the expression rate app using uh that's the main idea of it uh we I have a Blog out here uh GitHub repository which I am maintaining for my YouTube videos you can go there we will start if you like that repository so this is the repository for the YouTube tutorials here you can find a lot of way to uh tutorials on stream lead uh open AI all this stuff out there some python automation will Google that's everything is out there very well organized so make sure to check them out and also I'll be happy to receive your comments your feedbacks on we can make more of this holiday session app which we would really like to uh kind of Leverage chat gpt3 extremely to the basic control basic syntax you see today we made a multi-bit stupid app it's more of this basic syntax which will be very useful for all of us it's a learning curve for all of us during this holiday coding session give a long video but it's very useful for us and in that way we learn both using chat GPT 3 how to use the prompt how to use the basic stimulate syntax and also used to deploy the machine learning app all with a very less amount of very least amount of uncut of the video I will try to uncut as much as less as possible because I'm also in the holiday session now and I really don't want to work much in video editing so that's why we do it like this maybe during again a weekend we can also continue so that's all for today let me know what all you want to know in the comment section back about stream lead open AI about the charge GPT I'll be happy to make more videos on it let me know your feedbacks and share this video like this video And subscribe to my channel cheers
Info
Channel: Avra
Views: 7,873
Rating: undefined out of 5
Keywords: chat gpt, chat gpt coding, openai, open ai chat gtp, streamlit, streamlit tutorial, streamlit dashboard, streamlit python, python for beginners, python web development, python web app, gpt 3, gpt 4, chat gpt explained, chat gpt for beginners, chat gpt use cases, chatgpt explained, gpt 3 demo, openai api, machine lear, machine learning tutorial, machine learning projects in python, machine learning, artificial intelligence, machine learning python, machine learning projects
Id: LgdMhDqj77c
Channel Id: undefined
Length: 32min 55sec (1975 seconds)
Published: Tue Jan 03 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.