Coding A Full Stock Prediction Tool By Prompt (Warp, Python, React)
Key Takeaways
This video demonstrates building a full stock prediction tool using PyTorch for model training, FastAPI for backend, React for frontend, and Docker with NGINX for deployment, all prompted by Warp.
Full Transcript
Today we're going to do something very interesting. We're going to build a stock prediction tool with a bunch of different technologies. We're going to train using PyTorch. We're going to have a backend written in Fast API, a front end written in React with TypeScript. We're going to have Docker, Docker Compose, we're going to have EngineX. We're going to deploy all of this. And we're going to do all of this by using warp, which is kind of like a coding assistant. And we're going to code this whole thing by prompt. Now, if you think that this means we're just going to prompt and that's it and it's going to work first try, that's not the case. What we're going to do is we're going to go through the full development process. Uh, and we're going to see that it's not enough to just write a prompt and expect everything to work. You still need to have knowledge. You still need to be competent. You still need to be a developer. But you will see how you can build powerful applications in a short amount of time using Warp in this video today. So, let us get right into it. It's not a game. It's a red. [Music] Now, let me give you a motivation up front. This is our final result. This is the result of the tutorial that you're about to watch. It's an AI stock prediction tool with a user interface. You can see here this is a React application. It has a fast API backend and it was trained using PyTorch, which we can also see here. And the basic idea is we provide a ticker symbol. We can choose from the popular ones here like Apple, Microsoft, Amazon, Tesla, Nvidia and so on. You can see here the predictions of the model. Of course, don't trust these predictions. This is just the model making a good guess or maybe a bad guess. I mean, we have quite high percentages here and of course you can improve that. But this is the application basically. We can also provide a custom symbol like GS for Goldman Sachs. Uh and it makes the predictions here. We can also clear the predictions. So it is a full web application, a front end, a back end, a training process. Also, even though I'm running this right now on local host, we're going to deploy this in the video. We're using Docker, Docker Compose, Engine X, and so on. So we have a full pipeline, and this is the tool that we're going to end up with. Of course, if you run this on your own, you're going to get a slightly different tool. Of course, you can customize this however you want, but that is the final result that we're going to create in this video today. All right. Right. So, what we're going to do in this video is going to be super interesting and quite different than what we do usually. We're going to go through the full process of developing and deploying an application. We're going to train a model. We're going to do data prep-processing. We're going to build a backend with fast API. We're going to build a front end with React and TypeScript. We're going to use engine X as a reverse proxy. We're going to use Docker with Compose for the containerization. And we're going to deploy all of that. So, we have a bunch of steps in here. And we're going to do all that by prompt. Now, by prompt doesn't mean that we're just going to type the prompt and everything is going to happen for us and that's the video. We have to actively be a part of the development, but this is a kind of new way of developing applications. You still need to be competent. You still need to know what you're doing. You still need to look at the stuff that's happening, but you can do it much quicker because you don't have to code anything yourself or everything yourself at least. So, what we're going to do is we're going to use a tool called Warp. and they are sponsoring this video, but you need to be aware of the fact that you don't have to pay anything if you want to follow along with this uh video today. So, you can just download it for free. You can use the free plan. If you go to pricing, you will see there's a free plan with 150 AI requests per month. So, you can do what we do in this video today without having to pay anything. You can download it for Linux, Mac, and Windows. And what Warp is is they are a full coding platform, or you could say a full coding assistant. Actually, I already have a video on this channel where I used warp before, and back then it was just a terminal with a bit of AI and autocomp completion. Today, it's more like a cursor or windsurerf alternative, you could say. So, it's a full-fledged um coding assistant coding platform. So, you can type commands, you can do autocompletion, but you can also just chat with it. You can give tasks to the agent, and it's going to do that um step by step. It's going to execute commands. It's going to write code. It's going to uh read error messages and correct stuff. So, this is quite powerful. And this is how we're going to build the application today. We're going to do prompting. Then, we're going to see what is happening. We're going to make decisions along the way. And all of this will be done blindly. So, I didn't prepare for this. I tried to play around with it. So, I'm familiar with the tool, but I haven't uh created any code that I'm going to copy now. So, I'm not going to like I do usually. I'm not going to just have a code on my second screen and try to reproduce it. I'm going to do this from scratch with you guys. We are probably going to encounter some problems and that's part of the process. So the process here is not providing a prompt and getting the perfect result. We have to somehow uh we have to sometimes go back say okay do this differently or actually this is not what I meant. We need to refine results and so on. And this is what we're going to do today. We're going to do coding by prompt with warp. So this is warp. You can download it install it on your system right now. Currently, at this point in time, this is Warp Preview, which means that I'm actually using not the stable version, but the preview version, which should however be the stable version when you're watching this. So, this is actually now more of an AI agent. You can see down here, this looks a lot like the coding platforms that you use in things like cursor or windsurf. And what we can do here is we can run basic commands. I'm right now in the tutorial directory. So, actually, I do have some stuff here already. So, let me get rid of all this. Um, we can run commands here like in any ordinary terminal. We have autocomp completion. But what we can also do is we can chat with the agent. We can say, "Hello, what's up?" And we're going to be able to chat with an AI agent here in the terminal, and it is going to execute commands for us if needed. And of course, we can approve them and see what's happening. So, what we're going to do is we're going to build a stock predictor uh application or a stock prediction application. Uh having said that, it's important to realize this is not uh or it's important to understand this is not something that you should actually be using in the markets. This is not going to predict the stock prices of tomorrow or of any day in the future. It's more like a coding exercise. It's interesting to look at. Maybe it can sometimes perform well, but you should not use this as uh a resource or as the basis for your decision-m in the markets. I'm not responsible for any of that. So, as a disclaimer here, this is not financial advice. This is just a project to learn uh coding and to see how we can build uh applications quickly using something like warp or using warp. Um so let us get started. What we're going to do here manually first of all is we're going to create a structure. So I'm going to say here make directory project to get some basic project uh structure here and then I'm going to create the directories training. This is the stuff that I already did before a little bit. So you can see that it gives me the suggestion already. So I'm creating here now training backend and front end. The idea is I want to have in training a script that trains a neural network in PyTorch to predict stock prices. Then this model should be exported. Then I want to take that use it in the back end which is going to be a fast API back end. Once the fast API backend works, I want to have a React front end that is a nice UI for using the back end. And then we're going to do all of the containerization and deployment stuff. So let us go into the training directory now. And here now we can just formulate a prompt. So we can say implement a Python script that trains an LSTM model to predict stock prices and exports the resulting model. Use PyTorch and Y Finance for this. Get the data for multiple companies for long enough time periods and then train the model on this data. This is not just for hobby project. Don't just implement a proof of concept. Use enough data. Pick intelligent hyperparameters. Use a good architecture. Engineer some features based on technical analysis etc. Make this effective. Make sure it works. Your output should be just a single Python script that does the training and exports the model to be used later on. Use UV init directory and then UV add to add dependencies if needed. So you can of course adjust this prompt to be whatever you want to do. Uh I'm now going to send this and hopefully it's going to do something reasonable. If not, we can intervene. So what you see right now it is uh is it tries to execute a command UV init. That makes a lot of sense. Let me just zoom in a little bit so you can see this UV init. So I can say now run. I approve of that. Then it's going to initialize in this directory now the environment. Then it's going to try to do another command. It's going to be torch torch vision torch audio y finance pandas numpy scikitlearn math. Seabour talib. Uh now I'm not sure why we need um let me just refine this here. So I can say make sure the script you are writing is only for training and exporting. No evaluation, no visualization, just train and export. So just in case it tried to do some evaluation here, we only want to do training and exporting. So maybe there you go. We don't need anything else. It now only has torch, y finance, pandas, numpy. So I could learn and talip which is for technical analysis. So right now I intervened because I realized okay matlip seabour this looks like something where it's trying to actually do some uh visualization stuff. I don't want to do that. So run this. Now this failed probably because of tip. Uh that's not very easy to implement. So it's going to try to do it uh manually. That's also fine. So now it doesn't use talip anymore. It just uses y finance, pandas, numpy, scikitlearn, and torch. And now it's going to write the code. All right. So it suggests this code here. We have a bunch of things here like technical indicators, SMA, EMA, so exponential moving average, simple moving average, uh relative strength index, MACD and so on, Ballinger bands. So we have some technical analysis here. We have some data preparation and then it also does some training. What's the architecture? We have an LSTM layer. We have attention. Um I mean it's just linear uh a linear layer. Here we have fully connected layers. Drop out batch normalization. All right. So it uses these symbols. Let's go and approve that. Let's apply the changes. And then it tells us it is done. So what we're going to do now to check if this worked is we're going to run it manually. So we're not going to instruct it to do that. We're going to do it manually. Uh, the reason I don't want to run this now is because if it gets into some interactive mode, I want to be able to interact with it. So, I'm going to cancel here and I'm just going to run it myself. And by the way, we also need to use UV since we cannot just use Python. We need to say UV run and then train LSTM model because we used UV for the environment. So, doing that should either work or give us an error message. Both is fine because in the case of an error message, we can also see that error message and uh, warp is going to react to it. So now it's processing the data. It got the sequence and the features and now we should be uh okay we got a problem. So what you can see right away I got an error message and here it's already generating a fix. So it already knows okay what's the problem? Remove the verbose keyword. Accept this change and then I can just run the same command again. Also I didn't look at the epochs. I of course don't want to let this run forever. So maybe we're going to have to adjust that. 100 epochs is maybe a little bit too long. Let's see how much how long an epoch is. Let's see if it works at all. We don't really get an output. Maybe there's nothing printed. So let's maybe stop that for a second and let's go into the code manually, which is the train LSTM or is it train LSTM? LSTM model py. Let's go to the epoch. So that is going to be epochs. Where is that defined or there you go 100? Let's go with 10. And then maybe do we have some printing here? We have just the every 10th epoch is printed. So let's in this case just say uh every epoch is printed. So let's just comment this out and let's move this to the left. So we should see every epoch. And then let's run the same uh command which is the UV run. All right. Now we can see some progress epoch one two. There you go. So training successful exporting uh these models here as PTH and as pickle files. So what we are going to do now is we're going to assume that the model understands what it did there and we're going to say build a fast API application around this and make it usable via uh fast API. So build a fast API application around it and make this accessible via an API. So our query here is going to be now go ahead and implement a fast API application around this. Use the backend directory for this. Use UV again for it. Make sure this application loads the exported model and serves predictions uh based on user requests. This will later on be used by a front end. So make sure you handle uh course properly. So you need to understand that this is necessary otherwise maybe it forgets about that. So you also need to still have the skills to understand okay this is going to be running in docker this is going to be interacting with a front end so we need to take care of certain things. Now let's just execute this and see what happens. Okay so what it does now is it explores the file system. It wants to see what's present here. So let's just allow it to run these commands here. Now it looks at the content of the Python file it wrote. So it takes that as context to understand what is happening. What does the input look like? And now it's going to build the same thing uh in in fast API. It's going to make it compatible. So what it does now after looking at all of this is it goes to the backend directory and initializes a new UV project. So we can say run. It then adds dependencies. We have fast API u uh torch scikitlearn pandas numpy pyantic y finance and python multipart. All of this makes sense. Urorn is for running this as a uh server properly. And so we can run that now. And now it creates the code for the application. There you go. We have a suggestion. This is the code. We have some logging in here. We have the model path. We have the technical indicators again. So this is of course necessary to be able to reproduce the same features for any new data. So this is a bit redundant, but we need that. We have the uh definition or the design of the neural network here again because we can only load the weights and we need to make sure that we have the structure still in the code. And then we should have some endpoints down here as well. We have some pideantic base models here. We have the application. We have the course middleware for the front-end interaction. And we have the endpoints. So let's approve that. Let's apply that. Now what it does is it suggests a bash script that is uh for running the server. We need to refine this because this doesn't make sense. First of all, I don't want to use a bash script. Second of all, you cannot just use VN. Or maybe we can. I'm not sure um if UV also allows using just VNF like this, but I want to cancel this. I don't want to allow this. I want to just run the server. So, let's see if that is possible by just running uh uvun main.py. If not, we're going to do fast API run or something like this. There you go. So, it starts that. Um maybe let's open this in the browser. We have here our API. I'm not sure what kind of endpoints we have. So maybe let me close that here for a second. U or maybe let's run this in the background by providing this and symbol here and let's go into the main.py. Let's see what kind of endpoints we have here. We have predict. So instead of just using it, what I'm going to do now is I'm going to instruct Warp to make a request. So make a request to the API to make sure it works properly. Predict stock prices. So I can close the browser here. We don't need that. What it does now is it goes to the back end and it tries to run the application. Uh I can say this is not necessary. Server is already running. So just make the request. It wants to check if the service is healthy. So let's run that. Perfect. So it does the prediction request and it should get some data as a result. There is an issue here with fetching data. So we're going to try something else. It makes some changes here to the code. So my approach with this so you understand this is I just unless I see something that is clearly wrong, I just apply the changes and hope that it works. If there is some problem and it doesn't work at the end, uh I will have to look into the code. So for right now, I'm just trusting it to read the error messages. We don't see every output here. But what warp sees is all the error messages that are the result of running these commands. And what it does then is it fixes them or tries to fix them and only if it fails to do that, I will reprompt or try to look at the code myself. Okay, so it says it found some issues with the feature engineering. So let's apply that as well. Okay. So, let me pause here because it seems to have a problem because the server is still running the old code. So, what I'm going to do is I'm going to get this into the foreground. I'm going to terminate this and I'm going to run this again uh of course in the background. So, we're going to do that. And and now try again. Server is restarted. Now, it reverses basically some of the stuff that it just did. So, maybe it's a bit confused, but maybe it's going to work. Let's see. Okay, so basically it reversed all the changes that we did before and now it's trying to increase the number of days that we use. Now the problem is the server again needs to be restarted. So let's go foreground terminate and then do the same thing and now say try again restarted the server. Okay, there you go. Now it says excellent the API is working perfectly. Let me test a few more stocks. And it seems to work now. So, it runs a bunch of curl requests here to do stock prediction for different stocks. And it seems to work. Uh, now we can also run this command here with popular symbols. Not sure what that's going to do, but it seems to work. So, everything that the assistant wrote seems to work. And the important thing is we're going to now connect this to a front end. So our philosophy here is going to be let's see what the result is and if there's problems we're going to look into the code or we're going to adjust it manually. So there you go. We have a summary here that's not too important. What we want to do now is we want to instruct it to build the front end to this backend. So what we do now is we say so now implement a react front end for this back end. do that in front end with vit use typescript also install tailwind and make sure you add all code services types components css etc to make the front end professional and modern looking this should look polished and impressive so I can just run this it wants to execute a command now the problem I think is going to be that this requires an interactive yes we can try to run it but I think it's going to get stuck because it requires a yes no actually it worked okay perfect so we can just run this then it goes into the front end and installs everything. And now it's probably going to mess this up because I don't know a single coding assistant that installs uh Tailwind properly when it comes to VIT. So this is not the correct way to do that. We don't want to do it that way. So I'm going to cancel because even if I try to reprompt it, it's not going to work most of the time. What I'm going to do is I'm going to go to the Vit docs and I'm going to type Tailwind. So I'm going to show you that here in a second. Uh and they have a guide. It's very simple actually to do. Uh, all we need to do is we need to run this command. npm install tailwind CSS. Tailwind CSS/V. This is what no coding assistant somehow manages to do. So, we're going to run that manually now. And then we're going to also configure the vitig. So, we're going to go into the vitig ts. And here we're going to say now import tailwind CSS. And also here we're going to write tailwind CSS and parenthesis. And finally we need to also do this import tailwind CSS in our index CSS. So this is going to be in source. I think there's the index CSS. We're going to put it here uh at the top like this. This is how you install Tailwind CSS uh in Vit or for a React project using Vit. All right, perfect. So what we want to do now is uh we want to continue. So I installed Tailwind manually. Continue with the request. Hopefully it knows what I'm talking about. It wants to use some additional packages here. That's fine. I'm going to just run this. Then it wants to create the API TypeScript file. So we're going to apply that. Then this is the service. So these are the functions interacting with the back end. Apply that too. Here we have some utility functions like formatting stuff. There we see now a problem. This is what always happens with Tailwind. I don't know why it always happens with Tailwind. It tries to use it in the wrong way. This is how you use it in Vit. So we need to do a refining here. But we need to say this is not how we do this in VIT. We need to use or maybe it's a Tailwind a Tailwind version difference here. I don't know. Uh we need to use import tailwind CSS. There you go. So it still uses that. It replaces a bunch of the code here. Let's apply that. And now it goes into writing the component. So we have here a spinner component. We have a stock card component, a stock search component, an error alert component, a health status component, and now the main app component. So the app tsx. Then it removes the CSS file. So the app CSS file, and it also updates the index html file. Then it creates some index.ts file for making imports easier. I'm not sure what this is about, but let's just accept that. And then it tried to create a readme file. I'm not sure if it succeeded, but that's not really necessary. And now it tries to do npm rundef. We're not going to do it here. So, I'm going to cancel and I'm going to run it myself. So, npm rundef. Let's see if that works. I would be surprised if it works first try. Uh, so I have a wide screen in my browser. This doesn't seem to work well. Let's see what the console says. We have the requested module doesn't provide an export named batch prediction request. So, I can just copy this. I can end this. I can paste this here and hopefully it can find a solution. So now it says it could be an issue with caching. Um, now I'm not a Typescript or React expert, but I'm not sure if that's the problem. So let's say refine. Uh, because I think I didn't look at the code, but often times what is messed up is that there's a type keyword that's missing. Um, let's say, are you sure that is the problem? I think it could be missing the type keyword. Now, I'm not sure if that's true. It's just an assumption. Yeah, but it seems to think that this is true. So, probably that is the issue. I think that is the issue, but I'm not entirely sure. So, it tries to do the same fix in app.tsx and in all the components. Now what you can do here theoretically I would not recommend this is you can click on this button um at the bottom right which says auto approve all agent actions for this task. This means that basically you don't have to uh accept every action. It just automatically is executed which is dangerous because it could do something harmful. So I wouldn't recommend that but yeah you know it exists. So if you want to use it on your own risk you can do that. Let's try again. npm rundev. Let's reload this. And there you go. We have a user interface that looks quite uh interesting. Let's say uh it doesn't look like it's properly spaced. So, these are just icons. These are not tabs. Um I can enter a stock symbol. Also, the design here is a little bit messed up, but let's see if it works. Let's do AAPL. Let's do search. And what we get here is a prediction current price predicted price. Now in this case it's a 1-day forecast confidence medium. I'm I'm curious to know how the confidence is actually calculated. Uh let's go and do Microsoft. This is now another prediction. I think these are cached because it seems to be instantaneous. Let's do something like uh GS Goldman Sachs. Uh for this one it loaded or it took some time. So yeah, but this is actually kind of kind of interesting. Let's try to do some adjustments here in terms of style. So what I want to do is I want to have better spacing and I want to have dark mode. So what I'm going to say here is uh please make sure everything is properly spaced and professional in the components. also make everything dark mode if that is a proper English sentence. So it adjusts the CSS file and the components. It also updates the utility functions here to be adjusted for the dark mode. And now it's done. So let's wait for the output to finish and then let's rerun the application and see if the interface looks better. So, let's do npm rundef. Let's take that and let's reload. There you go. We have a dark mode. We still have the problem here with the uh search symbol and the box. But besides that, it actually looks kind of uh good. So, I think we can keep that. I don't want to now uh waste time just fixing the small bug. We can do that easily. If I say that this is a problem, it will just reposition it. Uh but let's see if the functionality still works. So we can click here on the popular stocks. I can also enter something like Goldman Sachs. There you go. Maybe Boeing as well. I'm just thinking of companies that are not listed here. So there you go with the prediction. Now I don't know this confidence if this is just something that it made up in the front end. Uh we could go deeper into that. But I think this is kind of a cool application uh to check. I think it usually predicts higher stock prices. So I don't think that this is necessarily uh very capable but maybe more training and more uh pre-processing of the data will make this better. This is always predicting now for one day a pretty high change in terms of price. But yeah, so what we could be doing is of course uh going back and forth looking into the code. Maybe this makes sense especially in the back end. The front end is just a wrapper, a UI wrapper around the back end. But we could go into the back end and see if the code makes sense. So we can go into the main py and see what is actually happening here in the predict uh function. So we have here predict and what it does is it takes that it fetches the data and then it engineers the features it drops nan values. Then it prepares the sequence and then it feeds that into our model to make a prediction. The predicted price is what the model outputs here and the confidence is always medium. Okay, this is a placeholder. This is what I thought. I don't think that we have actual confidence here. So in this case, what you could do of course is you could just get rid of that or you could um instruct the model or instruct uh warp to somehow come up with a metric here or maybe you would have to change the model. I think it's not very easy to just get a confidence. So in my case here since I didn't ask for it I would usually remove it since the front end now is based on that. Let's just keep it here for the sake of simplicity. This is more like a showcasing of the process. You can of course uh change this and adjust this to your specific use case. But what we want to do now is we want to take all of this and we want to dockerize it. So take all of this now. Take all this now back end front end and dockerize it. For this use docker files for each and docker compose yaml for the entire thing. Also use engine x as a reverse proxy. So everything is handled at port 80. Also make sure to adjust all the code everywhere. Everywhere so that it points to port 80. So it created a docker file for the back end. What does it do? It uses Python 3.13. That's fine. Work directory. It takes all of that. What is this? RMRF. Uh okay. Fine. install uv then it copies the project toml all the dependencies the health check now here we do have something now with localhost 8000 I think that's fine because we're using this in this one particular container uh we still need to have the ports of course behind the scenes so engineext can even reroute stuff for the front end we have uh the built this is uh reasonable because now we don't have um we no longer have npm rundev we actually build it and serve it statically with EngineX inside of the front end. So we have two engine X instances, one as a server, one as a reverse proxy. Then we have our engine X config. We have events, worker connections, uh 1,024, we have HTTP, a bunch of stuff that I don't think is necessarily uh mandatory here, but we have listen 80, which is uh engine x here. we have location slash is I'm not sure does this make sense now I'm not sure if this makes sense let me refine that by asking a question here uh is this the proper setup for rerouting to backend and front end it says you're absolutely right as every LM always says what it does now is it adjusts the docker file of the front Not sure that that was really a problem. Okay, so it removes the engine X config from the front end. Oh, this was the engine X config from the front end. Actually, this could make sense. I hope I didn't confuse it now because I thought this was the engine X config for the reverse proxy, but it actually says here for the front end container. Uh, so I hope I didn't mess it up now. I hope that this H maybe. Okay, let's just go with that. Let's see if it works. Otherwise, I will have to uh reverse this mistake that I made now because I question something that wasn't the thing I thought about. But now it creates an enginex configuration for the reverse proxy which is a different instance. So we use one engineext as I said for serving the front end the statics file the static files of the front end and another enginex instance for uh the reverse proxy which is for mapping here the different locations to the different uh servers that we have. So we have here the the front end at location slash and probably not even sure if we have the back end here. We don't really need the back end but it has it here as API. So actually of course we need it because we need to ping the API from the front end. So let's apply that. Now it adjusts the URLs in the front end which is important because now we're no longer using local host. We're using / API on the same uh port. So we need to apply that. And finally it generates a docker compose file. So we have here the backend which has the exported model here in a volume uh uses the default network probably bridge right. Yeah there you go. Then we have here the test for the health check which is just uh checking if the server the back end is available. Then we have the front end. And then we have engine x. That is it. So let's apply that. Then it creates a docker ignore file. This is nice to have but not necessary. Same thing for the front end. And a comprehensive readme file. Okay. I don't really need that but I don't want to interrupt it now. Okay. So that is crazy. Um, yeah, let's just accept that. We don't really need that, but it doesn't harm us. And now it creates some bash script for starting the whole thing. I actually don't want to use that. So, what I'm going to do is I'm going to just cancel and I'm going to say um actually I don't even need to ask it for help now because what I want to do is I want to see if it just works. So, what should work now is docker compos built should build the entire thing. Probably it's not going to work first try. That's my assumption. And maybe it works first try. That would be impressive. But there you go. We have a problem with mpm run build and it already automatically generates a fix. So what it says here is we have a bunch of errors here. Uh because of course we're using TypeScript and we're enforcing certain things here. We're saying okay unused imports and all that. Uh not acceptable. So there's an error because of that. What it's going to do now? It's going to generate a fix to get rid of all these problems and then we're going to try this again. Okay. It seems like it didn't really do anything. So I will just say fix the problem. Okay. So it doesn't seem to be able to see that. Let me just copy and paste that. So let's just do it like this. Maybe like this. Fix this. So it located all the errors in the three different files here. And now it fixes them. Now it adds some dependency here and uh it changes the data type of the timeout ID. So let's apply this as well. And now it tries to build again which we're not going to do because we're going to use docker compose again. Docker compose build. So this seems to have worked. And now the back end is running all the installation stuff. Okay. So everything was built successfully. Let's see if we can also do docker compose up and if everything runs properly. Usually that's not the case first try. Okay. So we got a problem here. No such file or directory. We have the pickle files here that are a problem. So I'm not sure if this is going to be recognized automatically as a uh fail. So I'm going to just copy this and write down here fix this and it can find the problem. It tries to find the model in this path and the model is actually at app training exported model. So it sees that this is the problem and now it's going to try to fix that. So I just have to apply that. And now it tries to restart Docker which again I'm going to cancel because I want to do it myself. Docker compose up. Actually I think we need to build. So Docker compose no need to generate a fix. Let's just docker compose built. And now docker compose up. Maybe first of all docker compose down. Not sure if that's necessary here. Doc compose up and the front end is started. Uvvicorn running on port 8000. Engine X is running too. So let's see if I can access this now at localhost. And it seems like I can do it. So this is localhost. And now let's do again Microsoft. Now it predicts that the price is going to fall. So let's click a bunch of these uh companies here. There you go. So it seems to work and we can also see probably if I go to the network tab if I press a button this is being sent to uh / API/predict. So we have a proper engine X setup here. Everything works now with Docker which brings us to the final point. We need to deploy this. So for the deployment I'm going to use Hner. This is just a platform that I'm familiar with. You can use whatever you want. You just need to get somehow access to a server. This can be your own server at home. This can be a Hner server. This can be Google Cloud. This can be Digital Ocean, Lenode, whatever kind of provider you want to use. I'm just going to go with Hner. Uh, and the deployment is then in the command line. So, we're going to do all of this with uh Docker. So, what I'm going to do here now is I'm going to rent a server instance. So, I'm going to just say I want to have a Nermber server and then I'm going to say Ubuntu. I'm going to say uh Intel AMD. I'm going to go with with this here. Uh, I'm going to go with a cheap one. 4 GB and 40 GB SSD. Let's go with that. Public IPv4, public IPv6. Uh, the root password via email is fine. I'm not going to use this longterm. So, I'm going to uh remove this instance anyway after the tutorial. So, an SSH key is not necessary. We have volumes. We have firewalls. Uh, backups. We don't need any of that since we're just playing around. Now uh we can call this tutorial server. And now we can say create and buy. Now this is going to cost me 551. Now I have the server here with a public IP address which is no longer going to be mine when you're watching this. So we have to wait for this to boot up. So you can see the status here is still initializing. And now the server is up. So what we need to do is we need to somehow connect to it. And if we don't know how to do that, we can do that with warp. So let's try the naive way. Maybe it works even. It's uh SSH root at and then the IP address. And here it says uh do you want to accept that now? Okay, the password is via email. So I will have to copy paste this here. Okay, it seems like there was a leading white space. This was the problem. So now we can change the password. There you go. And now we are in this session. So let's run ls here. pwd runs uh and shows me /root. So we do have some output here that is a bit annoying. So not sure there's probably an option here to get rid of that which I don't know about now. Uh but yeah, we can run basic commands here. And the idea now is I want to take my code and I want to put it on the server. So what I do here, I exit this and I say upload my whole project with all files to the server via SCP. So now it tries to run the command SCP and then the whole thing here uh with just slash. I don't want to do that. I want to do that here with slashroot. But besides that, it's fine. So run this. And I'm not sure if this is going to produce some problems. The problem I see is that I don't see what's happening. So maybe I want to just copy this and do it myself. That might be a good idea. So maybe I'm actually going to do that. I'm going to interrupt. I'm going to take that command because it asks for the password. This is the problem. If if it's interactive, we shouldn't do it like that. So I'm going to do this here. I'm going to again copy paste my password. And now it says no such file. Okay. Actually because yeah I mean the command was actually correct. Um I did something wrong here. So actually it's just that because that is automatically going to be root since we are actually root. So let me just paste this here. Let's try again. Now it's uploading everything. Actually I think it might be faster. uh provides the rync command. SCP is too slow. So now here it says uh project. I hope this works. Now let's try to copy this command without project. And now let's go and okay, I don't have arsync on my system. So, let's go pseudo Pac-Man- Srync. And now let's rerun the command. Now it should upload everything much faster. Okay, so actually we don't need the training. So we can abort this. I hope that the rest was still transmitted. So let's try uh the same thing. Actually, this is probably I should not do this verbose. Let's do it like this. And now we can do ls. And we can see we have a bunch of stuff here. Uh fly toml is from something I tried that I decided not to do. Uh so we do have backend and front end and engine x. I think that should be enough to get uh actually I don't have neoim here. That should be enough to get yeah the docker compose setup running. So what we need to do on the server is of course pseudoapp update to make sure we have all the repositories and then we want to do pseudoapp install docker because without docker or actually we don't do that with pseudoapp install I think for docker maybe we can ask warp so maybe I don't have to google that uh but I think docker has a uh a specific command uh that we need to run here so install install docker on this headner abuntu machine. I already did that. I already did that. Okay, so these are the dependencies for Docker. Let's install them. That should also work. And now it uses the curl command. This is what I expected. Giving the right permissions. Now it adds the repository. And then I think it's going to do an install or actually another apt update. And this one I think is something that we should run manually. So let's go to edit. Let's copy this or actually provide the command as text. There you go. So I can just copy it. I can run it interactively because I think I'm going to have to approve this or actually not. Okay, just stall stat. Uh then we need to do start enable and then we can use docker. All right. So systemct ctl start docker or what was the command? Yeah, I think that's that's correct. systemctl enable docker and then we should be able to see that docker is installed. Perfect. So now what I want to do is I want to just say docker compose built. All right. So everything was built successfully. Now let's do docker. Actually it already suggested it I think. So let's do control shift uh enter. This should just be docker compose up. Yeah, dashd. So, it's going to run in the background. And then we can try to go to the IP address. So, I'm going to copy that. I'm going to open that in a new tab. I'm going to just type it. Uh, I think the command is not yet uh being run properly. So, let's just run it ourselves. Docker compose up. Let's see what happens. application failed because we don't have Oh, okay. Actually, we do need to upload the uh exported model directory. We didn't do that. So, let's exit. Let's um let's go to training. Okay. So, what we want to do here, upload the training slashexported uh what was it? model directory to the same path remotely or in the server but don't upload any other stuff like VNF etc. use rync. So what it says here is run this command. This seems reasonable. Let's run. This should also not be too large. Oh, actually I need to run this myself again. So I will have to ask for provide the command as text because of course I need to enter my password again. So I'm going to copy this here like this. I'm going to run this. I'm going to enter my password and there you go. Then we're going to go back to SSH and I'm going to do another docker compose up. Okay. So, so there seems to be a problem uh still with the meta data. So, let's actually see what this problem could be. We do have training. We do have exported model. But we don't have anything in here actually. Maybe my command was mis uh understood because I did actually want to take everything from exported model. So actually I do want to do I'm not sure if an asterisk is enough. Okay, doesn't seem to work. Maybe I'm doing something wrong. Let's go locally to exported model. Upload all files in exported model to the directory on the server. Provide the command text use rync. So what it does here is it takes that and path destination directory. Okay. Root at what was the IP address? Somehow it seems to not know it anymore. And the path is root slash training/exported model. So I'm not sure if I'm misunderstanding something about this command. There you go. Now it uploaded the three files. So let's go and log into the server again. And now we should be able to do docker compose up. There you go. We have still a problem because I think we need to docker compose built. Okay, so it still doesn't find app training exported model metadata pickle file. So let's see if we do have it now on the server. We do have it here. So that's not the problem. So, I'm not sure what the problem is, but let's try and say why does my backend not find the exported models when running in Docker, the files exist and I do map a volume in Docker Compose. Okay, so it says that it should work now. I'm not sure. It doesn't seem to work. So I don't think that it really did something here. Let's just try to restart this by using docker compose down. Docker compose up. So I'm going to say here docker compose down. Docker compose up. Okay. So the back end is running now. The front end is running. Engine X needs to be started now. And if this works and if everything's running, we should be able to access this not as HTTPS but as HTTP uh but at port 80. That should be possible. There you go. We have it deployed. We have this application here now. Uh it makes the predictions perfectly and this is deployed on the server. Of course, we don't have a domain here. This is something that you would have to buy. But this is our application deployed here on Hzner with Docker. And we did basically everything with warp. You saw that it's not enough to just prompt. You need to understand what is happening. You need to understand what the errors are. You need to know what potential uh traps are and you need to be aware of the stuff that's happening. But overall, you can really build an application without writing code yourself. And this is how we build this stock predictor AI in Python, React, and with Docker and EngineX. So that's it for today's video. I hope you enjoyed it and hope you learned something. If so, let me know by hitting a like button and leaving a comment in the comment section down below. Of course, also don't forget to check out Warp, the sponsor of this video, the tool that we used to build this entire application and to deploy it. As I said, they have a free plan and it's a very powerful tool as you saw. It's basically a cursor and terminal and everything in one. So, you have this uh full coding platform as a terminal. Make sure to check them out uh at the link in the description down below. And besides that, don't forget to subscribe to this channel and hit the notification bell to not miss a single future video for free. Other than that, thank you much for watching. See you in the next video and bye.
Original Description
Try Warp for free: https://go.warp.dev/neuralnine
And use this code for 2 months free of Warp Pro: NEURALNINE
Today we are going to build a full stock prediction tool in Python. We will train a model with PyTorch, build a back-end with FastAPI, a front-end with React and then we are going to deploy the entire thing with Docker and NGINX. All of this will be done by prompt using Warp.
◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾
📚 Programming Books & Merch 📚
🐍 The Python Bible Book: https://www.neuralnine.com/books/
💻 The Algorithm Bible Book: https://www.neuralnine.com/books/
👕 Programming Merch: https://www.neuralnine.com/shop
💼 Services 💼
💻 Freelancing & Tutoring: https://www.neuralnine.com/services
🖥️ Setup & Gear 🖥️: https://neuralnine.com/extras/
🌐 Social Media & Contact 🌐
📱 Website: https://www.neuralnine.com/
📷 Instagram: https://www.instagram.com/neuralnine
🐦 Twitter: https://twitter.com/neuralnine
🤵 LinkedIn: https://www.linkedin.com/company/neuralnine/
📁 GitHub: https://github.com/NeuralNine
🎙 Discord: https://discord.gg/JU4xr8U3dm
Timestamps:
(0:00) Intro
(0:57) Preview
(2:08) Plan For Project
(4:47) Training Model with PyTorch
(12:30) FastAPI Back-End
(18:50) React Front-End
(28:40) Docker & Containerization
(36:49) Deployment
(49:08) Outro
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from NeuralNine · NeuralNine · 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
Visualizing Stock Data With Candlestick Charts in Python
NeuralNine
Python Beginner Tutorial #1 - Installation and First Program
NeuralNine
Python Beginner Tutorial #2 - Variables and Data Types
NeuralNine
Python Beginner Tutorial #3 - Operators and User Input
NeuralNine
Python Beginner Tutorial #4 - If Statements and Conditions
NeuralNine
Python Beginner Tutorial #5 - Loops
NeuralNine
Python Beginner Tutorial #6 - Sequences and Collections
NeuralNine
Python Beginner Tutorial #7 - Functions
NeuralNine
Python Beginner Tutorial #8 - Exception Handling
NeuralNine
Python Beginner Tutorial #9 - File Operations
NeuralNine
Python Beginner Tutorial #10 - String Functions
NeuralNine
Python Intermediate Tutorial #1 - Classes and Objects
NeuralNine
Python Intermediate Tutorial #2 - Inheritance
NeuralNine
Python Intermediate Tutorial #3 - Multithreading
NeuralNine
Python Intermediate Tutorial #4 - Synchronizing Threads
NeuralNine
Python Intermediate Tutorial #5 - Events and Daemon Threads
NeuralNine
Python Intermediate Tutorial #6 - Queues
NeuralNine
Python Intermediate Tutorial #7 - Sockets and Network Programming
NeuralNine
Python Intermediate Tutorial #8 - Database Programming
NeuralNine
Python Intermediate Tutorial #9 - Recursion
NeuralNine
Python Intermediate Tutorial #10 - XML Processing
NeuralNine
Python Intermediate Tutorial #11 - Logging
NeuralNine
Python Data Science Tutorial #1 - Anaconda and PyCharm Setup
NeuralNine
Python Data Science Tutorial #2 - NumPy Arrays
NeuralNine
Python Data Science Tutorial #3 - Numpy Functions
NeuralNine
Python Data Science Tutorial #4 - Plotting Functions With Matplotlib
NeuralNine
Python Data Science Tutorial #5 - Subplots and Multiple Windows
NeuralNine
Python Data Science Tutorial #6 - Matplotlib Styling
NeuralNine
Python Data Science Tutorial #7 - Bar Charts with Matplotlib
NeuralNine
Python Data Science Tutorial #8 - Pie Charts with Matplotlib
NeuralNine
Python Data Science Tutorial #9 - Plotting Histograms with Matplotlib
NeuralNine
Python Data Science Tutorial #10 - Scatter Plots with Matplotlib
NeuralNine
Python Data Science Tutorial #11 - 3D Plotting with Matplotlib
NeuralNine
Python Data Science Tutorial #12 - Pandas Series
NeuralNine
Python Data Science Tutorial #13 - Pandas Data Frames
NeuralNine
Python Data Science Tutorial #14 - Pandas Statistics
NeuralNine
Python Data Science Tutorial #15 - Pandas Sorting and Functions
NeuralNine
Python Data Science Tutorial #16 - Pandas Merging Data Frames
NeuralNine
Python Data Science Tutorial #17 - Pandas Queries
NeuralNine
Python Machine Learning Tutorial #1 - What is Machine Learning?
NeuralNine
Python Machine Learning Tutorial #2 - Linear Regression
NeuralNine
Python Machine Learning Tutorial #3 - K-Nearest Neighbors Classification
NeuralNine
Python Machine Learning #4 - Support Vector Machines
NeuralNine
Python Machine Learning Tutorial #5 - Decision Trees and Random Forest Classification
NeuralNine
Python Machine Learning Tutorial #6 - K-Means Clustering
NeuralNine
Python Machine Learning Tutorial #7 - Neural Networks
NeuralNine
Python Machine Learning Tutorial #8 - Handwritten Digit Recognition with Tensorflow
NeuralNine
Generating Poetic Texts with Recurrent Neural Networks in Python
NeuralNine
Stock Portfolio Visualization with Matplotlib in Python
NeuralNine
Analyzing Coronavirus with Python (COVID-19)
NeuralNine
Making Text Images Readable Again with Python and OpenCV
NeuralNine
Neural Networks Simply Explained (Theory)
NeuralNine
Motion Filtering with OpenCV in Python
NeuralNine
Top 5 Programming Languages To Learn in 2020
NeuralNine
Simple TCP Chat Room in Python
NeuralNine
Image Classification with Neural Networks in Python
NeuralNine
Edge Detection with OpenCV in Python
NeuralNine
S&P 500 Web Scraping with Python
NeuralNine
Simple Sentiment Text Analysis in Python
NeuralNine
Introduction - Algorithms & Data Structures #1
NeuralNine
More on: ML Pipelines
View skill →Related Reads
🎓
Tutor Explanation
DeepCamp AI