We’ve now downloaded the data! In the real world, we want to save the data to disk, so we can access it again if we need it without calling the API over and over. We’ll use data for a single stock (Microsoft) from when it started trading to the present. We can install this by typing pip install yfinance in the command line (or typing !pip install yfinance in Jupyter notebook). ![]() To do this, we’ll use the yfinance python package. Downloading the dataįirst, we’ll download the data from Yahoo Finance. Setup the dataset to predict future prices using historical pricesĪt the end, we’ll document some potential future directions we can go in to improve the technique.Download MSFT stock prices from Yahoo finance.Here are the steps that we’ll follow to make predictions on the price of MSFT stock: We’ll be looking at Microsoft stock, which has the stock symbol MSFT. So our model will have low recall, but high precision. This is okay, since we’d rather minimize our potential losses than maximize our potential gains. This means that we will have to accept a lot of false negatives – days when we predict that the price will go down, but it actually goes up. This will ensure that we minimize how much money we lose with false positives (days when we buy the stock, but the price actually goes down). Therefore, we’ll be using precision as our error metric for our model, which is true positives / (false positives + true positives). We want to maximize our true positives – days when the model predicts that the price will go up, and it actually goes go up. If the model says that the price will go down, we won’t do anything. If the model says that the price will increase, we’ll buy stock. This model needs to predict tomorrow’s closing price using data from today. To tell us when to trade, we want to train a machine learning model. We’ll buy stock when the market opens, and sell it when the market closes. So when we buy a stock, we want to be fairly certain that the price will increase. We’re interested in making profitable stock trades with minimal risk. In this case, let’s say that we are trading stocks. So spend a good amount of time thinking about what error metric you want to target and how your algorithm will be used. This is because hiring managers want your project to be as close to actual data science work as possible. ![]() When making a project, even if it is for your portfolio, it is important to think about how it might be used in the real world. For your reference, you can see the completed project here.įirst, let’s tie what we’ll be doing in this project to the real world. ![]() As we do that, we’ll discuss what makes a good project for a data science portfolio, and how to present this project in your portfolio. Along the way, we’ll download stock prices, create a machine learning model, and develop a back-testing engine. In this project, we’ll learn how to predict stock prices using python, pandas, and scikit-learn. DecemPortfolio Project: Predicting Stock Prices Using Pandas and Scikit-learn
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |